update it
This commit is contained in:
parent
d9281ba7c0
commit
c989c76951
|
@ -0,0 +1,20 @@
|
|||
#define TRACE_MODULE _cw_common
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define PLMN_ID_DIGIT1(x) (((x) / 100) % 10)
|
||||
#define PLMN_ID_DIGIT2(x) (((x) / 10) % 10)
|
||||
#define PLMN_ID_DIGIT3(x) ((x) % 10)
|
||||
|
||||
void encode_plmn_id(c_uint8_t *buf, plmn_id_t *plmn_id)
|
||||
{
|
||||
buf[0] = (PLMN_ID_DIGIT2(plmn_id->mcc) << 4) | PLMN_ID_DIGIT1(plmn_id->mcc);
|
||||
|
||||
if (plmn_id->mnc_len == 2)
|
||||
buf[1] = (0xf << 4);
|
||||
else
|
||||
buf[1] = (PLMN_ID_DIGIT1(plmn_id->mnc) << 4);
|
||||
buf[1] |= PLMN_ID_DIGIT3(plmn_id->mcc);
|
||||
|
||||
buf[2] = (PLMN_ID_DIGIT3(plmn_id->mnc) << 4) | PLMN_ID_DIGIT2(plmn_id->mnc);
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef __CELLWIRE_COMMON_H__
|
||||
#define __CELLWIRE_COMMON_H__
|
||||
|
||||
#include "core_errno.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct _plmn_id_t {
|
||||
c_uint16_t mcc;
|
||||
c_uint16_t mnc;
|
||||
c_uint16_t mnc_len;
|
||||
} plmn_id_t;
|
||||
|
||||
CORE_DECLARE(void) encode_plmn_id(c_uint8_t *buf, plmn_id_t *plmn_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* !__CELLWIRE_COMMON_H__ */
|
Loading…
Reference in New Issue