| #include <stdio.h> |
| #include <stdlib.h> |
| #include <stdbool.h> |
| #include <dlfcn.h> |
| #include <stdint.h> |
| #include <string.h> |
| #include <pthread.h> |
| |
| //mbtk include |
| #define LYNQ_AIR_PLANE_MODE_ON 4 //at+cfun = 4 |
| #define LYNQ_AIR_PLANE_MODE_OFF 1 // at+cfun = 1 |
| |
| |
| #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
| |
| #ifndef FALSE |
| #define FALSE (0) |
| #endif |
| |
| |
| #ifndef TRUE |
| #define TRUE (!FALSE) |
| #endif |
| |
| typedef unsigned int uint32; |
| typedef unsigned char uint8; |
| typedef unsigned short uint16; |
| typedef void (*mbtk_info_callback_func)(const void* data, int data_len); |
| |
| typedef enum |
| { |
| MBTK_DEV_MODEM_MIN_FUN, //Modem 最小功能 |
| MBTK_DEV_MODEM_FULL_FUN, //Modem 全功能 |
| MBTK_DEV_MODEM_DISABLE_RECEIVE_RF_CIRCUITS = 3, //Modem 禁用射频接收电路 |
| MBTK_DEV_MODEM_DISABLE_TRANSMIT_AND_RECEIVE_RF_CIRCUITS, //Modem禁用射频发射和接收电路 |
| MBTK_DEV_MODEM_DISABLE_SIM, //Modem 禁用(U)SIM 卡 |
| MBTK_DEV_MODEM_TURN_OFF_FULL_SECONDARY_RECEIVE, //Modem 完全禁用辅助接收 |
| }MBTK_DEV_MODEM_FUNCTION; |
| |
| typedef enum |
| { |
| MBTK_CELL_TYPE_GSM = 0, |
| MBTK_CELL_TYPE_UMTS, |
| MBTK_CELL_TYPE_LTE |
| } mbtk_cell_type_enum; |
| |
| typedef struct |
| { |
| MBTK_DEV_MODEM_FUNCTION fun; |
| int rst; |
| } mbtk_modem_info_t; |
| |
| typedef struct |
| { |
| int client_fd; |
| pthread_t read_thread_id; |
| int exit_fd[2]; |
| bool is_waitting; |
| pthread_cond_t cond; |
| pthread_mutex_t mutex; |
| |
| pthread_mutex_t send_mutex; |
| |
| // Temp response data. |
| uint16 info_err; |
| uint16 data_len; |
| void *data; |
| |
| //mbtk wyq for server_ready_status add start |
| char server_ready_status; |
| //mbtk wyq for server_ready_status add end |
| |
| mbtk_info_callback_func net_state_cb; |
| mbtk_info_callback_func call_state_cb; |
| mbtk_info_callback_func sms_state_cb; |
| mbtk_info_callback_func radio_state_cb; |
| mbtk_info_callback_func sim_state_cb; |
| mbtk_info_callback_func pdp_state_cb; |
| //add signal by xr |
| mbtk_info_callback_func signal_state_cb; |
| } mbtk_info_handle_t; |
| |
| |
| |
| typedef struct |
| { |
| // LTE server cell: tac, PCI, dlEuarfcn, ulEuarfcn, band |
| // LTE cell: phyCellId,euArfcn,rsrp,rsrq |
| // WCDMA server cell: lac, ci, arfcn |
| // WCDMA cell: lac, ci, arfcn |
| // GSM server cell: lac, ci, arfcn, bsic |
| // GSM cell: |
| mbtk_cell_type_enum type : 8; |
| uint32 value1; //tac |
| uint32 value2; //pci |
| uint32 value3; //dlEuarfcn |
| uint32 value4; //ul arfcn |
| uint32 value5; //band |
| uint32 value6; //mcc |
| uint32 value7; //mnc |
| uint32 value8; //cid |
| uint32 value9; //rsrp |
| uint32 value10; //cell identiy |
| } __attribute__((packed)) mbtk_cell_info_t; |
| |
| |
| |
| |
| |
| typedef struct |
| { |
| uint8 net_pref; // mbtk_net_pref_enum |
| uint16 gsm_band; // mbtk_gsm_band_enum |
| uint16 umts_band; // mbtk_umts_band_enum |
| uint32 tdlte_band; // mbtk_tdlte_band_enum |
| uint32 fddlte_band; // mbtk_fddlte_band_enum |
| uint32 lte_ext_band; // mbtk_lte_ext_band_enum |
| } __attribute__((packed)) mbtk_band_info_t; |
| |
| typedef struct list_arraynode |
| { |
| void *data; |
| struct list_arraynode *next; |
| } list_arraynode_t; |
| |
| typedef struct list_treenode |
| { |
| list_arraynode_t *data; |
| int count; |
| struct list_treenode *left; |
| struct list_treenode *right; |
| } list_treenode_t; |
| |
| typedef int (*list_sort_func)(void *data1, void *data2); |
| typedef void (*list_free_func)(void *data); |
| |
| typedef struct list_node |
| { |
| uint32 size; |
| list_sort_func sort_func; |
| list_free_func free_func; |
| |
| uint32 cur_index; |
| list_arraynode_t *cur_array_data; |
| |
| list_arraynode_t array_data; |
| list_treenode_t tree_data; |
| } list_node_t; |
| |
| /* |
| 0: GSM |
| 1: GSM Compact |
| 2: UTRAN |
| 3: GSM w/EGPRS |
| 4: UTRAN w/HSDPA |
| 5: UTRAN w/HSUPA |
| 6: UTRAN w/HSDPA and HSUPA |
| 7: E-UTRAN |
| 8: UTRAN HSPA+ |
| */ |
| typedef enum { |
| MBTK_RADIO_TECH_GSM = 0, |
| MBTK_RADIO_TECH_GSM_COMPACT, |
| MBTK_RADIO_TECH_UTRAN, |
| MBTK_RADIO_TECH_GSM_EGPRS, |
| MBTK_RADIO_TECH_UTRAN_HSDPA, |
| MBTK_RADIO_TECH_UTRAN_HSUPA, |
| MBTK_RADIO_TECH_UTRAN_HSDPA_HSUPA, |
| MBTK_RADIO_TECH_E_UTRAN, // LTE |
| MBTK_RADIO_TECH_UTRAN_HSPA |
| } mbtk_radio_technology_enum; |
| |
| typedef struct |
| { |
| /* |
| 0: automatic |
| 1: manual |
| */ |
| uint8 net_sel_mode; |
| /* |
| 0: GSM |
| 1: GSM Compact |
| 2: UTRAN |
| 3: GSM w/EGPRS |
| 4: UTRAN w/HSDPA |
| 5: UTRAN w/HSUPA |
| 6: UTRAN w/HSDPA and HSUPA |
| 7: E-UTRAN |
| 8: UTRAN HSPA+ |
| 0xFF: Unused |
| */ |
| uint8 net_type; |
| //uint8 plmn[10]; // 46000 |
| /* |
| 0: unknown |
| 1: available |
| 2: current |
| 3: forbidden |
| */ |
| uint8 net_state; |
| uint32 plmn; |
| } __attribute__((packed)) mbtk_net_info_t; |
| |
| |
| typedef enum |
| { |
| MBTK_NET_REG_STATE_NON = 0, |
| MBTK_NET_REG_STATE_HOME, |
| MBTK_NET_REG_STATE_SEARCHING, |
| MBTK_NET_REG_STATE_DENIED, |
| MBTK_NET_REG_STATE_UNKNOWN, |
| MBTK_NET_REG_STATE_ROAMING, |
| MBTK_NET_REG_STATE_SMS_ONLY, |
| MBTK_NET_REG_STATE_ROAMING_SMS, |
| MBTK_NET_REG_STATE_ATTACHED_EMERGENCY, |
| MBTK_NET_REG_STATE_CSFB_HOME, |
| MBTK_NET_REG_STATE_CSFB_ROAMING, |
| MBTK_NET_REG_STATE_EMERGENCY_ONLY |
| } mbtk_net_reg_state_enum; |
| |
| typedef struct |
| { |
| uint8 call_state;// mbtk_net_reg_state_enum |
| uint8 data_state;// mbtk_net_reg_state_enum |
| uint8 ims_state;// mbtk_net_reg_state_enum |
| uint8 type; // mbtk_radio_technology_enum |
| uint16 lac; |
| uint32 ci; |
| } __attribute__((packed)) mbtk_net_reg_info_t; |
| |
| typedef struct |
| { |
| uint8 type; // mbtk_radio_technology_enum |
| uint8 rssi; // 0: 113 dBm or less |
| // 1: 111 dBm |
| // 2��30: 109��53 dBm |
| // 31: 51 dBm or greater |
| // 99: not known or not detectable |
| uint8 rxlev;// 0:rssi < -110 dBm |
| // 1: -110 dBm �� rssi < -109 dBm |
| // 2: -109 dBm �� rssi < -108 dBm |
| // ...... |
| // 61: -50 dBm �� rssi < -49 dBm |
| // 62: -49 dBm �� rssi < -48 dBm |
| // 63: -48 dBm �� rssi |
| // 99: not known or not detectable |
| uint8 ber; // 0...7 as RXQUAL values in the table in 3GPP TS 45.008 [20] subclause 8.2.4 |
| // 99 not known or not detectable |
| uint8 rscp; // 0: rscp < -120 dBm |
| // 1: -120 dBm �� rscp < -119 dBm |
| // 2: -119 dBm �� rscp < -118 dBm |
| // ...... |
| // 94: -27 dBm �� rscp < -26 dBm |
| // 95: -26 dBm �� rscp < -25 dBm |
| // 96: - 25 dBm �� rscp |
| // 255: not known or not detectable |
| uint8 ecno; // 0: Ec/Io < -24 dB |
| // 1: -24 dB �� Ec/Io < -23.5 dB |
| // 2: -23.5 dB �� Ec/Io < -23 dB |
| // ...... |
| // 47: -1 dB �� Ec/Io < -0.5 dB |
| // 48: -0.5 dB �� Ec/Io < 0 dB |
| // 49: 0 dB �� Ec/Io |
| // 255: not known or not detectable |
| uint8 rsrq; // 0: rsrq < -19.5 dB |
| // 1: -19.5 dB �� rsrq < -19 dB |
| // 2: -19 dB �� rsrq < -18.5 dB |
| // ...... |
| // 32: -4 dB �� rsrq < -3.5 dB |
| // 33: -3.5 dB �� rsrq < -3 dB |
| // 34: -3 dB �� rsrq |
| // 255: not known or not detectable |
| uint8 rsrp; // 0: rsrp < -140 dBm |
| // 1: -140 dBm �� rsrp < -139 dBm |
| // 2: -139 dBm �� rsrp < -138 dBm |
| // ...... |
| // 95: -46 dBm �� rsrp < -45 dBm |
| // 96: -45 dBm �� rsrp < -44 dBm |
| // 97: -44 dBm �� rsrp |
| // 255: not known or not detectable |
| } __attribute__((packed)) mbtk_signal_info_t; |
| |
| #define lib_gsw_nw_path "/lib/libgsw_lib.so" |
| static void *dlHandle_nw = NULL; |
| |
| //gsw include |
| |
| |
| #define GSW_HAL_SUCCESS 0 |
| #define GSW_HAL_FAIL -1 |
| #define GSW_HAL_MEM_INVAILD -2 |
| #define GSW_NW_OPERATION_NAME_LEN 128 |
| #define GSW_NW_PLMN_LEN 6 |
| #define GSW_NW_MCC_LEN 3 |
| #define GSW_NW_MNC_LEN 3 |
| #define GSW_NW_PARA_MAX_LEN 128 |
| #define GSW_MCC_MAX_LEN 16 |
| #define GSW_MNC_MAX_LEN 16 |
| #define GSW_APN_CHANNEL_MAX 10 |
| #define GSW_POXY_ADDR_MAX_LEN 64 |
| #define GSW_PDP_TYPE_MAX_LEN 16 |
| #define GSW_APN_MAX_LEN 65 |
| #define GSW_APN_ID_MAX_LEN 32 |
| #define GSW_APN_TYPE_MAX_LEN 50 |
| #define GSW_USR_MAX_LEN 16 |
| #define GSW_PWD_MAX_LEN 16 |
| #define GSW_AUTH_TYPE_MAX_LEN 50 |
| #define GSW_PROTOCO_MAX_LEN 64 |
| #define GSW_CARRIER_ID_MAX_LEN 64 |
| #define GSW_IFACE_NAME_MAX_LEN 50 |
| #define GSW_PDP_ADDR_MAX_LEN 64 |
| #define GSW_DNS_APN_MAX_LEN 64 |
| #define GSW_GETWAYS_ADDR_MAX_LEN 64 |
| #define GSW_RSP_MAX_LEN 256 |
| #define GSW_PLMN_LIST_MAX_LEN 85 |
| |
| |
| |
| typedef enum service_domain |
| { |
| GSW_SRV_DOMAIN_NO_SVC = 0x0, /**< no service */ |
| GSW_SRV_DOMAIN_CS_ONLY = 0x1, /**< cs only */ |
| GSW_SRV_DOMAIN_PS_ONLY = 0x2, /**< ps only */ |
| GSW_SRV_DOMAIN_CS_PS = 0x3, /**< reg all in service */ |
| } GSW_SERVICE_DOMAIN_E; |
| |
| typedef enum gsw_network_reg_state |
| { |
| GSW_NETWORK_REG_NOT_REGISTERED = 0x0, /**< no service */ |
| GSW_NETWORK_REG_REGISTERED = 0x1, /**< reg in service home */ |
| GSW_NETWORK_REG_NOT_REGISTERED_SEARCHING = 0x2, /**< searching network */ |
| GSW_NETWORK_REG_REGISTRATION_DENIED = 0x3, /**< network denny device */ |
| GSW_NETWORK_REG_REGISTRATION_UNKNOWN = 0x4, /**< unknown state */ |
| GSW_NETWORK_REG_REGISTRATION_ROAMING = 0x5, /**< roaming state in service */ |
| GSW_NETWORK_REG_LIMITED_SERVICE = 0x6, /**< limited service */ |
| } GSW_NW_REG_STATE_E; |
| |
| typedef enum gsw_network_radio_interface |
| { |
| GSW_NETWORK_RADIO_NO_SVC = 0x0, /**< radio state no service */ |
| GSW_NETWORK_RADIO_CDMA_1X = 0x1, /**< cdma 1x */ |
| GSW_NETWORK_RADIO_CDMA_1XEVDO = 0x2, /**< cdma evdo */ |
| GSW_NETWORK_RADIO_AMPS = 0x3, /**< amps gsm 2g*/ |
| GSW_NETWORK_RADIO_GSM = 0x4, /**< gsm */ |
| GSW_NETWORK_RADIO_UMTS = 0x5, /**< umts wcdma*/ |
| GSW_NETWORK_RADIO_LTE = 0x6, /**< LTE 4G */ |
| GSW_NETWORK_RADIO_TDSCDMA = 0x7, /**< TDS 3G*/ |
| GSW_NETWORK_RADIO_NR5G = 0x8, /**< NR 5G*/ |
| } GSW_NW_RADIO_ACCESS_TECH_E; |
| |
| |
| typedef enum gsw_network_roaming_state |
| { |
| GSW_NETWORK_ROAMING_OFF = 0x0, /**< roaming off */ |
| GSW_NETWORK_ROAMING_ON = 0x1, /**< roaming on*/ |
| } GSW_NW_ROAMING_STATE_E; |
| |
| typedef enum oprate_mode |
| { |
| GSW_OP_MODE_LPM = 0, /**< radio state off*/ |
| GSW_OP_MODE_ONLINE = 1, /**< radio state on*/ |
| GSW_OP_MODE_FTM = 2, /**< radio state ftm*/ |
| GSW_OP_MODE_OFFLINE = 3, /**< radio state offline*/ |
| } OPERATE_MODE_E; |
| |
| typedef enum prefer_mode |
| { |
| GSW_PREFER_MODE_GSW = 1, /**<2G only*/ |
| GSW_PREFER_MODE_WCDMA = 2, /**< 3G only*/ |
| GSW_PREFER_MODE_WCDMA_GSM = 3, /**< 3G/2G*/ |
| GSW_PREFER_MODE_LTE = 4, /**< 4G only*/ |
| GSW_PREFER_MODE_NR5G = 5, /**< 5G only*/ |
| GSW_PREFER_MODE_NR5G_LTE = 8, /**< 5G/4G*/ |
| GSW_PREFER_MODE_LTE_WCDMA_GSM = 9, /**< 4G/3G/2G*/ |
| GSW_PREFER_MODE_NR5G_LTE_WCDMA_GSM = 32, /**< 5G/4G/3G/2G*/ |
| } PREFER_MODE_E; |
| |
| typedef enum gsw_hal_nw_mode_state_type |
| { |
| GSW_MODEM_STATE_UNKNOWN = 0, |
| GSW_MODEM_STATE_ONLINE, |
| GSW_MODEM_STATE_OFFLINE, |
| GSW_SDK_STATE_SERVICE_DOWN, |
| GSW_SDK_STATE_SERVICE_UP,// service down->up 需要routectl 重启 |
| GSW_SDK_STATE_GPS_DOWN, |
| GSW_SDK_STATE_GPS_UP, |
| } gsw_mode_state_e; |
| |
| |
| typedef struct |
| { |
| GSW_NW_RADIO_ACCESS_TECH_E rej_rat; /**< current network radio tech*/ |
| GSW_SERVICE_DOMAIN_E rej_domain; /**< reject code from ps or cs*/ |
| int rej_cause; /**< reject code number*/ |
| } GSW_NW_REJ_CAUSE_E; |
| |
| typedef struct |
| { |
| int32_t gw_sig_valid; /**< 1 valid,1 invalid*/ |
| int32_t rssi; /**< Valid values are (0-31, 99) as defined in TS 27.007 8.5 */ |
| int32_t wcdma_sig_valid;/**< 1 valid,0 invalid*/ |
| int32_t rscp; /**< The Received Signal Code Power in dBm multipled by -1. |
| * Range : 25 to 120 |
| * INT_MAX: 0x7FFFFFFF denotes invalid value. |
| * Reference: 3GPP TS 25.123, section 9.1.1.1 */ |
| int32_t ecno; /**< Valid values are positive integers. This value is the actual Ec/Io multiplied |
| * by -10. Example: If the actual Ec/Io is -12.5 dB, then this response value |
| * will be 125.*/ |
| int32_t lte_sig_valid;/**< 1 valid,0 invalid*/ |
| int32_t rsrp; /**< The current Reference Signal Receive Power in dBm multipled by -1. |
| * Range: 44 to 140 dBm |
| * INT_MAX: 0x7FFFFFFF denotes invalid value. |
| * Reference: 3GPP TS 36.133 9.1.4 */ |
| int32_t rsrq; /**< The current Reference Signal Receive Quality in dB multiplied by -1. |
| * Range: 20 to 3 dB. |
| * INT_MAX: 0x7FFFFFFF denotes invalid value. |
| * Reference: 3GPP TS 36.133 9.1.7 */ |
| int32_t rssnr; /**< The current reference signal signal-to-noise ratio in 0.1 dB units. |
| * Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB). |
| * INT_MAX : 0x7FFFFFFF denotes invalid value. |
| * Reference: 3GPP TS 36.101 8.1.1 */ |
| int32_t nr_sig_valid;/**<1 valid,0 invalid*/ |
| int32_t ssRsrp; /**< SS(Synchronization Signal) reference signal received power, multipled by -1. |
| * Reference: 3GPP TS 38.215. |
| * Range [44, 140], INT_MAX means invalid/unreported.*/ |
| int32_t ssRsrq; /**< SS reference signal received quality, multipled by -1. |
| * Reference: 3GPP TS 38.215. |
| * Range [3, 20], INT_MAX means invalid/unreported.*/ |
| int32_t ssSinr; /**< SS signal-to-noise and interference ratio. |
| * Reference: 3GPP TS 38.215 section 5.1.*, 3GPP TS 38.133 section 10.1.16.1. |
| * Range [-23, 40], INT_MAX means invalid/unreported.*/ |
| int32_t csiRsrp; /**< CSI reference signal received power, multipled by -1. |
| * Reference: 3GPP TS 38.215. |
| * Range [44, 140], INT_MAX means invalid/unreported.*/ |
| int32_t csiRsrq; /**< CSI reference signal received quality, multipled by -1. |
| * Reference: 3GPP TS 38.215. |
| * Range [3, 20], INT_MAX means invalid/unreported.*/ |
| int32_t csiSinr; /**< CSI signal-to-noise and interference ratio. |
| * Reference: 3GPP TS 138.215 section 5.1.*, 3GPP TS 38.133 section 10.1.16.1. |
| * Range [-23, 40], INT_MAX means invalid/unreported.*/ |
| } signalStrength_t; |
| |
| typedef struct |
| { |
| GSW_NW_REG_STATE_E reg_state; /**< network cs regstate*/ |
| GSW_NW_REG_STATE_E ps_state; /**< network ps regstate*/ |
| GSW_NW_RADIO_ACCESS_TECH_E reg_rat; /**< current radio state*/ |
| GSW_SERVICE_DOMAIN_E srv_domain; /**< current cs or ps state*/ |
| GSW_NW_ROAMING_STATE_E roaming_ind; /**< roaming state*/ |
| char reg_plmn[GSW_NW_PLMN_LEN + 1]; /**< current cell plmn*/ |
| char operator_name[GSW_NW_OPERATION_NAME_LEN + 1]; /**< operator name*/ |
| char cell_id[128]; /**< cell id*/ |
| char tac[128]; /**< cell tac*/ |
| char lac[128]; /**< cell lac*/ |
| int sid; /**< cell sid cdma*/ |
| int nid; /**< cell nid cdma*/ |
| } GSW_NW_SERVING_INFO; |
| |
| |
| typedef struct |
| { |
| char long_eons[128]; /* Full name of the operator*/ |
| char short_eons[128]; /* Shor name of the operator*/ |
| char mcc[4]; /* Mobile country code*/ |
| char mnc[4]; /* Mobile network code*/ |
| }gsw_mobile_operator_name; |
| |
| #define MAX_CELL_EXT_INFO (5) |
| |
| typedef struct |
| { |
| unsigned char cell_id_valid; |
| unsigned char pci_valid; |
| unsigned char psc_valid; |
| unsigned char band_valid; |
| unsigned char arfcn_valid; |
| unsigned char rssi_valid; |
| unsigned char rsrp_valid; |
| unsigned char rsrq_valid; |
| unsigned char sinr_valid; |
| unsigned char rscp_valid; |
| unsigned char ecio_valid; |
| GSW_NW_RADIO_ACCESS_TECH_E rat; |
| unsigned int cell_id; |
| int pci; |
| int psc; |
| int band; |
| int arfcn; |
| int rssi; |
| int rsrp; |
| int rsrq; |
| int sinr; |
| int rscp; |
| int ecio; |
| char mcc[5]; |
| char mnc[5]; |
| } GSW_NW_CELL_EXT_INFO; |
| |
| typedef struct |
| { |
| GSW_NW_RADIO_ACCESS_TECH_E rat; /**< current radio state*/ |
| |
| unsigned char mcc_valid; |
| char mcc[5]; |
| |
| unsigned char mnc_valid; |
| char mnc[5]; |
| |
| unsigned char cell_id_valid; |
| unsigned int cell_id; /**< cell id*/ |
| |
| unsigned char pci_valid; |
| int pci; /**<physical cell id*/ |
| |
| unsigned char psc_valid; |
| int psc; /*wcdma primary scramble code*/ |
| |
| unsigned char nrarfcn_valid; |
| int nrarfcn; /*nr cell freq*/ |
| |
| unsigned char earfcn_valid; |
| int earfcn; /*lte cell freq*/ |
| |
| unsigned char uarfcn_valid; |
| int uarfcn; /*wcdma cell freq*/ |
| |
| unsigned char arfcn_valid; |
| int arfcn; /*gsw cell freq*/ |
| |
| unsigned char tac_valid; |
| unsigned int tac; /**< cell tac*/ |
| |
| unsigned char lac_valid; |
| unsigned int lac; /**< cell lac*/ |
| |
| unsigned char sid_valid; |
| int sid; /**< cell sid cdma*/ |
| |
| unsigned char nid_valid; |
| int nid; /**< cell nid cdma*/ |
| |
| unsigned char lteMode_valid; |
| int lteMode; /*tdd 0, fdd 1*/ |
| |
| unsigned char rssi_valid; |
| int rssi; /**< Valid values are (0-31, 99) as defined in TS 27.007 8.5 */ |
| |
| unsigned char rscp_valid; |
| int rscp; /**< The Received Signal Code Power in dBm multipled by -1. |
| * Range : 25 to 120 |
| * INT_MAX: 0x7FFFFFFF denotes invalid value. |
| * Reference: 3GPP TS 25.123, section 9.1.1.1 */ |
| |
| unsigned char ecio_valid; |
| int ecio; /**< Valid values are positive integers. This value is the actual Ec/Io multiplied |
| * by -10. Example: If the actual Ec/Io is -12.5 dB, then this response value |
| * will be 125.*/ |
| |
| unsigned char rsrp_valid; |
| int rsrp; /**< The current Reference Signal Receive Power in dBm multipled by -1. |
| * Range: 44 to 140 dBm |
| * INT_MAX: 0x7FFFFFFF denotes invalid value. |
| * Reference: 3GPP TS 36.133 9.1.4 */ |
| |
| unsigned char rsrq_valid; |
| int rsrq; /**< The current Reference Signal Receive Quality in dB multiplied by -1. |
| * Range: 20 to 3 dB. |
| * INT_MAX: 0x7FFFFFFF denotes invalid value. |
| * Reference: 3GPP TS 36.133 9.1.7 */ |
| |
| unsigned char rssnr_valid; |
| int rssnr; /**< The current reference signal signal-to-noise ratio in 0.1 dB units. |
| * Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB). |
| * INT_MAX : 0x7FFFFFFF denotes invalid value. |
| * Reference: 3GPP TS 36.101 8.1.1 */ |
| |
| unsigned char band_valid; |
| int band; |
| |
| unsigned char bler_valid; |
| int bler; /*bit error rate*/ |
| |
| GSW_NW_CELL_EXT_INFO ext_info[MAX_CELL_EXT_INFO]; /* Used to hold neighborhood information for service cells. */ |
| } GSW_NW_CELL_INFO; |
| |
| typedef struct { |
| char mcc[GSW_MCC_MAX_LEN]; |
| char mnc[GSW_MNC_MAX_LEN]; |
| } gsw_nw_plmn_t; |
| |
| |
| typedef struct { |
| int plmn_list_len; |
| gsw_nw_plmn_t plmn_list[GSW_PLMN_LIST_MAX_LEN]; |
| } gsw_nw_plmn_list_t; |
| |
| typedef struct |
| { |
| /* Configuration parameters for MCM network full band network scan when OOS (out of service)*/ |
| int t_min; |
| int t_step; |
| int t_max; |
| }GSW_NW_OOS_CONFIG_INFO_T; |
| |
| typedef void (* GSW_NW_ServingInfoHandlePtr)(GSW_NW_SERVING_INFO serving_info); |
| typedef void (* GSW_NW_SigInfoHandlePtr)(signalStrength_t sig_info); |
| typedef void (* GSW_NW_RejectCauseHandlePtr)(GSW_NW_REJ_CAUSE_E *rej_cause); |
| typedef void (* GSW_HAL_NW_AIRPLANE_MODE_HANDLE_PTR)(int32_t airplane_mode); |
| typedef void (* GSW_NW_ModemStateHandlePtr)(gsw_mode_state_e state); |
| |
| int (*gsw_reg_serving_info_callback)(GSW_NW_ServingInfoHandlePtr handle_ptr); |
| int (*gsw_reg_sig_info_callback)(GSW_NW_SigInfoHandlePtr handle_ptr); |
| int (*gsw_reg_rej_cause_callback)(GSW_NW_RejectCauseHandlePtr handle_ptr); |
| int (*gsw_nw_sdk_init)(int token); |
| int (*gsw_nw_sdk_deinit)(void); |
| int (*gsw_get_nwinfo)(GSW_NW_SERVING_INFO *serving_info); |
| int (*gsw_get_netype)(int32_t *netype); |
| int (*gsw_get_opmode)(int *op_mode); |
| int (*gsw_set_opmode)(int32_t op_mode); |
| int (*gsw_get_mode_preference)(int32_t *mode_pref); |
| int (*gsw_set_mode_preference)(int32_t mode_pref); |
| int (*gsw_get_sig_info)(int32_t *csq_value); |
| int (*gsw_network_set_power_mode)(int8_t mode); |
| int (*gsw_sigInfo_to_csq)(int32_t netType, int32_t sigValue); |
| int (*gsw_get_forbidden_networks)(gsw_nw_plmn_list_t *plmn_list); |
| int (*gsw_add_forbidden_networks)(gsw_nw_plmn_list_t *plmn_list); |
| int (*gsw_remove_forbidden_networks)(gsw_nw_plmn_list_t *plmn_list); |
| int (*gsw_clear_forbidden_networks)(void); |
| int (*gsw_get_mobile_operator_name)(gsw_mobile_operator_name *nw_operator_name_infos); |
| int (*gsw_reg_set_modem_status_event_callback)(GSW_NW_ModemStateHandlePtr handle_ptr); |
| int (*gsw_get_cell_info)(GSW_NW_CELL_INFO *cell_info); |
| int (*gsw_oos_config_get)(GSW_NW_OOS_CONFIG_INFO_T *pt_info); |
| int (*gsw_oos_config_set)(GSW_NW_OOS_CONFIG_INFO_T *pt_info); |
| |
| |
| static int gsw_nw_api_import() |
| { |
| dlHandle_nw = dlopen(lib_gsw_nw_path, RTLD_NOW); |
| if (dlHandle_nw == NULL) { |
| printf("error: %s\n", dlerror()); |
| return -1; |
| } |
| |
| gsw_nw_sdk_init = (int(*)(int token))dlsym(dlHandle_nw, "gsw_nw_sdk_init"); |
| if (gsw_nw_sdk_init == NULL) { |
| printf("gsw_nw_sdk_init dlysm failed \n"); |
| return -1; |
| } |
| |
| gsw_nw_sdk_deinit = (int(*)(void))dlsym(dlHandle_nw, "gsw_nw_sdk_deinit"); |
| if (gsw_nw_sdk_deinit == NULL) { |
| printf("gsw_nw_sdk_deinit dlysm failed \n"); |
| return -1; |
| } |
| |
| gsw_get_nwinfo = (int(*)(GSW_NW_SERVING_INFO *serving_info))dlsym(dlHandle_nw, "gsw_get_nwinfo"); |
| if (gsw_get_nwinfo == NULL) { |
| printf("gsw_get_nwinfo dlysm failed \n"); |
| return -1; |
| } |
| |
| gsw_get_netype = (int(*)(int32_t *netype))dlsym(dlHandle_nw, "gsw_get_netype"); |
| if (gsw_get_netype == NULL) { |
| printf("gsw_get_netype dlysm failed \n"); |
| return -1; |
| } |
| |
| gsw_get_opmode = (int(*)(int *op_mode))dlsym(dlHandle_nw, "gsw_get_opmode"); |
| if (gsw_get_opmode == NULL) { |
| printf("gsw_get_opmode dlysm failed \n"); |
| return -1; |
| } |
| |
| gsw_set_opmode = (int(*)(int32_t op_mode))dlsym(dlHandle_nw, "gsw_set_opmode"); |
| if (gsw_set_opmode == NULL) { |
| printf("gsw_set_opmode dlysm failed \n"); |
| return -1; |
| } |
| |
| gsw_get_mode_preference = (int(*)(int32_t *mode_pref))dlsym(dlHandle_nw, "gsw_get_mode_preference"); |
| if (gsw_get_mode_preference == NULL) { |
| printf("gsw_get_mode_preference dlysm failed \n"); |
| return -1; |
| } |
| |
| gsw_set_mode_preference = (int(*)(int32_t mode_pref))dlsym(dlHandle_nw, "gsw_set_mode_preference"); |
| if (gsw_set_mode_preference == NULL) { |
| printf("gsw_set_mode_preference dlysm failed \n"); |
| return -1; |
| } |
| |
| gsw_get_sig_info = (int(*)(int32_t *csq_value))dlsym(dlHandle_nw, "gsw_get_sig_info"); |
| if (gsw_get_sig_info == NULL) { |
| printf("gsw_get_sig_info dlysm failed \n"); |
| return -1; |
| } |
| |
| gsw_network_set_power_mode = (int(*)(int8_t mode))dlsym(dlHandle_nw, "gsw_network_set_power_mode"); |
| if (gsw_network_set_power_mode == NULL) { |
| printf("gsw_network_set_power_mode dlysm failed \n"); |
| return -1; |
| } |
| |
| gsw_sigInfo_to_csq = (int(*)(int32_t netType, int32_t sigValue))dlsym(dlHandle_nw, "gsw_sigInfo_to_csq"); |
| if (gsw_sigInfo_to_csq == NULL) { |
| printf("gsw_sigInfo_to_csq dlysm failed \n"); |
| return -1; |
| } |
| |
| gsw_get_forbidden_networks = (int(*)(gsw_nw_plmn_list_t *plmn_list))dlsym(dlHandle_nw, "gsw_get_forbidden_networks"); |
| if (gsw_get_forbidden_networks == NULL) { |
| printf("gsw_get_forbidden_networks dlysm failed \n"); |
| return -1; |
| } |
| |
| gsw_add_forbidden_networks = (int(*)(gsw_nw_plmn_list_t *plmn_list))dlsym(dlHandle_nw, "gsw_add_forbidden_networks"); |
| if (gsw_add_forbidden_networks == NULL) { |
| printf("gsw_add_forbidden_networks dlysm failed \n"); |
| return -1; |
| } |
| |
| gsw_remove_forbidden_networks = (int(*)(gsw_nw_plmn_list_t *plmn_list))dlsym(dlHandle_nw, "gsw_remove_forbidden_networks"); |
| if (gsw_remove_forbidden_networks == NULL) { |
| printf("gsw_remove_forbidden_networks dlysm failed \n"); |
| return -1; |
| } |
| |
| gsw_clear_forbidden_networks = (int(*)(void))dlsym(dlHandle_nw, "gsw_clear_forbidden_networks"); |
| if (gsw_clear_forbidden_networks == NULL) { |
| printf("gsw_clear_forbidden_networks dlysm failed \n"); |
| return -1; |
| } |
| |
| gsw_get_mobile_operator_name = (int(*)(gsw_mobile_operator_name *nw_operator_name_infos))dlsym(dlHandle_nw, "gsw_get_mobile_operator_name"); |
| if (gsw_get_mobile_operator_name == NULL) { |
| printf("gsw_get_mobile_operator_name dlysm failed \n"); |
| return -1; |
| } |
| |
| gsw_reg_set_modem_status_event_callback = (int(*)(GSW_NW_ModemStateHandlePtr handle_ptr))dlsym(dlHandle_nw, "gsw_reg_set_modem_status_event_callback"); |
| if (gsw_reg_set_modem_status_event_callback == NULL) { |
| printf("gsw_reg_set_modem_status_event_callback dlysm failed \n"); |
| return -1; |
| } |
| |
| gsw_get_cell_info = (int(*)(GSW_NW_CELL_INFO *cell_info))dlsym(dlHandle_nw, "gsw_get_cell_info"); |
| if (gsw_get_cell_info == NULL) { |
| printf("gsw_get_cell_info dlysm failed \n"); |
| return -1; |
| } |
| |
| gsw_reg_serving_info_callback = (int(*)(GSW_NW_ServingInfoHandlePtr handle_ptr))dlsym(dlHandle_nw, "gsw_reg_serving_info_callback"); |
| if (gsw_reg_serving_info_callback == NULL) { |
| printf("gsw_reg_serving_info_callback dlysm failed \n"); |
| return -1; |
| } |
| |
| gsw_reg_sig_info_callback = (int(*)(GSW_NW_SigInfoHandlePtr handle_ptr))dlsym(dlHandle_nw, "gsw_reg_sig_info_callback"); |
| if (gsw_reg_sig_info_callback == NULL) { |
| printf("gsw_reg_sig_info_callback dlysm failed \n"); |
| return -1; |
| } |
| |
| gsw_reg_rej_cause_callback = (int(*)(GSW_NW_RejectCauseHandlePtr handle_ptr))dlsym(dlHandle_nw, "gsw_reg_rej_cause_callback"); |
| if (gsw_reg_rej_cause_callback == NULL) { |
| printf("gsw_reg_rej_cause_callback dlysm failed \n"); |
| return -1; |
| } |
| |
| gsw_oos_config_get = (int(*)(GSW_NW_OOS_CONFIG_INFO_T *oos_config))dlsym(dlHandle_nw, "gsw_oos_config_get"); |
| if (gsw_oos_config_get == NULL) { |
| printf("gsw_oos_config_get dlysm failed \n"); |
| return -1; |
| } |
| |
| gsw_oos_config_set = (int(*)(GSW_NW_OOS_CONFIG_INFO_T *oos_config))dlsym(dlHandle_nw, "gsw_oos_config_set"); |
| if (gsw_oos_config_set == NULL) { |
| printf("gsw_oos_config_set dlysm failed \n"); |
| return -1; |
| } |
| |
| return 0; |
| |
| } |
| |
| static void gsw_serving_info_callback(GSW_NW_SERVING_INFO serving_info) |
| { |
| printf("gsw_serving_info_callback: \n"); |
| printf("reg_state = %d\n", serving_info.reg_state); |
| printf("ps_state = %d\n", serving_info.ps_state); |
| printf("reg_rat = %d\n", serving_info.reg_rat); |
| printf("srv_domain = %d\n", serving_info.srv_domain); |
| printf("roaming_ind = %d\n", serving_info.roaming_ind); |
| printf("reg_plmn = %s\n", serving_info.reg_plmn); |
| printf("operator_name = %s\n", serving_info.operator_name); |
| printf("cell_id = %s\n", serving_info.cell_id); |
| printf("tac = %s\n", serving_info.tac); |
| printf("lac = %s\n", serving_info.lac); |
| printf("sid = %d\n", serving_info.sid); |
| printf("nid = %d\n", serving_info.nid); |
| } |
| |
| static void gsw_sig_info_callback(signalStrength_t sig_info) |
| { |
| printf("gsw_sig_info_callback: \n"); |
| printf("gw_sig_valid = %d\n", sig_info.gw_sig_valid); |
| printf("rssi = %d\n", sig_info.rssi); |
| printf("wcdma_sig_valid = %d\n", sig_info.wcdma_sig_valid); |
| printf("rscp = %d\n", sig_info.rscp); |
| printf("ecno = %d\n", sig_info.ecno); |
| printf("lte_sig_valid = %d\n", sig_info.lte_sig_valid); |
| printf("rsrp = %d\n", sig_info.rsrp); |
| printf("rsrq = %d\n", sig_info.rsrq); |
| printf("rssnr = %d\n", sig_info.rssnr); |
| printf("nr_sig_valid = %d\n", sig_info.nr_sig_valid); |
| printf("ssRsrp = %d\n", sig_info.ssRsrp); |
| printf("ssRsrq = %d\n", sig_info.ssRsrq); |
| printf("ssSinr = %d\n", sig_info.ssSinr); |
| printf("csiRsrp = %d\n", sig_info.csiRsrp); |
| printf("csiRsrq = %d\n", sig_info.csiRsrq); |
| printf("csiSinr = %d\n", sig_info.csiSinr); |
| } |
| |
| static void gsw_rej_cause_callback(GSW_NW_REJ_CAUSE_E *rej_cause) |
| { |
| printf("gsw_rej_cause_callback: \n"); |
| printf("rej_rat = %d\n", rej_cause->rej_rat); |
| printf("rej_domain = %d\n", rej_cause->rej_domain); |
| printf("rej_cause = %d\n", rej_cause->rej_cause); |
| } |
| |
| static void gsw_modem_status_cb(gsw_mode_state_e state) |
| { |
| printf("gsw_modem_status_cb: \n"); |
| printf("state = %d\n", state); |
| } |
| |
| |
| void dump_items() |
| { |
| printf("\n"); |
| printf("The current module is: network \n"); |
| |
| printf("-------------------------------------------------------------------------\n"); |
| printf("| index | function name |\n"); |
| printf("| -1 exit\n"); |
| printf(" 1 gsw_nw_sdk_init\n"); |
| printf(" 2 gsw_nw_sdk_deinit\n"); |
| printf(" 3 gsw_get_nwinfo\n"); |
| printf(" 4 gsw_get_netype\n"); |
| printf(" 5 gsw_get_opmode\n"); |
| printf(" 6 gsw_set_opmode\n"); |
| printf(" 7 gsw_get_mode_preference\n"); |
| printf(" 8 gsw_set_mode_preference\n"); |
| printf(" 9 gsw_get_sig_info\n"); |
| printf(" 10 gsw_network_set_power_mode\n"); |
| printf(" 11 gsw_sigInfo_to_csq\n"); |
| printf(" 12 gsw_get_forbidden_networks\n"); |
| printf(" 13 gsw_add_forbidden_networks\n"); |
| printf(" 14 gsw_remove_forbidden_networks\n"); |
| printf(" 15 gsw_clear_forbidden_networks\n"); |
| printf(" 16 gsw_get_mobile_operator_name\n"); |
| printf(" 17 gsw_reg_set_modem_status_event_callback\n"); |
| printf(" 18 gsw_get_cell_info\n"); |
| printf(" 19 gsw_reg_serving_info_callback\n"); |
| printf(" 20 gsw_reg_sig_info_callback\n"); |
| printf(" 21 gsw_reg_rej_cause_callback\n"); |
| printf(" 22 gsw_oos_config_get\n"); |
| printf(" 23 gsw_oos_config_set\n"); |
| printf("-------------------------------------------------------------------------\n"); |
| } |
| |
| int main(int argc, char *argv[]) |
| { |
| int ret; |
| char operator[10]; |
| int opt; |
| |
| ret = gsw_nw_api_import(); |
| if (ret != 0) { |
| printf("gsw_nw_api_import failed \n"); |
| return -1; |
| } |
| |
| |
| while(1) |
| { |
| dump_items(); |
| printf("input the index of module: "); |
| |
| opt = -1; |
| printf("%s",fgets(operator, sizeof(operator), stdin)); |
| fflush(stdin); |
| |
| opt = atoi(operator); |
| switch (opt) { |
| case -1: |
| { |
| printf("main exit\n"); |
| return 0; |
| } |
| case 1: |
| { |
| printf("gsw_nw_sdk_init\n"); |
| ret = gsw_nw_sdk_init(1024); |
| printf("gsw_nw_sdk_init ret = %d\n",ret); |
| break; |
| } |
| case 2: |
| { |
| printf("gsw_nw_sdk_deinit\n"); |
| ret = gsw_nw_sdk_deinit(); |
| printf("gsw_nw_sdk_deinit ret = %d\n",ret); |
| break; |
| } |
| case 3: |
| { |
| GSW_NW_SERVING_INFO* nwinfo; |
| nwinfo = (GSW_NW_SERVING_INFO*)malloc(sizeof(GSW_NW_SERVING_INFO)); |
| memset(nwinfo, 0x00, sizeof(GSW_NW_SERVING_INFO)); |
| printf("gsw_get_nwinfo start\n"); |
| ret = gsw_get_nwinfo(nwinfo); |
| if(ret != 0) |
| { |
| printf("gsw_get_nwinfo failed \n"); |
| continue; |
| } |
| printf("nwinfo.reg_state = %d\nnwinfo.ps_state = %d\nnwinfo.reg_rat = %d\nnwinfo.srv_domain = %d\nnwinfo.roaming_ind = %d\nnwinfo.reg_plmn = %s\nnwinfo.operator_name = %s\nnwinfo.cell_id = %s\nnwinfo.lac = %s\nnwinfo.sid=%d\nnwinfo.nid = %d\n",nwinfo->reg_state, nwinfo->ps_state, nwinfo->reg_rat, nwinfo->srv_domain, nwinfo->roaming_ind, nwinfo->reg_plmn, nwinfo->operator_name, nwinfo->cell_id, nwinfo->lac, nwinfo->sid, nwinfo->nid); |
| free(nwinfo); |
| break; |
| } |
| case 4: |
| { |
| int nettype; |
| ret = gsw_get_netype(&nettype); |
| if(ret != 0) |
| { |
| printf("gsw_get_netype failed \n"); |
| continue; |
| } |
| printf("nettype = %d\n", nettype); |
| break; |
| } |
| |
| case 5: |
| { |
| int opmode; |
| ret = gsw_get_opmode(&opmode); |
| if(ret != 0) |
| { |
| printf("gsw_get_opmode failed \n"); |
| continue; |
| } |
| printf("opmode = %d\n", opmode); |
| break; |
| } |
| |
| case 6: |
| { |
| printf("input the opmode: "); |
| memset(operator,0x00, sizeof(operator)); |
| printf("%s\n",fgets(operator, sizeof(operator)-1, stdin)); |
| fflush(stdin); |
| opt = atoi(operator); |
| ret = gsw_set_opmode(opt); |
| if(ret != 0) |
| { |
| printf("gsw_set_opmode failed \n"); |
| continue; |
| } |
| break; |
| } |
| |
| case 7: |
| { |
| int mode_pref; |
| ret = gsw_get_mode_preference(&mode_pref); |
| if(ret != 0) |
| { |
| printf("gsw_get_mode_preference failed \n"); |
| continue; |
| } |
| printf("mode_pref = %d\n", mode_pref); |
| break; |
| } |
| |
| case 8: |
| { |
| printf("input the mode_pref: "); |
| memset(operator,0x00, sizeof(operator)); |
| printf("%s\n",fgets(operator, sizeof(operator)-1, stdin)); |
| fflush(stdin); |
| opt = atoi(operator); |
| ret = gsw_set_mode_preference(opt); |
| if(ret != 0) |
| { |
| printf("gsw_set_mode_preference failed \n"); |
| continue; |
| } |
| break; |
| } |
| |
| case 9: |
| { |
| int siginfo; |
| ret = gsw_get_sig_info(&siginfo); |
| if(ret != 0) |
| { |
| printf("gsw_get_sig_info failed \n"); |
| continue; |
| } |
| printf("signal info: siginfo = %d\n", siginfo); |
| break; |
| } |
| |
| case 10: |
| { |
| printf("input the power mode: "); |
| memset(operator,0x00, sizeof(operator)); |
| printf("%s\n",fgets(operator, sizeof(operator)-1, stdin)); |
| fflush(stdin); |
| opt = atoi(operator); |
| ret = gsw_network_set_power_mode(opt); |
| if(ret != 0) |
| { |
| printf("gsw_network_set_power_mode failed \n"); |
| continue; |
| } |
| break; |
| } |
| |
| case 11: |
| { |
| int nettype; |
| int sigValue; |
| printf("please input the netType:"); |
| memset(operator,0x00, sizeof(operator)); |
| printf("%s\n",fgets(operator, sizeof(operator)-1, stdin)); |
| fflush(stdin); |
| nettype = atoi(operator); |
| |
| printf("input the sigValue: "); |
| memset(operator,0x00, sizeof(operator)); |
| printf("%s\n",fgets(operator, sizeof(operator)-1, stdin)); |
| fflush(stdin); |
| sigValue = atoi(operator); |
| |
| ret = gsw_sigInfo_to_csq(nettype, sigValue); |
| printf("csq = %d\n", ret); |
| |
| break; |
| } |
| |
| case 12: |
| { |
| printf("gsw_get_forbidden_networks start\n"); |
| gsw_nw_plmn_list_t fplmn_list; |
| fplmn_list.plmn_list_len = 0; |
| ret = gsw_get_forbidden_networks(&fplmn_list); |
| if(ret != 0) |
| { |
| printf("gsw_get_forbidden_networks failed \n"); |
| continue; |
| } |
| |
| printf("gsw_get_forbidden_networks end\n"); |
| for(int i = 0; i < fplmn_list.plmn_list_len; i++) |
| { |
| printf("list[%d] mcc = %s,mnc = %s\n",i, fplmn_list.plmn_list[i].mcc, fplmn_list.plmn_list[i].mnc); |
| } |
| |
| break; |
| } |
| case 13: |
| { |
| printf("gsw_add_forbidden_networks start\n"); |
| gsw_nw_plmn_list_t fplmn_list_set; |
| fplmn_list_set.plmn_list_len = 1; |
| strcpy(fplmn_list_set.plmn_list[0].mcc, "460"); |
| strcpy(fplmn_list_set.plmn_list[0].mnc, "09"); |
| |
| ret = gsw_add_forbidden_networks(&fplmn_list_set); |
| if(ret != 0) |
| { |
| printf("gsw_add_forbidden_networks failed \n"); |
| continue; |
| } |
| printf("gsw_add_forbidden_networks end\n"); |
| break; |
| } |
| case 14: |
| { |
| printf("gsw_add_forbidden_networks start\n"); |
| gsw_nw_plmn_list_t fplmn_list_remove; |
| fplmn_list_remove.plmn_list_len = 1; |
| strcpy(fplmn_list_remove.plmn_list[0].mcc, "460"); |
| strcpy(fplmn_list_remove.plmn_list[0].mnc, "02"); |
| |
| ret = gsw_remove_forbidden_networks(&fplmn_list_remove); |
| if(ret != 0) |
| { |
| printf("gsw_add_forbidden_networks failed \n"); |
| continue; |
| } |
| printf("gsw_add_forbidden_networks end\n"); |
| break; |
| } |
| |
| case 15: |
| { |
| printf("gsw_clear_forbidden_networks start\n"); |
| ret = gsw_clear_forbidden_networks(); |
| if(ret != 0) |
| { |
| printf("gsw_clear_forbidden_networks failed \n"); |
| continue; |
| } |
| printf("gsw_clear_forbidden_networks end\n"); |
| break; |
| } |
| |
| case 16: |
| { |
| gsw_mobile_operator_name opname; |
| |
| ret = gsw_get_mobile_operator_name(&opname); |
| if(ret != 0) |
| { |
| printf("gsw_get_mobile_operator_name failed \n"); |
| continue; |
| } |
| |
| printf("opname.operator_name = %s\nopname.operator_code = %s\nopname.mcc=%s\nopname.mnc=%s", opname.long_eons, opname.short_eons, opname.mcc, opname.mnc); |
| break; |
| } |
| |
| case 17: |
| { |
| printf("gsw_reg_set_modem_status_event_callback\n"); |
| ret = gsw_reg_set_modem_status_event_callback(gsw_modem_status_cb); |
| if(ret != 0) |
| { |
| printf("gsw_reg_set_modem_status_event_callback failed \n"); |
| continue; |
| } |
| printf("gsw_reg_set_modem_status_event_callback success\n"); |
| break; |
| } |
| |
| case 18: |
| { |
| printf("gsw_get_cell_info starts\n"); |
| GSW_NW_CELL_INFO cell_info; |
| memset(&cell_info, 0x00, sizeof(GSW_NW_CELL_INFO)); |
| ret = gsw_get_cell_info(&cell_info); |
| if(ret != 0) |
| { |
| printf("gsw_get_cell_info failed \n"); |
| continue; |
| } |
| |
| printf("--------------------serving cell info ------------------------------\n"); |
| printf("mcc_valid = %d\n",cell_info.mcc_valid); |
| printf("mcc = %s\n",cell_info.mcc); |
| printf("mnc_valid = %d\n",cell_info.mnc_valid); |
| printf("mnc = %s\n",cell_info.mnc); |
| printf("cell_id_valid = %d\n",cell_info.cell_id_valid); |
| printf("cell_id = %u\n",cell_info.cell_id); |
| printf("pci_valid = %d\n",cell_info.pci_valid); |
| printf("pci = %d\n",cell_info.pci); |
| printf("psc_valid = %d\n",cell_info.psc_valid); |
| printf("psc = %d\n",cell_info.psc); |
| printf("earfcn_valid = %d\n",cell_info.earfcn_valid); |
| printf("earfcn = %d\n",cell_info.earfcn); |
| printf("uarfcn_valid = %d\n",cell_info.uarfcn_valid); |
| printf("uarfcn = %d\n",cell_info.uarfcn); |
| printf("arfcn_valid = %d\n",cell_info.arfcn_valid); |
| printf("arfcn = %d\n",cell_info.arfcn); |
| printf("tac_valid = %d\n",cell_info.tac_valid); |
| printf("tac = %u\n",cell_info.tac); |
| printf("lac_valid = %d\n",cell_info.lac_valid); |
| printf("lac = %u\n",cell_info.lac); |
| printf("sid_valid = %d\n",cell_info.sid_valid); |
| printf("sid = %d\n",cell_info.sid); |
| printf("nid_valid = %d\n",cell_info.nid_valid); |
| printf("nid = %d\n",cell_info.nid); |
| printf("lteMode_valid = %d\n",cell_info.lteMode_valid); |
| printf("lteMode = %d\n",cell_info.lteMode); |
| printf("rssi_valid = %d\n",cell_info.rssi_valid); |
| printf("rssi = %d\n",cell_info.rssi); |
| printf("rsrq_valid = %d\n",cell_info.rsrq_valid); |
| printf("rsrq = %d\n",cell_info.rsrq); |
| printf("ecio_valid = %d\n",cell_info.ecio_valid); |
| printf("ecio = %d\n",cell_info.ecio); |
| printf("rsrp_valid = %d\n",cell_info.rsrp_valid); |
| printf("rsrp = %d\n",cell_info.rsrp); |
| printf("rsrq_valid = %d\n",cell_info.rsrq_valid); |
| printf("rsrq = %d\n",cell_info.rsrq); |
| printf("rssnr_valid = %d\n",cell_info.rssnr_valid); |
| printf("rssnr = %d\n",cell_info.rssnr); |
| printf("band_valid = %d\n",cell_info.band_valid); |
| printf("band = %d\n",cell_info.band); |
| printf("bler_valid = %d\n",cell_info.bler_valid); |
| printf("bler = %d\n",cell_info.bler); |
| |
| |
| printf("-----------------------------------------------------------------------------------\n"); |
| |
| printf("-------------------------------------inter cell info ------------------------------\n"); |
| |
| for(int i = 0; i <MAX_CELL_EXT_INFO ; i++) |
| { |
| printf("-----------------------------------------------------------\n"); |
| printf("inter cell info[%d] rat = %d\n",i,cell_info.ext_info[i].rat); |
| |
| printf("inter cell info[%d] mcc = %s\n",i,cell_info.ext_info[i].mcc); |
| |
| printf("inter cell info[%d] mnc = %s\n",i,cell_info.ext_info[i].mnc); |
| |
| printf("inter cell info[%d] pci_valid = %d\n",i,cell_info.ext_info[i].pci_valid); |
| printf("inter cell info[%d] pci = %d\n",i,cell_info.ext_info[i].pci); |
| |
| printf("inter cell info[%d] arfcn_valid = %d\n",i,cell_info.ext_info[i].arfcn_valid); |
| printf("inter cell info[%d] arfcn = %d\n",i,cell_info.ext_info[i].arfcn); |
| |
| printf("inter cell info[%d] rsrp_valid = %d\n",i,cell_info.ext_info[i].rsrp_valid); |
| printf("inter cell info[%d] rsrp = %d\n",i,cell_info.ext_info[i].rsrp); |
| |
| printf("inter cell info[%d] rsrq_valid = %d\n",i,cell_info.ext_info[i].rsrq_valid); |
| printf("inter cell info[%d] rsrq = %d\n",i,cell_info.ext_info[i].rsrq); |
| |
| printf("inter cell info[%d] cell_id_valid = %d\n",i,cell_info.ext_info[i].cell_id_valid); |
| printf("inter cell info[%d] cell_id = %u\n",i,cell_info.ext_info[i].cell_id); |
| |
| printf("inter cell info[%d] band_valid = %d\n",i,cell_info.ext_info[i].band_valid); |
| printf("inter cell info[%d] band = %u\n",i,cell_info.ext_info[i].band); |
| |
| printf("-----------------------------------------------------------\n"); |
| } |
| |
| |
| break; |
| } |
| |
| case 19: |
| { |
| printf("gsw_reg_serving_info_callback start\n"); |
| ret = gsw_reg_serving_info_callback(gsw_serving_info_callback); |
| break; |
| } |
| |
| case 20: |
| { |
| printf("gsw_reg_sig_info_callback start\n"); |
| ret = gsw_reg_sig_info_callback(gsw_sig_info_callback); |
| break; |
| } |
| |
| case 21: |
| { |
| printf("gsw_reg_rej_cause_callback\n"); |
| ret = gsw_reg_rej_cause_callback(gsw_rej_cause_callback); |
| break; |
| } |
| |
| case 22: |
| { |
| printf("gsw_oos_config_get\n"); |
| GSW_NW_OOS_CONFIG_INFO_T oos_cfg; |
| ret = gsw_oos_config_get(&oos_cfg); |
| if(ret != 0) |
| { |
| printf("gsw_oos_config_get failed \n"); |
| continue; |
| } |
| |
| else |
| { |
| printf("oos_cfg.t_min = %d\n",oos_cfg.t_min); |
| printf("oos_cfg.t_max = %d\n",oos_cfg.t_max); |
| printf("oos_cfg.t_step = %d\n",oos_cfg.t_step); |
| } |
| break; |
| } |
| |
| case 23: |
| { |
| printf("gsw_oos_config_set\n"); |
| GSW_NW_OOS_CONFIG_INFO_T oos_cfg; |
| oos_cfg.t_min = 5; |
| oos_cfg.t_step = 5; |
| oos_cfg.t_max = 5; |
| |
| ret = gsw_oos_config_set(&oos_cfg); |
| if(ret != 0) |
| { |
| printf("gsw_oos_config_set failed \n"); |
| continue; |
| } |
| else |
| { |
| printf("gsw_oos_config_set success\n"); |
| } |
| break; |
| } |
| |
| |
| default: |
| { |
| continue; |
| } |
| |
| |
| } |
| } |
| |
| |
| } |