hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 1 | #include <stdbool.h>
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2 | #include <dlfcn.h>
|
| 3 | #include <time.h>
|
| 4 | #include <pthread.h>
|
hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 5 | #include "gsw_nw_interface.h"
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 6 | #include "gsw_log_interface.h"
|
| 7 |
|
cz.li | f4a9a93 | 2025-06-05 11:37:59 +0800 | [diff] [blame] | 8 | #define SIG_TIMER 5
|
q.huang | 66b7916 | 2025-06-27 17:45:34 +0800 | [diff] [blame] | 9 | #define MODEM_TIMER 5
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 10 | #define SERVING_TIMER 5
|
| 11 |
|
q.huang | 66b7916 | 2025-06-27 17:45:34 +0800 | [diff] [blame] | 12 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 13 | //mbtk include
|
| 14 | #define LYNQ_AIR_PLANE_MODE_OFF 1 //at+cfun = 1
|
| 15 | #define LYNQ_AIR_PLANE_MODE_ON 4 // at+cfun = 4
|
| 16 | #define LYNQ_AIR_CFUN_MODE_OFF 0 // at+cfun = 0
|
| 17 |
|
| 18 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
| 19 |
|
| 20 | #define FPLMN_STRING_LENGTH 120
|
| 21 | #define ENTRY_LENGTH 6
|
| 22 | #define FPLMN_ARRAY_SIZE (FPLMN_STRING_LENGTH / 6) + 1
|
| 23 |
|
q.huang | 238b22a | 2025-06-10 14:36:59 +0800 | [diff] [blame] | 24 | #define MBTK_ERR_OK 0
|
xf.li | 56b78fb | 2025-06-13 03:29:21 -0700 | [diff] [blame] | 25 | #define GSW_IMEI_LENGTH 15+1
|
q.huang | 238b22a | 2025-06-10 14:36:59 +0800 | [diff] [blame] | 26 |
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 27 | #define INT_32_MAX (0x7FFFFFFF)
|
q.huang | 2dbc0bc | 2025-08-06 10:36:24 +0800 | [diff] [blame] | 28 | #define INVALID_AT_SIGNAL_LEVEL (99)
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 29 |
|
q.huang | 238b22a | 2025-06-10 14:36:59 +0800 | [diff] [blame] | 30 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 31 | #ifndef FALSE
|
| 32 | #define FALSE (0)
|
| 33 | #endif
|
| 34 |
|
| 35 |
|
| 36 | #ifndef TRUE
|
| 37 | #define TRUE (!FALSE)
|
| 38 | #endif
|
| 39 |
|
| 40 | typedef unsigned int uint32;
|
| 41 | typedef unsigned char uint8;
|
q.huang | 861c07d | 2025-06-24 16:54:58 +0800 | [diff] [blame] | 42 | typedef signed char int8;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 43 | typedef unsigned short uint16;
|
| 44 | typedef void (*mbtk_info_callback_func)(const void* data, int data_len);
|
| 45 |
|
q.huang | daa16d4 | 2025-07-03 14:32:48 +0800 | [diff] [blame] | 46 | //#define MBTK_READY_UCI "persist.mbtk.sdk.state"
|
rx.xie | aad2b6f | 2025-08-01 00:55:33 -0700 | [diff] [blame] | 47 | #define SDK_READY_CMD "uci get lynq_uci.sdk_ready"
|
q.huang | 66b7916 | 2025-06-27 17:45:34 +0800 | [diff] [blame] | 48 | #define MBTK_READY_STRING_SIZE_MAX (3+1)
|
| 49 |
|
| 50 |
|
| 51 | typedef enum{
|
| 52 | MBTK_READY_INIT = -1,
|
| 53 | MBTK_READY_SUCCESS,
|
| 54 | MBTK_READY_MODEM_FAIL,
|
| 55 | MBTK_READY_RESPONSE_FAIL,
|
| 56 | MBTK_READY_SOCKET_FAIL,
|
| 57 | MBTK_READY_RIL_FAIL
|
| 58 | }mbtk_ready_status_type;
|
| 59 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 60 | typedef enum
|
| 61 | {
|
| 62 | MBTK_DEV_MODEM_MIN_FUN, //Modem 最小功能
|
| 63 | MBTK_DEV_MODEM_FULL_FUN, //Modem 全功能
|
| 64 | MBTK_DEV_MODEM_DISABLE_RECEIVE_RF_CIRCUITS = 3, //Modem 禁用射频接收电路
|
| 65 | MBTK_DEV_MODEM_DISABLE_TRANSMIT_AND_RECEIVE_RF_CIRCUITS, //Modem禁用射频发射和接收电路
|
| 66 | MBTK_DEV_MODEM_DISABLE_SIM, //Modem 禁用(U)SIM 卡
|
| 67 | MBTK_DEV_MODEM_TURN_OFF_FULL_SECONDARY_RECEIVE, //Modem 完全禁用辅助接收
|
| 68 | }MBTK_DEV_MODEM_FUNCTION;
|
| 69 |
|
| 70 | typedef enum
|
| 71 | {
|
| 72 | MBTK_CELL_TYPE_GSM = 0,
|
| 73 | MBTK_CELL_TYPE_UMTS,
|
| 74 | MBTK_CELL_TYPE_LTE
|
| 75 | } mbtk_cell_type_enum;
|
| 76 |
|
| 77 | typedef struct
|
| 78 | {
|
| 79 | MBTK_DEV_MODEM_FUNCTION fun;
|
| 80 | int rst;
|
| 81 | } mbtk_modem_info_t;
|
| 82 |
|
| 83 | typedef struct
|
| 84 | {
|
| 85 | int client_fd;
|
| 86 | pthread_t read_thread_id;
|
| 87 | int exit_fd[2];
|
| 88 | bool is_waitting;
|
| 89 | pthread_cond_t cond;
|
| 90 | pthread_mutex_t mutex;
|
| 91 |
|
| 92 | pthread_mutex_t send_mutex;
|
| 93 |
|
| 94 | // Temp response data.
|
| 95 | uint16 info_err;
|
| 96 | uint16 data_len;
|
| 97 | void *data;
|
| 98 |
|
| 99 | //mbtk wyq for server_ready_status add start
|
| 100 | char server_ready_status;
|
| 101 | //mbtk wyq for server_ready_status add end
|
| 102 |
|
| 103 | mbtk_info_callback_func net_state_cb;
|
| 104 | mbtk_info_callback_func call_state_cb;
|
| 105 | mbtk_info_callback_func sms_state_cb;
|
| 106 | mbtk_info_callback_func radio_state_cb;
|
| 107 | mbtk_info_callback_func sim_state_cb;
|
| 108 | mbtk_info_callback_func pdp_state_cb;
|
| 109 | //add signal by xr
|
| 110 | mbtk_info_callback_func signal_state_cb;
|
| 111 | } mbtk_info_handle_t;
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 | typedef struct
|
| 116 | {
|
q.huang | 638d587 | 2025-06-21 13:44:43 +0800 | [diff] [blame] | 117 | // NR server cell:
|
| 118 | // NR cell:
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 119 | // LTE server cell: tac, PCI, dlEuarfcn, ulEuarfcn, band
|
| 120 | // LTE cell: phyCellId,euArfcn,rsrp,rsrq
|
| 121 | // WCDMA server cell: lac, ci, arfcn
|
| 122 | // WCDMA cell: lac, ci, arfcn
|
| 123 | // GSM server cell: lac, ci, arfcn, bsic
|
| 124 | // GSM cell:
|
q.huang | 638d587 | 2025-06-21 13:44:43 +0800 | [diff] [blame] | 125 | uint32 value1; //tac
|
| 126 | uint32 value2; //pci
|
| 127 | uint32 value3; //dlEuarfcn
|
| 128 | uint32 value4; //bler
|
| 129 | uint32 value5; //band
|
| 130 | uint32 value6; //mcc
|
| 131 | uint32 value7; //mnc
|
| 132 | uint32 value8; //rsrp
|
| 133 | uint32 value9; //rsrq
|
| 134 | uint32 value10; //cell identiy
|
| 135 | uint32 value11; //sinr
|
| 136 | uint32 value12; //is tdd
|
| 137 | uint32 value13;
|
| 138 | uint32 value14;
|
| 139 | uint32 value15;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 140 | } __attribute__((packed)) mbtk_cell_info_t;
|
| 141 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 142 | typedef struct
|
| 143 | {
|
| 144 | uint8 net_pref; // mbtk_net_pref_enum
|
| 145 | uint16 gsm_band; // mbtk_gsm_band_enum
|
| 146 | uint16 umts_band; // mbtk_umts_band_enum
|
| 147 | uint32 tdlte_band; // mbtk_tdlte_band_enum
|
| 148 | uint32 fddlte_band; // mbtk_fddlte_band_enum
|
| 149 | uint32 lte_ext_band; // mbtk_lte_ext_band_enum
|
| 150 | } __attribute__((packed)) mbtk_band_info_t;
|
| 151 |
|
| 152 | typedef struct list_arraynode
|
| 153 | {
|
| 154 | void *data;
|
| 155 | struct list_arraynode *next;
|
| 156 | } list_arraynode_t;
|
| 157 |
|
| 158 | typedef struct list_treenode
|
| 159 | {
|
| 160 | list_arraynode_t *data;
|
| 161 | int count;
|
| 162 | struct list_treenode *left;
|
| 163 | struct list_treenode *right;
|
| 164 | } list_treenode_t;
|
| 165 |
|
| 166 | typedef int (*list_sort_func)(void *data1, void *data2);
|
| 167 | typedef void (*list_free_func)(void *data);
|
| 168 |
|
| 169 | typedef struct list_node
|
| 170 | {
|
| 171 | uint32 size;
|
| 172 | list_sort_func sort_func;
|
| 173 | list_free_func free_func;
|
| 174 |
|
| 175 | uint32 cur_index;
|
| 176 | list_arraynode_t *cur_array_data;
|
| 177 |
|
| 178 | list_arraynode_t array_data;
|
| 179 | list_treenode_t tree_data;
|
| 180 | } list_node_t;
|
| 181 |
|
| 182 | /*
|
| 183 | 0: GSM
|
| 184 | 1: GSM Compact
|
| 185 | 2: UTRAN
|
| 186 | 3: GSM w/EGPRS
|
| 187 | 4: UTRAN w/HSDPA
|
| 188 | 5: UTRAN w/HSUPA
|
| 189 | 6: UTRAN w/HSDPA and HSUPA
|
| 190 | 7: E-UTRAN
|
| 191 | 8: UTRAN HSPA+
|
| 192 | */
|
| 193 | typedef enum {
|
| 194 | MBTK_RADIO_TECH_GSM = 0,
|
| 195 | MBTK_RADIO_TECH_GSM_COMPACT,
|
| 196 | MBTK_RADIO_TECH_UTRAN,
|
| 197 | MBTK_RADIO_TECH_GSM_EGPRS,
|
| 198 | MBTK_RADIO_TECH_UTRAN_HSDPA,
|
| 199 | MBTK_RADIO_TECH_UTRAN_HSUPA,
|
| 200 | MBTK_RADIO_TECH_UTRAN_HSDPA_HSUPA,
|
| 201 | MBTK_RADIO_TECH_E_UTRAN, // LTE
|
| 202 | MBTK_RADIO_TECH_UTRAN_HSPA
|
| 203 | } mbtk_radio_technology_enum;
|
| 204 |
|
| 205 | typedef struct
|
| 206 | {
|
| 207 | /*
|
| 208 | 0: automatic
|
| 209 | 1: manual
|
| 210 | */
|
| 211 | uint8 net_sel_mode;
|
| 212 | /*
|
| 213 | 0: GSM
|
| 214 | 1: GSM Compact
|
| 215 | 2: UTRAN
|
| 216 | 3: GSM w/EGPRS
|
| 217 | 4: UTRAN w/HSDPA
|
| 218 | 5: UTRAN w/HSUPA
|
| 219 | 6: UTRAN w/HSDPA and HSUPA
|
| 220 | 7: E-UTRAN
|
| 221 | 8: UTRAN HSPA+
|
| 222 | 0xFF: Unused
|
| 223 | */
|
| 224 | uint8 net_type;
|
| 225 | //uint8 plmn[10]; // 46000
|
| 226 | /*
|
| 227 | 0: unknown
|
| 228 | 1: available
|
| 229 | 2: current
|
| 230 | 3: forbidden
|
| 231 | */
|
| 232 | uint8 net_state;
|
| 233 | uint32 plmn;
|
| 234 | } __attribute__((packed)) mbtk_net_info_t;
|
| 235 |
|
| 236 |
|
| 237 | typedef enum
|
| 238 | {
|
| 239 | MBTK_NET_REG_STATE_NON = 0,
|
| 240 | MBTK_NET_REG_STATE_HOME,
|
| 241 | MBTK_NET_REG_STATE_SEARCHING,
|
| 242 | MBTK_NET_REG_STATE_DENIED,
|
| 243 | MBTK_NET_REG_STATE_UNKNOWN,
|
| 244 | MBTK_NET_REG_STATE_ROAMING,
|
| 245 | MBTK_NET_REG_STATE_SMS_ONLY,
|
| 246 | MBTK_NET_REG_STATE_ROAMING_SMS,
|
| 247 | MBTK_NET_REG_STATE_ATTACHED_EMERGENCY,
|
| 248 | MBTK_NET_REG_STATE_CSFB_HOME,
|
| 249 | MBTK_NET_REG_STATE_CSFB_ROAMING,
|
| 250 | MBTK_NET_REG_STATE_EMERGENCY_ONLY
|
| 251 | } mbtk_net_reg_state_enum;
|
| 252 |
|
| 253 | typedef struct
|
| 254 | {
|
| 255 | uint8 call_state;// mbtk_net_reg_state_enum
|
| 256 | uint8 data_state;// mbtk_net_reg_state_enum
|
| 257 | uint8 ims_state;// mbtk_net_reg_state_enum
|
| 258 | uint8 type; // mbtk_radio_technology_enum
|
| 259 | uint16 lac;
|
| 260 | uint32 ci;
|
| 261 | } __attribute__((packed)) mbtk_net_reg_info_t;
|
| 262 |
|
| 263 | typedef struct
|
| 264 | {
|
| 265 | uint8 type; // mbtk_radio_technology_enum
|
| 266 | uint8 rssi; // 0: 113 dBm or less
|
| 267 | // 1: 111 dBm
|
| 268 | // 2��30: 109��53 dBm
|
| 269 | // 31: 51 dBm or greater
|
| 270 | // 99: not known or not detectable
|
| 271 | uint8 rxlev;// 0:rssi < -110 dBm
|
| 272 | // 1: -110 dBm �� rssi < -109 dBm
|
| 273 | // 2: -109 dBm �� rssi < -108 dBm
|
| 274 | // ......
|
| 275 | // 61: -50 dBm �� rssi < -49 dBm
|
| 276 | // 62: -49 dBm �� rssi < -48 dBm
|
| 277 | // 63: -48 dBm �� rssi
|
| 278 | // 99: not known or not detectable
|
| 279 | uint8 ber; // 0...7 as RXQUAL values in the table in 3GPP TS 45.008 [20] subclause 8.2.4
|
| 280 | // 99 not known or not detectable
|
| 281 | uint8 rscp; // 0: rscp < -120 dBm
|
| 282 | // 1: -120 dBm �� rscp < -119 dBm
|
| 283 | // 2: -119 dBm �� rscp < -118 dBm
|
| 284 | // ......
|
| 285 | // 94: -27 dBm �� rscp < -26 dBm
|
| 286 | // 95: -26 dBm �� rscp < -25 dBm
|
| 287 | // 96: - 25 dBm �� rscp
|
| 288 | // 255: not known or not detectable
|
| 289 | uint8 ecno; // 0: Ec/Io < -24 dB
|
| 290 | // 1: -24 dB �� Ec/Io < -23.5 dB
|
| 291 | // 2: -23.5 dB �� Ec/Io < -23 dB
|
| 292 | // ......
|
| 293 | // 47: -1 dB �� Ec/Io < -0.5 dB
|
| 294 | // 48: -0.5 dB �� Ec/Io < 0 dB
|
| 295 | // 49: 0 dB �� Ec/Io
|
| 296 | // 255: not known or not detectable
|
| 297 | uint8 rsrq; // 0: rsrq < -19.5 dB
|
| 298 | // 1: -19.5 dB �� rsrq < -19 dB
|
| 299 | // 2: -19 dB �� rsrq < -18.5 dB
|
| 300 | // ......
|
| 301 | // 32: -4 dB �� rsrq < -3.5 dB
|
| 302 | // 33: -3.5 dB �� rsrq < -3 dB
|
| 303 | // 34: -3 dB �� rsrq
|
| 304 | // 255: not known or not detectable
|
| 305 | uint8 rsrp; // 0: rsrp < -140 dBm
|
| 306 | // 1: -140 dBm �� rsrp < -139 dBm
|
| 307 | // 2: -139 dBm �� rsrp < -138 dBm
|
| 308 | // ......
|
| 309 | // 95: -46 dBm �� rsrp < -45 dBm
|
| 310 | // 96: -45 dBm �� rsrp < -44 dBm
|
| 311 | // 97: -44 dBm �� rsrp
|
| 312 | // 255: not known or not detectable
|
q.huang | 861c07d | 2025-06-24 16:54:58 +0800 | [diff] [blame] | 313 | int8 sinr; //-20-35 dbm
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 314 | } __attribute__((packed)) mbtk_signal_info_t;
|
| 315 |
|
| 316 | typedef struct{
|
| 317 | uint8_t mode;
|
| 318 | uint32_t oosPhase[3]; //单位为秒
|
| 319 | } mbtk_oos_info;
|
| 320 |
|
| 321 | typedef struct
|
| 322 | {
|
| 323 | /* Configuration parameters for MCM network full band network scan when OOS (out of service)*/
|
| 324 | int t_min;
|
| 325 | int t_step;
|
| 326 | int t_max;
|
| 327 | }GSW_NW_OOS_CONFIG_INFO_T;
|
| 328 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 329 | #define lib_mbtk_path "/lib/libmbtk_lib.so"
|
| 330 | mbtk_info_handle_t* nw_info_handle = NULL;
|
| 331 |
|
q.huang | 638d587 | 2025-06-21 13:44:43 +0800 | [diff] [blame] | 332 | static GSW_NW_ServingInfoHandlePtr serving_cb=NULL;
|
| 333 | static GSW_NW_SigInfoHandlePtr sig_cb=NULL;
|
| 334 | static GSW_NW_RejectCauseHandlePtr reject_cb=NULL;
|
| 335 | static GSW_NW_ModemStateHandlePtr modem_cb=NULL;
|
| 336 | static GSW_NW_AirplaneModeHandlePtr airplane_cb=NULL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 337 |
|
| 338 | static void *dlHandle_mbtk;
|
| 339 | int nw_init_flag = 0;
|
| 340 | int mode = -1;
|
| 341 | int fplmn_max_length = 0;
|
| 342 |
|
| 343 | gsw_nw_plmn_list_t gsw_nw_plmn_list;
|
| 344 | char fplmn_array[FPLMN_ARRAY_SIZE][7];
|
| 345 | int fplmn_index = 0;
|
| 346 |
|
| 347 | static mbtk_info_handle_t* (*mbtk_info_handle_get)(void);
|
| 348 | static int (*mbtk_info_handle_free)(mbtk_info_handle_t** handle);
|
| 349 | int (*mbtk_net_sel_mode_get)(mbtk_info_handle_t* handle, mbtk_net_info_t *net);
|
| 350 | int (*mbtk_net_reg_get)(mbtk_info_handle_t* handle, mbtk_net_reg_info_t *reg);
|
| 351 | int (*mbtk_cell_get)(mbtk_info_handle_t* handle, mbtk_cell_type_enum *type, list_node_t **cell_list);
|
| 352 | int (*mbtk_get_modem_fun)(mbtk_info_handle_t* handle, int* fun);
|
| 353 | static int (*mbtk_set_modem_fun)(mbtk_info_handle_t* handle, mbtk_modem_info_t *info);
|
| 354 | int (*mbtk_current_band_get)(mbtk_info_handle_t* handle, mbtk_band_info_t *band);
|
| 355 | int (*mbtk_current_band_set)(mbtk_info_handle_t* handle, const mbtk_band_info_t *band);
|
| 356 | int (*mbtk_net_signal_get)(mbtk_info_handle_t* handle, mbtk_signal_info_t *signal);
|
| 357 | int (*mbtk_wakeup_state_set)(mbtk_info_handle_t* handle, uint32 wakeup_state);
|
| 358 | int (*mbtk_signal_state_change_cb_reg)(mbtk_info_handle_t* handle, mbtk_info_callback_func cb);
|
| 359 | int (*mbtk_net_state_change_cb_reg)(mbtk_info_handle_t* handle, mbtk_info_callback_func cb);
|
| 360 | int (*mbtk_fplmn_get)(mbtk_info_handle_t *handle, void *fplmn);
|
| 361 | int (*mbtk_fplmn_set)(mbtk_info_handle_t *handle, void *fplmn);
|
| 362 | int (*mbtk_radio_state_change_cb_reg)(mbtk_info_handle_t* handle, mbtk_info_callback_func cb);
|
| 363 | int (*mbtk_oos_get)(mbtk_info_handle_t* handle, mbtk_oos_info *oos_info);
|
| 364 | int (*mbtk_oos_set)(mbtk_info_handle_t* handle, mbtk_oos_info *oos_info);
|
q.huang | 238b22a | 2025-06-10 14:36:59 +0800 | [diff] [blame] | 365 | int (*mbtk_imei_get)(mbtk_info_handle_t* handle, void *imei);
|
q.huang | daa16d4 | 2025-07-03 14:32:48 +0800 | [diff] [blame] | 366 | bool (*str_empty)(const void *str);
|
q.huang | 238b22a | 2025-06-10 14:36:59 +0800 | [diff] [blame] | 367 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 368 |
|
l.yang | 6a42e4d | 2025-05-28 01:04:20 -0700 | [diff] [blame] | 369 | #define GSW_NW "[HAL][GSW_NW]"
|
| 370 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 371 | typedef struct
|
| 372 | {
|
| 373 | char *lynq_operator_l;
|
| 374 | char *lynq_operator_s;
|
| 375 | uint32 lynq_mcc_mnc;
|
| 376 | } lynq_operator_mcc_mnc_t;
|
| 377 |
|
| 378 | static lynq_operator_mcc_mnc_t lynq_operator_mcc_mnc[] =
|
| 379 | {
|
| 380 | {"China Mobile","CMCC",46000},
|
| 381 | {"China Unicom","CU",46001},
|
| 382 | {"China Mobile","CMCC",46002},
|
| 383 | {"China Telecom","CT",46003},
|
| 384 | {"China Mobile","CMCC",46004},
|
| 385 | {"China Telecom","CT",46005},
|
| 386 | {"China Unicom","CU",46006},
|
| 387 | {"China Mobile","CMCC",46007},
|
| 388 | {"China Mobile","CMCC",46008},
|
| 389 | {"China Unicom","CU",46009},
|
| 390 | {"China Telecom","CT",46011}
|
| 391 | };
|
| 392 |
|
| 393 |
|
| 394 | //GSW include
|
| 395 | typedef enum prefer_mode
|
| 396 | {
|
| 397 | GSW_PREFER_MODE_GSW = 1, /**<2G only*/
|
| 398 | GSW_PREFER_MODE_WCDMA = 2, /**< 3G only*/
|
| 399 | GSW_PREFER_MODE_WCDMA_GSM = 3, /**< 3G/2G*/
|
| 400 | GSW_PREFER_MODE_LTE = 4, /**< 4G only*/
|
| 401 | GSW_PREFER_MODE_NR5G = 5, /**< 5G only*/
|
| 402 | GSW_PREFER_MODE_NR5G_LTE = 8, /**< 5G/4G*/
|
| 403 | GSW_PREFER_MODE_LTE_WCDMA_GSM = 9, /**< 4G/3G/2G*/
|
| 404 | GSW_PREFER_MODE_NR5G_LTE_WCDMA_GSM = 32, /**< 5G/4G/3G/2G*/
|
| 405 | } PREFER_MODE_E;
|
| 406 |
|
q.huang | 81905ea | 2025-07-25 20:19:41 +0800 | [diff] [blame] | 407 | #define NW_THEAD_NUM (3)
|
| 408 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 409 | static int mbtk_nw_api_import()
|
| 410 | {
|
| 411 | dlHandle_mbtk = dlopen(lib_mbtk_path, RTLD_NOW);
|
| 412 | if (dlHandle_mbtk == NULL)
|
| 413 | {
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 414 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 415 | }
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 416 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 417 | mbtk_info_handle_get = (mbtk_info_handle_t* (*)(void))dlsym(dlHandle_mbtk, "mbtk_info_handle_get");
|
| 418 | if (mbtk_info_handle_get == NULL)
|
| 419 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 420 | LOGE(GSW_NW,"mbtk_info_handle_get dlsym fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 421 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 422 | }
|
| 423 |
|
| 424 | mbtk_info_handle_free = (int (*)(mbtk_info_handle_t** handle))dlsym(dlHandle_mbtk, "mbtk_info_handle_free");
|
| 425 | if (mbtk_info_handle_free == NULL)
|
| 426 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 427 | LOGE(GSW_NW,"mbtk_info_handle_free dlsym fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 428 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 429 | }
|
| 430 |
|
| 431 | mbtk_net_sel_mode_get = (int (*)(mbtk_info_handle_t* handle, mbtk_net_info_t *net))dlsym(dlHandle_mbtk, "mbtk_net_sel_mode_get");
|
| 432 | if (mbtk_net_sel_mode_get == NULL)
|
| 433 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 434 | LOGE(GSW_NW,"mbtk_net_sel_mode_get dlsym fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 435 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 436 | }
|
| 437 |
|
| 438 | mbtk_net_reg_get = (int (*)(mbtk_info_handle_t* handle, mbtk_net_reg_info_t *reg))dlsym(dlHandle_mbtk, "mbtk_net_reg_get");
|
| 439 | if (mbtk_net_reg_get == NULL)
|
| 440 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 441 | LOGE(GSW_NW,"mbtk_net_reg_get dlsym fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 442 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 443 | }
|
| 444 |
|
| 445 | mbtk_get_modem_fun = (int (*)(mbtk_info_handle_t* handle, int* fun))dlsym(dlHandle_mbtk, "mbtk_get_modem_fun");
|
| 446 | if (mbtk_get_modem_fun == NULL)
|
| 447 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 448 | LOGE(GSW_NW,"mbtk_get_modem_fun dlsym fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 449 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 450 | }
|
| 451 |
|
| 452 | mbtk_set_modem_fun = (int (*)(mbtk_info_handle_t* handle, mbtk_modem_info_t *info))dlsym(dlHandle_mbtk, "mbtk_set_modem_fun");
|
| 453 | if (mbtk_set_modem_fun == NULL)
|
| 454 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 455 | LOGE(GSW_NW,"mbtk_set_modem_fun dlsym fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 456 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 457 | }
|
| 458 |
|
| 459 | mbtk_current_band_get = (int (*)(mbtk_info_handle_t* handle, mbtk_band_info_t *band))dlsym(dlHandle_mbtk, "mbtk_current_band_get");
|
| 460 | if (mbtk_current_band_get == NULL)
|
| 461 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 462 | LOGE(GSW_NW,"mbtk_current_band_get dlsym fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 463 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 464 | }
|
| 465 |
|
| 466 | mbtk_current_band_set = (int (*)(mbtk_info_handle_t* handle, const mbtk_band_info_t *band))dlsym(dlHandle_mbtk, "mbtk_current_band_set");
|
| 467 | if (mbtk_current_band_set == NULL)
|
| 468 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 469 | LOGE(GSW_NW,"mbtk_current_band_set dlsym fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 470 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 471 | }
|
| 472 |
|
| 473 | mbtk_net_signal_get = (int (*)(mbtk_info_handle_t* handle, mbtk_signal_info_t *signal))dlsym(dlHandle_mbtk, "mbtk_net_signal_get");
|
| 474 | if (mbtk_net_signal_get == NULL)
|
| 475 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 476 | LOGE(GSW_NW,"mbtk_net_signal_get dlsym fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 477 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 478 | }
|
| 479 |
|
| 480 | mbtk_wakeup_state_set = (int (*)(mbtk_info_handle_t* handle, uint32 wakeup_state))dlsym(dlHandle_mbtk, "mbtk_wakeup_state_set");
|
| 481 | if (mbtk_wakeup_state_set == NULL)
|
| 482 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 483 | LOGE(GSW_NW,"mbtk_wakeup_state_set dlsym fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 484 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 485 | }
|
| 486 |
|
| 487 | mbtk_cell_get = (int (*)(mbtk_info_handle_t* handle, mbtk_cell_type_enum *type, list_node_t **cell_list))dlsym(dlHandle_mbtk, "mbtk_cell_get");
|
| 488 | if (mbtk_cell_get == NULL)
|
| 489 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 490 | LOGE(GSW_NW,"mbtk_cell_get dlsym fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 491 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 492 | }
|
| 493 |
|
| 494 | mbtk_signal_state_change_cb_reg = (int (*)(mbtk_info_handle_t* handle, mbtk_info_callback_func cb))dlsym(dlHandle_mbtk, "mbtk_signal_state_change_cb_reg");
|
| 495 | if (mbtk_signal_state_change_cb_reg == NULL)
|
| 496 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 497 | LOGE(GSW_NW,"mbtk_signal_state_change_cb_reg dlsym fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 498 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 499 | }
|
| 500 |
|
| 501 | mbtk_net_state_change_cb_reg = (int (*)(mbtk_info_handle_t* handle, mbtk_info_callback_func cb))dlsym(dlHandle_mbtk, "mbtk_net_state_change_cb_reg");
|
| 502 | if (mbtk_net_state_change_cb_reg == NULL)
|
| 503 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 504 | LOGE(GSW_NW,"mbtk_net_state_change_cb_reg dlsym fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 505 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 506 | }
|
| 507 |
|
| 508 | mbtk_fplmn_get = (int(*)(mbtk_info_handle_t *handle, void *fplmn))dlsym(dlHandle_mbtk, "mbtk_fplmn_get");
|
| 509 | if (mbtk_fplmn_get == NULL)
|
| 510 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 511 | LOGE(GSW_NW,"mbtk_fplmn_get dlsym fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 512 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 513 | }
|
| 514 |
|
| 515 | mbtk_fplmn_set = (int(*)(mbtk_info_handle_t *handle, void *fplmn))dlsym(dlHandle_mbtk, "mbtk_fplmn_set");
|
| 516 | if (mbtk_fplmn_set == NULL)
|
| 517 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 518 | LOGE(GSW_NW,"mbtk_fplmn_get dlsym fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 519 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 520 | }
|
| 521 |
|
| 522 | mbtk_radio_state_change_cb_reg = (int (*)(mbtk_info_handle_t* handle, mbtk_info_callback_func cb))dlsym(dlHandle_mbtk, "mbtk_radio_state_change_cb_reg");
|
| 523 | if (mbtk_radio_state_change_cb_reg == NULL)
|
| 524 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 525 | LOGE(GSW_NW,"mbtk_radio_state_change_cb_reg dlsym fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 526 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 527 | }
|
| 528 |
|
| 529 | mbtk_oos_get = (int (*)(mbtk_info_handle_t* handle, mbtk_oos_info *oos))dlsym(dlHandle_mbtk, "mbtk_oos_get");
|
| 530 | if (mbtk_oos_get == NULL)
|
| 531 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 532 | LOGE(GSW_NW,"mbtk_oos_get dlsym fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 533 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 534 | }
|
| 535 |
|
| 536 | mbtk_oos_set = (int (*)(mbtk_info_handle_t* handle, mbtk_oos_info *oos))dlsym(dlHandle_mbtk, "mbtk_oos_set");
|
| 537 | if (mbtk_oos_set == NULL)
|
| 538 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 539 | LOGE(GSW_NW,"mbtk_oos_set dlsym fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 540 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 541 | }
|
q.huang | 238b22a | 2025-06-10 14:36:59 +0800 | [diff] [blame] | 542 |
|
| 543 | mbtk_imei_get = (int (*)(mbtk_info_handle_t* handle, void *imei))dlsym(dlHandle_mbtk, "mbtk_imei_get");
|
| 544 | if (mbtk_imei_get == NULL)
|
| 545 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 546 | LOGE(GSW_NW,"mbtk_imei_get dlsym fail\n");
|
q.huang | 238b22a | 2025-06-10 14:36:59 +0800 | [diff] [blame] | 547 | return GSW_HAL_NORMAL_FAIL;
|
| 548 | }
|
q.huang | daa16d4 | 2025-07-03 14:32:48 +0800 | [diff] [blame] | 549 |
|
| 550 | str_empty = (bool (*)(const void *str))dlsym(dlHandle_mbtk, "str_empty");
|
| 551 | if (str_empty == NULL)
|
| 552 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 553 | LOGE(GSW_NW,"str_empty dlsym fail\n");
|
q.huang | daa16d4 | 2025-07-03 14:32:48 +0800 | [diff] [blame] | 554 | return GSW_HAL_NORMAL_FAIL;
|
| 555 | }
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 556 |
|
| 557 | return GSW_HAL_SUCCESS;
|
| 558 | }
|
| 559 |
|
| 560 | void list_first(list_node_t *list)
|
| 561 | {
|
| 562 | if (list) {
|
| 563 | list->cur_index = 0;
|
| 564 | list->cur_array_data = list->array_data.next;
|
| 565 | }
|
| 566 | }
|
| 567 |
|
| 568 | void* list_next(list_node_t *list)
|
| 569 | {
|
| 570 | if (list) {
|
| 571 | list_arraynode_t *node = list->cur_array_data;
|
| 572 | if (node) {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 573 | LOGE(GSW_NW,"node is not null\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 574 | list->cur_array_data = list->cur_array_data->next;
|
| 575 | list->cur_index++;
|
| 576 | return node->data;
|
| 577 | } else {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 578 | LOGE(GSW_NW,"node is null\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 579 | return NULL;
|
| 580 | }
|
| 581 | } else {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 582 | LOGE(GSW_NW,"list is null\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 583 | return NULL;
|
| 584 | }
|
| 585 | }
|
| 586 |
|
| 587 | void list_free(list_node_t *list)
|
| 588 | {
|
| 589 | if (list) {
|
| 590 | list_arraynode_t *node = &(list->array_data); // Head node
|
| 591 | list_arraynode_t *node_temp = NULL;
|
| 592 | while (node->next) {
|
| 593 | node_temp = node->next;
|
| 594 | node->next = node->next->next;
|
| 595 |
|
| 596 | if (list->free_func) {
|
| 597 | list->free_func(node_temp->data);
|
| 598 | } else {
|
| 599 | free(node_temp->data);
|
| 600 | }
|
| 601 | free(node_temp);
|
| 602 | }
|
| 603 | free(list);
|
| 604 | }
|
| 605 | }
|
| 606 |
|
q.huang | 861c07d | 2025-06-24 16:54:58 +0800 | [diff] [blame] | 607 | #if 0
|
q.huang | 638d587 | 2025-06-21 13:44:43 +0800 | [diff] [blame] | 608 | static int32_t gsm_rssi_convert_to_dBm(uint8 rssi)
|
| 609 | {
|
| 610 | if(rssi <= 31)
|
| 611 | {
|
| 612 | return rssi * 2 - 113; //0 map -113
|
| 613 | //31 map -51
|
| 614 | }
|
| 615 | else
|
| 616 | {
|
| 617 | return INT_32_MAX;
|
| 618 | }
|
| 619 | }
|
q.huang | 861c07d | 2025-06-24 16:54:58 +0800 | [diff] [blame] | 620 | #endif
|
q.huang | 638d587 | 2025-06-21 13:44:43 +0800 | [diff] [blame] | 621 |
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 622 | static int32_t rscp_convert_to_minus_dBm(uint8 rscp)
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 623 | {
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 624 | if(rscp <= 96)
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 625 | {
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 626 | return 121-rscp; // 96 map 25
|
| 627 | // 0 map -121, below -120
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 628 | }
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 629 | else
|
| 630 | {
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 631 | return INT_32_MAX;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 632 | }
|
| 633 | }
|
| 634 |
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 635 | static int32_t rsrp_convert_to_minus_dBm(uint8 rsrp)
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 636 | {
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 637 | if(rsrp <= 97)
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 638 | {
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 639 | return 141-rsrp; // 97 map 44
|
| 640 | // 0 map 141 below 140
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 641 | }
|
| 642 | else
|
| 643 | {
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 644 | return INT_32_MAX;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 645 | }
|
| 646 | }
|
| 647 |
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 648 | static int32_t rsrq_convert_to_minus_dB(uint8 rsrq)
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 649 | {
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 650 | if(rsrq <= 34)
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 651 | {
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 652 | return (40-rsrq)/2; //=20-rsrq / 2;
|
| 653 | // 34 map 3
|
| 654 | // 0 map 20
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 655 | }
|
| 656 | else
|
| 657 | {
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 658 | return INT_32_MAX;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 659 | }
|
| 660 | }
|
| 661 |
|
q.huang | 861c07d | 2025-06-24 16:54:58 +0800 | [diff] [blame] | 662 | static int32_t sinr_convert_to_10_times_dB(int8 sinr)
|
q.huang | 638d587 | 2025-06-21 13:44:43 +0800 | [diff] [blame] | 663 | {
|
| 664 | if(sinr <=35 && sinr>=-20)
|
| 665 | {
|
| 666 | return sinr*10; //35 map 350 db
|
| 667 | // -20 map -2000 db
|
| 668 | }
|
| 669 | else
|
| 670 | {
|
| 671 | return INT_32_MAX;
|
| 672 | }
|
| 673 | }
|
| 674 |
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 675 | //int ecno; /**< Valid values are positive integers. This value is the actual Ec/Io multiplied
|
| 676 | // * by -10. Example: If the actual Ec/Io is -12.5 dB, then this response value
|
| 677 | // * will be 125.*/
|
| 678 | //uint8 ecno; // 0: Ec/Io < -24 dB
|
| 679 | // 1: -24 dB �� Ec/Io < -23.5 dB
|
| 680 | // 2: -23.5 dB �� Ec/Io < -23 dB
|
| 681 | // ......
|
| 682 | // 47: -1 dB �� Ec/Io < -0.5 dB
|
| 683 | // 48: -0.5 dB �� Ec/Io < 0 dB
|
| 684 | // 49: 0 dB �� Ec/Io
|
| 685 | // 255: not known or not detectabl
|
| 686 | static int32_t ecno_convert_to_minus_10_times_dB(uint8 ecno)
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 687 | {
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 688 | if(ecno <=49)
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 689 | {
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 690 | return 245-ecno*5; //49 map 0 db
|
| 691 | // 1 map 240 db
|
| 692 | // 0 map 245 below 240
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 693 | }
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 694 | else
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 695 | {
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 696 | return INT_32_MAX;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 697 | }
|
| 698 | }
|
| 699 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 700 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 701 |
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 702 | /* change realCsq to level */
|
| 703 | static int rscpToLevel(int rscp)
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 704 | {
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 705 |
|
| 706 | if (rscp < -110) {
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 707 | return 0;
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 708 | } else if (rscp <= -95) {
|
| 709 | return rscp+111; // to 16
|
| 710 | } else if (rscp >=-93 && rscp <=-90) {
|
| 711 | return rscp+110; // to 20
|
| 712 | } else if (rscp >=-89 && rscp <=-59) {
|
| 713 | return (rscp+152)/3; // =(rscp+89)/3+21 to 31
|
| 714 | } else if (rscp ==- 94) { // Geely requirement, -94 map 16
|
| 715 | return 16;
|
| 716 | } else if(rscp <= -25) {
|
| 717 | return 31;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 718 | }
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 719 | return 99;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 720 | }
|
| 721 |
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 722 | static int rsrpToLevel(int rsrp)
|
| 723 | {
|
| 724 | if (rsrp < -130) {
|
| 725 | return 0;
|
| 726 | } else if (rsrp <= -118) {
|
| 727 | return (rsrp+132)/2; // to 7
|
| 728 | } else if (rsrp <=-109) {
|
| 729 | return rsrp+125; // to 16
|
| 730 | } else if (rsrp <=-103) {
|
| 731 | return (rsrp+141)/2; // =(rsrp+109)/2+16 to 19
|
| 732 | } else if (rsrp <=- 85) {
|
| 733 | return (rsrp+160)/3; // =(rsrp+103)/3+19 to 25
|
| 734 | } else if(rsrp <= -55) {
|
| 735 | return (rsrp+210)/5; // =(rsrp+85)/5+25 to 31
|
| 736 | } else if(rsrp <=-44)
|
| 737 | {
|
| 738 | return 31;
|
| 739 | }
|
| 740 | return 99;
|
| 741 | }
|
| 742 |
|
q.huang | 861c07d | 2025-06-24 16:54:58 +0800 | [diff] [blame] | 743 | //uint8 rssi; // 0: 113 dBm or less
|
| 744 | // 1: 111 dBm
|
| 745 | // 2��30: 109��53 dBm
|
| 746 | // 31: 51 dBm or greater
|
| 747 | // 99: not known or not detectable
|
| 748 | //uint8 rxlev;// 0:rssi < -110 dBm
|
| 749 | // 1: -110 dBm �� rssi < -109 dBm
|
| 750 | // 2: -109 dBm �� rssi < -108 dBm
|
| 751 | // 60 ......
|
| 752 | // 61: -50 dBm �� rssi < -49 dBm
|
| 753 | // 62: -49 dBm �� rssi < -48 dBm
|
| 754 | // 63: -48 dBm �� rssi
|
| 755 | // 99: not known or not detectable
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 756 |
|
q.huang | 861c07d | 2025-06-24 16:54:58 +0800 | [diff] [blame] | 757 | /* change realCsq to level */
|
| 758 | static int rxlevToLevel(uint8 rxlev)
|
| 759 | {
|
| 760 | if (rxlev <=60) {
|
| 761 | return (rxlev+3)/2; // =(rxlev+1)/2+1,
|
| 762 | // 0 map 1
|
| 763 | // 1,2 map 2
|
| 764 | // 59,60 map 31
|
| 765 | }
|
| 766 | else if(rxlev <=63)
|
| 767 | {
|
| 768 | return 31;
|
| 769 | }
|
q.huang | 2dbc0bc | 2025-08-06 10:36:24 +0800 | [diff] [blame] | 770 | return INVALID_AT_SIGNAL_LEVEL;
|
q.huang | 861c07d | 2025-06-24 16:54:58 +0800 | [diff] [blame] | 771 | }
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 772 |
|
| 773 | static int convert_reg_state(int reg_state_t)
|
| 774 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 775 | LOGD(GSW_NW,"reg_state_t = %d\n",reg_state_t);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 776 | int reg_state = 0;
|
| 777 |
|
| 778 | switch (reg_state_t)
|
| 779 | {
|
| 780 | case MBTK_NET_REG_STATE_NON:
|
| 781 | {
|
| 782 | reg_state = GSW_NETWORK_REG_NOT_REGISTERED;
|
| 783 | break;
|
| 784 | }
|
| 785 | case MBTK_NET_REG_STATE_HOME:
|
| 786 | {
|
| 787 | reg_state = GSW_NETWORK_REG_REGISTERED;
|
| 788 | break;
|
| 789 | }
|
| 790 | case MBTK_NET_REG_STATE_SEARCHING:
|
| 791 | {
|
| 792 | reg_state = GSW_NETWORK_REG_NOT_REGISTERED_SEARCHING;
|
| 793 | break;
|
| 794 | }
|
| 795 | case MBTK_NET_REG_STATE_DENIED:
|
| 796 | {
|
| 797 | reg_state = GSW_NETWORK_REG_REGISTRATION_DENIED;
|
| 798 | break;
|
| 799 | }
|
| 800 | case MBTK_NET_REG_STATE_UNKNOWN:
|
| 801 | {
|
| 802 | reg_state = GSW_NETWORK_REG_REGISTRATION_UNKNOWN;
|
| 803 | break;
|
| 804 | }
|
| 805 | case MBTK_NET_REG_STATE_ROAMING:
|
| 806 | {
|
| 807 | reg_state = GSW_NETWORK_REG_REGISTRATION_ROAMING;
|
| 808 | break;
|
| 809 | }
|
| 810 | case MBTK_NET_REG_STATE_SMS_ONLY:
|
| 811 | case MBTK_NET_REG_STATE_ROAMING_SMS:
|
| 812 | case MBTK_NET_REG_STATE_ATTACHED_EMERGENCY:
|
| 813 | case MBTK_NET_REG_STATE_CSFB_HOME:
|
| 814 | case MBTK_NET_REG_STATE_CSFB_ROAMING:
|
| 815 | case MBTK_NET_REG_STATE_EMERGENCY_ONLY:
|
| 816 | {
|
| 817 | reg_state = GSW_NETWORK_REG_LIMITED_SERVICE;
|
| 818 | break;
|
| 819 | }
|
| 820 | }
|
| 821 |
|
| 822 | return reg_state;
|
| 823 | }
|
| 824 |
|
| 825 |
|
| 826 | static int convert_net_mode(int net_mode)
|
| 827 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 828 | LOGD(GSW_NW,"net_mode = %d\n",net_mode);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 829 | switch(net_mode)
|
| 830 | {
|
| 831 | case MBTK_RADIO_TECH_GSM:
|
| 832 | case MBTK_RADIO_TECH_GSM_COMPACT:
|
| 833 | case MBTK_RADIO_TECH_GSM_EGPRS:
|
| 834 | {
|
| 835 | return GSW_NETWORK_RADIO_GSM;
|
| 836 | }
|
| 837 | case MBTK_RADIO_TECH_UTRAN:
|
| 838 | case MBTK_RADIO_TECH_UTRAN_HSDPA:
|
| 839 | case MBTK_RADIO_TECH_UTRAN_HSUPA:
|
| 840 | case MBTK_RADIO_TECH_UTRAN_HSDPA_HSUPA:
|
| 841 | case MBTK_RADIO_TECH_UTRAN_HSPA:
|
| 842 | {
|
| 843 | return GSW_NETWORK_RADIO_UMTS;
|
| 844 | }
|
| 845 | case MBTK_RADIO_TECH_E_UTRAN:
|
| 846 | {
|
| 847 | return GSW_NETWORK_RADIO_LTE;
|
| 848 | }
|
| 849 |
|
| 850 | default:
|
| 851 | {
|
| 852 | return GSW_NETWORK_RADIO_NO_SVC;
|
| 853 | }
|
| 854 | }
|
| 855 |
|
| 856 | return GSW_NETWORK_RADIO_NO_SVC;
|
| 857 | }
|
| 858 |
|
| 859 | static int convert_mbtk_net_config(int config)
|
| 860 | {
|
| 861 | int net_pref = -1;
|
| 862 |
|
| 863 | switch(config)
|
| 864 | {
|
| 865 | case GSW_PREFER_MODE_GSW:
|
| 866 | {
|
| 867 | net_pref = 0;
|
| 868 | break;
|
| 869 | }
|
| 870 |
|
| 871 | case GSW_PREFER_MODE_WCDMA:
|
| 872 | {
|
| 873 | net_pref = 1;
|
| 874 | break;
|
| 875 | }
|
| 876 |
|
| 877 | case GSW_PREFER_MODE_WCDMA_GSM:
|
| 878 | {
|
| 879 | net_pref = 2;
|
| 880 | break;
|
| 881 | }
|
| 882 |
|
| 883 | case GSW_PREFER_MODE_LTE:
|
| 884 | case GSW_PREFER_MODE_NR5G:
|
| 885 | case GSW_PREFER_MODE_NR5G_LTE:
|
| 886 | {
|
| 887 | net_pref = 5;
|
| 888 | break;
|
| 889 | }
|
| 890 |
|
| 891 | case GSW_PREFER_MODE_LTE_WCDMA_GSM:
|
| 892 | case GSW_PREFER_MODE_NR5G_LTE_WCDMA_GSM:
|
| 893 | {
|
| 894 | net_pref = 15;
|
| 895 | break;
|
| 896 | }
|
| 897 | }
|
| 898 |
|
| 899 | return net_pref;
|
| 900 | }
|
| 901 |
|
| 902 |
|
| 903 | static int convert_gsw_net_config(int config)
|
| 904 | {
|
| 905 | int net_config = -1;
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 906 | LOGD(GSW_NW,"config = %d\n",config);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 907 |
|
| 908 | switch (config)
|
| 909 | {
|
| 910 | case 0:
|
| 911 | {
|
| 912 | net_config = GSW_PREFER_MODE_GSW;
|
| 913 | break;
|
| 914 | }
|
| 915 |
|
| 916 | case 1:
|
| 917 | {
|
| 918 | net_config = GSW_PREFER_MODE_WCDMA;
|
| 919 | break;
|
| 920 | }
|
| 921 |
|
| 922 | case 2:
|
| 923 | {
|
| 924 | net_config = GSW_PREFER_MODE_WCDMA_GSM;
|
| 925 | break;
|
| 926 | }
|
| 927 |
|
| 928 | case 5:
|
| 929 | {
|
| 930 | net_config = GSW_PREFER_MODE_LTE;
|
| 931 | break;
|
| 932 | }
|
| 933 |
|
| 934 | case 15:
|
| 935 | {
|
| 936 | net_config = GSW_PREFER_MODE_LTE_WCDMA_GSM;
|
| 937 | break;
|
| 938 | }
|
| 939 | }
|
| 940 |
|
| 941 | return net_config;
|
| 942 | }
|
| 943 |
|
| 944 | //64F010 -> 46001 (64->46,F0->0,10->01)
|
| 945 | static void transform_fplmn_str_to_plmn(char *entry)
|
| 946 | {
|
| 947 | if (strncmp(entry, "FFFFFF", ENTRY_LENGTH) == 0) {
|
| 948 | return; //if FFFFFF,means invalid fplmn, do nothing
|
| 949 | }
|
| 950 |
|
| 951 | char temp = entry[0];
|
| 952 | entry[0] = entry[1];
|
| 953 | entry[1] = temp;
|
| 954 |
|
| 955 | temp = entry[ENTRY_LENGTH - 2];
|
| 956 | entry[ENTRY_LENGTH - 2] = entry[ENTRY_LENGTH - 1];
|
| 957 | entry[ENTRY_LENGTH - 1] = temp;
|
| 958 |
|
| 959 | memmove(entry + 2, entry + 3, ENTRY_LENGTH - 2);
|
| 960 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 961 | LOGE(GSW_NW,"after transform_fplmn_str_to_plmn: %s\n", entry);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 962 |
|
| 963 | //valid fplmn
|
| 964 | fplmn_index++;
|
| 965 | }
|
| 966 |
|
| 967 | static void extract_mcc_mnc(char *entry, char *mcc, char *mnc)
|
| 968 | {
|
| 969 | strncpy(mcc,entry,3);
|
| 970 | mcc[3] = '\0';
|
| 971 | strncpy(mnc,entry + 3,2);
|
| 972 | mnc[2] = '\0';
|
| 973 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 974 | LOGE(GSW_NW,"entry = %s, mcc = %s, mnc = %s\n", entry, mcc, mnc);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 975 | }
|
| 976 |
|
| 977 |
|
| 978 | static void update_fplmn_list(char *fplmn_str)
|
| 979 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 980 | LOGE(GSW_NW,"fplmn_str = %s\n",fplmn_str);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 981 | char temp_fplmn_array[FPLMN_ARRAY_SIZE][7];
|
| 982 | memset(fplmn_array, 0, sizeof(fplmn_array));
|
| 983 | memset(temp_fplmn_array, 0, sizeof(temp_fplmn_array));
|
| 984 | fplmn_index = 0;
|
| 985 | int array_length = 0;
|
| 986 |
|
| 987 | for (int i = 0; i < strlen(fplmn_str); i += 6) {
|
| 988 |
|
| 989 | int length = (i + 6 < strlen(fplmn_str)) ? 6 : strlen(fplmn_str) - i;
|
| 990 | strncpy(temp_fplmn_array[array_length], fplmn_str + i, length);
|
| 991 | temp_fplmn_array[array_length][length] = '\0';
|
| 992 | array_length++;
|
| 993 | if (i + 6 >= strlen(fplmn_str)) {
|
| 994 | break;
|
| 995 | }
|
| 996 | }
|
| 997 |
|
| 998 | for (int i = 0; i < array_length; i++) {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 999 | LOGE(GSW_NW,"array[%d] = %s\n", i, temp_fplmn_array[i]);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1000 | transform_fplmn_str_to_plmn(temp_fplmn_array[i]);
|
| 1001 | strncpy(fplmn_array[i], temp_fplmn_array[i], ENTRY_LENGTH);
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1002 | LOGE(GSW_NW,"fplmn_array[%d] = %s\n", i, fplmn_array[i]);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1003 | }
|
| 1004 |
|
| 1005 | }
|
| 1006 |
|
| 1007 | static void format_plmn(char *result, char *plmn_entry)
|
| 1008 | {
|
| 1009 | strncpy(result, plmn_entry, strlen(plmn_entry));
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1010 | LOGE(GSW_NW,"result = %s, numStr = %s\n",result, plmn_entry);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1011 |
|
| 1012 | if (strlen(result) >= 2) {
|
| 1013 | char temp = result[0];
|
| 1014 | result[0] = result[1];
|
| 1015 | result[1] = temp;
|
| 1016 | }
|
| 1017 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1018 | LOGE(GSW_NW,"1.result = %s\n",result);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1019 |
|
| 1020 | if (strlen(result) >= 3) {
|
| 1021 | memmove(&result[3], &result[2], strlen(result) - 2 + 1);
|
| 1022 | result[2] = 'F';
|
| 1023 | }
|
| 1024 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1025 | LOGE(GSW_NW,"2.result = %s\n",result);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1026 |
|
| 1027 | if (strlen(result) >= 2) {
|
| 1028 | char temp = result[strlen(result) - 1];
|
| 1029 | result[strlen(result) - 1] = result[strlen(result) - 2];
|
| 1030 | result[strlen(result) - 2] = temp;
|
| 1031 | }
|
| 1032 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1033 | LOGE(GSW_NW,"3.result = %s\n",result);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1034 | }
|
| 1035 |
|
| 1036 |
|
| 1037 | static void convert_plmn_to_fplmn_str(char *fplmn_str)
|
| 1038 | {
|
| 1039 | char temp_fplmn_str[128] = {0};
|
| 1040 | char temp[20]; // 临时存储单个格式化后的数字
|
| 1041 | int index = 0;
|
| 1042 |
|
| 1043 | for (int i = 0; i < fplmn_index; i++) {
|
| 1044 | memset(temp, 0x0, sizeof(temp));
|
| 1045 | format_plmn(temp, fplmn_array[i]);
|
| 1046 | strcat(temp_fplmn_str, temp);
|
| 1047 | index += strlen(temp);
|
| 1048 | }
|
| 1049 |
|
| 1050 | while(index < (6 * fplmn_max_length))
|
| 1051 | {
|
| 1052 | temp_fplmn_str[index++] = 'F';
|
| 1053 | }
|
| 1054 |
|
| 1055 | // 修剪或截断formattedNumbers,确保它不超过6 * fplmn_max_length个字符
|
| 1056 | if (index > (6 * fplmn_max_length)) {
|
| 1057 | temp_fplmn_str[(6 * fplmn_max_length)] = '\0';
|
| 1058 | }
|
| 1059 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1060 | LOGE(GSW_NW,"%s\n", temp_fplmn_str);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1061 | strncpy(fplmn_str, temp_fplmn_str, strlen(temp_fplmn_str));
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1062 | LOGE(GSW_NW,"fplmn_str = %s\n", fplmn_str);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1063 | }
|
| 1064 |
|
| 1065 | static int check_index(char *mcc, char *mnc)
|
| 1066 | {
|
| 1067 | int i = 0;
|
| 1068 |
|
| 1069 | for(i = 0; i < fplmn_index; i++)
|
| 1070 | {
|
| 1071 | if(strncmp(fplmn_array[i], mcc, 3) == 0 && strncmp(fplmn_array[i] + 3, mnc, 2) == 0)
|
| 1072 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1073 | LOGE(GSW_NW,"index = %d\n", i);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1074 | return i;
|
| 1075 | }
|
| 1076 | }
|
| 1077 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1078 | LOGE(GSW_NW,"not find\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1079 | return -1;
|
| 1080 | }
|
| 1081 |
|
| 1082 | static void remove_fplmn(int index)
|
| 1083 | {
|
| 1084 | int write_index = 0;
|
| 1085 | for (int i = 0; i < fplmn_index; i++) {
|
| 1086 | if (i != index) {
|
| 1087 | strncpy(fplmn_array[write_index++], fplmn_array[i], ENTRY_LENGTH);
|
| 1088 | }
|
| 1089 | }
|
| 1090 | fplmn_index--;
|
| 1091 | }
|
| 1092 |
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 1093 | static void convert_mbtk_sig_info_to_gsw_sig_info(const mbtk_signal_info_t* signal, signalStrength_t* sig_strength)
|
| 1094 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1095 | LOGD(GSW_NW,"signal->type=%d", signal->type);
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 1096 | memset(sig_strength,0,sizeof (signalStrength_t));
|
| 1097 | switch(signal->type)
|
| 1098 | {
|
| 1099 | case MBTK_RADIO_TECH_E_UTRAN:
|
| 1100 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1101 | LOGI(GSW_NW,"rsrp = %d",signal->rsrp);
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 1102 | sig_strength->lte_sig_valid = 1;
|
q.huang | c8b9312 | 2025-06-17 17:46:05 +0800 | [diff] [blame] | 1103 | sig_strength->rsrp = rsrp_convert_to_minus_dBm(signal->rsrp);
|
| 1104 | sig_strength->rsrq = rsrq_convert_to_minus_dB(signal->rsrq);
|
q.huang | 861c07d | 2025-06-24 16:54:58 +0800 | [diff] [blame] | 1105 | sig_strength->rssnr= sinr_convert_to_10_times_dB(signal->sinr);
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 1106 | break;
|
| 1107 | }
|
| 1108 | case MBTK_RADIO_TECH_UTRAN:
|
| 1109 | case MBTK_RADIO_TECH_UTRAN_HSDPA:
|
| 1110 | case MBTK_RADIO_TECH_UTRAN_HSUPA:
|
| 1111 | case MBTK_RADIO_TECH_UTRAN_HSDPA_HSUPA:
|
| 1112 | case MBTK_RADIO_TECH_UTRAN_HSPA:
|
| 1113 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1114 | LOGI(GSW_NW,"rscp = %d",signal->rscp);
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 1115 | sig_strength->wcdma_sig_valid = 1;
|
| 1116 | sig_strength->rscp = rscp_convert_to_minus_dBm(signal->rscp);
|
q.huang | 2dbc0bc | 2025-08-06 10:36:24 +0800 | [diff] [blame] | 1117 | sig_strength->ecno = ecno_convert_to_minus_10_times_dB(signal->ecno);
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 1118 | break;
|
| 1119 | }
|
| 1120 | case MBTK_RADIO_TECH_GSM:
|
| 1121 | case MBTK_RADIO_TECH_GSM_COMPACT:
|
| 1122 | case MBTK_RADIO_TECH_GSM_EGPRS:
|
| 1123 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1124 | LOGI(GSW_NW,"g rxlev = %d",signal->rxlev);
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 1125 | sig_strength->gw_sig_valid = 1;
|
q.huang | 2dbc0bc | 2025-08-06 10:36:24 +0800 | [diff] [blame] | 1126 | sig_strength->rssi = rxlevToLevel(signal->rxlev);
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 1127 | break;
|
| 1128 | }
|
| 1129 | default:
|
| 1130 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1131 | LOGE(GSW_NW,"[%s] unknown reg type.[%d]", __func__, signal->type);
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 1132 | }
|
| 1133 | }
|
| 1134 |
|
| 1135 | }
|
| 1136 |
|
q.huang | 66b7916 | 2025-06-27 17:45:34 +0800 | [diff] [blame] | 1137 | /*
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1138 | typedef enum{ |
| 1139 | MBTK_READY_INIT = -1, |
| 1140 | MBTK_READY_SUCCESS, |
| 1141 | MBTK_READY_MODEM_FAIL, |
| 1142 | MBTK_READY_RESPONSE_FAIL, |
| 1143 | MBTK_READY_SOCKET_FAIL, |
| 1144 | MBTK_READY_RIL_FAIL |
q.huang | 66b7916 | 2025-06-27 17:45:34 +0800 | [diff] [blame] | 1145 | }mbtk_ready_status_type;
|
| 1146 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1147 | typedef enum gsw_hal_nw_mode_state_type |
| 1148 | { |
| 1149 | GSW_MODEM_STATE_UNKNOWN = 0, |
| 1150 | GSW_MODEM_STATE_ONLINE, |
| 1151 | GSW_MODEM_STATE_OFFLINE, |
| 1152 | GSW_SDK_STATE_SERVICE_DOWN, |
| 1153 | GSW_SDK_STATE_SERVICE_UP,// service down->up 需要routectl 重启 |
| 1154 | GSW_SDK_STATE_GPS_DOWN, |
| 1155 | GSW_SDK_STATE_GPS_UP, |
q.huang | 66b7916 | 2025-06-27 17:45:34 +0800 | [diff] [blame] | 1156 | } gsw_mode_state_e;
|
| 1157 |
|
| 1158 | */
|
| 1159 |
|
q.huang | 66b7916 | 2025-06-27 17:45:34 +0800 | [diff] [blame] | 1160 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1161 | static void gsw_serving_info_callback_thread()
|
| 1162 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1163 | GSW_NW_SERVING_INFO serving_info;
|
| 1164 | int ret = gsw_get_nwinfo(&serving_info);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1165 | if(ret != 0)
|
| 1166 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1167 | LOGE(GSW_NW,"cb gsw_get_nwinfo failed");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1168 | return;
|
| 1169 | }
|
| 1170 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1171 | if(serving_cb!=NULL)
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1172 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1173 | LOGE(GSW_NW,"serving cb called");
|
| 1174 | serving_cb(serving_info);
|
| 1175 | }
|
| 1176 | else
|
| 1177 | {
|
| 1178 | LOGE(GSW_NW,"serving cb is NULL");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1179 | }
|
| 1180 | }
|
| 1181 |
|
| 1182 | static void gsw_serving_info_callback(const void* data, int data_len)
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1183 | {
|
| 1184 | if (nw_init_flag == 0)
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1185 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1186 | printf("%s, nw not init\n",__func__);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1187 | return;
|
| 1188 | }
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1189 |
|
| 1190 | pthread_t thread;
|
| 1191 | int ret=pthread_create(&thread, NULL, (void*)gsw_serving_info_callback_thread, NULL);
|
| 1192 | if(ret==0)
|
| 1193 | {
|
| 1194 | pthread_detach(thread);
|
| 1195 | }
|
| 1196 | else
|
| 1197 | {
|
| 1198 | LOGE(GSW_NW,"create thread fail, ret is %d",ret);
|
| 1199 | }
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1200 | }
|
| 1201 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1202 |
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 1203 | /*typedef struct
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1204 | { |
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 1205 | 0 mbtk_radio_technology_enum type : 8; // mbtk_radio_technology_enum
|
| 1206 | 1 uint8 rssi; // 0: 113 dBm or less
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1207 | // 1: 111 dBm |
| 1208 | // 2��30: 109��53 dBm |
| 1209 | // 31: 51 dBm or greater |
| 1210 | // 99: not known or not detectable |
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 1211 | 2 uint8 rxlev;// 0:rssi < -110 dBm
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1212 | // 1: -110 dBm �� rssi < -109 dBm |
| 1213 | // 2: -109 dBm �� rssi < -108 dBm |
| 1214 | // ...... |
| 1215 | // 61: -50 dBm �� rssi < -49 dBm |
| 1216 | // 62: -49 dBm �� rssi < -48 dBm |
| 1217 | // 63: -48 dBm �� rssi |
| 1218 | // 99: not known or not detectable |
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 1219 | 3 uint8 ber; // 0...7 as RXQUAL values in the table in 3GPP TS 45.008 [20] subclause 8.2.4
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1220 | // 99 not known or not detectable |
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 1221 | 4 uint8 rscp; // 0: rscp < -120 dBm
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1222 | // 1: -120 dBm �� rscp < -119 dBm |
| 1223 | // 2: -119 dBm �� rscp < -118 dBm |
| 1224 | // ...... |
| 1225 | // 94: -27 dBm �� rscp < -26 dBm |
| 1226 | // 95: -26 dBm �� rscp < -25 dBm |
| 1227 | // 96: - 25 dBm �� rscp |
| 1228 | // 255: not known or not detectable |
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 1229 | 5 uint8 ecno; // 0: Ec/Io < -24 dB
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1230 | // 1: -24 dB �� Ec/Io < -23.5 dB |
| 1231 | // 2: -23.5 dB �� Ec/Io < -23 dB |
| 1232 | // ...... |
| 1233 | // 47: -1 dB �� Ec/Io < -0.5 dB |
| 1234 | // 48: -0.5 dB �� Ec/Io < 0 dB |
| 1235 | // 49: 0 dB �� Ec/Io |
| 1236 | // 255: not known or not detectable |
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 1237 | 6 uint8 rsrq; // 0: rsrq < -19.5 dB
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1238 | // 1: -19.5 dB �� rsrq < -19 dB |
| 1239 | // 2: -19 dB �� rsrq < -18.5 dB |
| 1240 | // ...... |
| 1241 | // 32: -4 dB �� rsrq < -3.5 dB |
| 1242 | // 33: -3.5 dB �� rsrq < -3 dB |
| 1243 | // 34: -3 dB �� rsrq |
| 1244 | // 255: not known or not detectable |
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 1245 | 7 uint8 rsrp; // 0: rsrp < -140 dBm
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1246 | // 1: -140 dBm �� rsrp < -139 dBm |
| 1247 | // 2: -139 dBm �� rsrp < -138 dBm |
| 1248 | // ...... |
| 1249 | // 95: -46 dBm �� rsrp < -45 dBm |
| 1250 | // 96: -45 dBm �� rsrp < -44 dBm |
| 1251 | // 97: -44 dBm �� rsrp |
| 1252 | // 255: not known or not detectable |
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 1253 | 8 uint8 ss_rsrq; // 0: ss_rsrq < -43 dB
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1254 | // 1: -43 dB <= ss_rsrq < -42.5 dB |
| 1255 | // 2: -42.5 dB <= ss_rsrq < -42 dB |
| 1256 | // ...... |
| 1257 | // 125: 19 dB <= ss_rsrq < 19.5 dB |
| 1258 | // 126: 19.5 dB <= ss_rsrq < 20 dB |
| 1259 | // 255: not known or not detectable |
| 1260 | uint8 ss_rsrp; // 0: ss_rsrp < -156 dBm |
| 1261 | // 1: -156 dBm <= ss_rsrp < -155 dBm |
| 1262 | // 2: -155 dBm <= ss_rsrp < -154 dBm |
| 1263 | // ...... |
| 1264 | // 125: -32 dBm <= ss_rsrp < -31 dBm |
| 1265 | // 126: -31 dBm <= ss_rsrp |
| 1266 | // 255: not known or not detectable |
| 1267 | uint8 ss_sinr; // 0: ss_sinr < -23 dB |
| 1268 | // 1: -23 dB ss_sinr < -22.5 dB |
| 1269 | // 2: -22.5 dB ss_sinr < -22 dB |
| 1270 | // ...... |
| 1271 | // 125: 39 dB ss_sinr < 39.5 dBm |
| 1272 | // 126: 39.5 dB ss_sinr < 40 dB |
| 1273 | // 127: 40 dB ss_sinr |
| 1274 | // 255: not known or not detectable |
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 1275 | } __attribute__((packed)) mbtk_signal_info_t;
|
| 1276 | */
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1277 | static void gsw_sig_info_callback(const void* data, int data_len)
|
| 1278 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1279 | if (nw_init_flag == 0)
|
| 1280 | {
|
| 1281 | printf("%s, nw not init\n",__func__);
|
| 1282 | return;
|
| 1283 | }
|
| 1284 |
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 1285 | if(data && (data_len >= sizeof (mbtk_signal_info_t)))
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1286 | {
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1287 | signalStrength_t sig_strength;
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 1288 | convert_mbtk_sig_info_to_gsw_sig_info(( const mbtk_signal_info_t*) data,&sig_strength);
|
| 1289 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1290 | if(sig_cb != NULL)
|
| 1291 | {
|
| 1292 | sig_cb(sig_strength);
|
| 1293 | }
|
| 1294 | }
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1295 | else
|
| 1296 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1297 | LOGE(GSW_NW,"data is NULL or data len %d error",data_len);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1298 | }
|
| 1299 | }
|
| 1300 |
|
q.huang | c8b9312 | 2025-06-17 17:46:05 +0800 | [diff] [blame] | 1301 | static void gsw_operating_mode_event_callback(const void* data, int data_len)
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1302 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1303 | if (nw_init_flag == 0)
|
| 1304 | {
|
| 1305 | printf("%s nw not init\n",__func__);
|
| 1306 | return;
|
| 1307 | }
|
| 1308 |
|
| 1309 | LOGE(GSW_NW,"gsw_operating_mode_event_callback start\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1310 |
|
q.huang | c8b9312 | 2025-06-17 17:46:05 +0800 | [diff] [blame] | 1311 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1312 | if(data && data_len > 0)
|
| 1313 | {
|
q.huang | c8b9312 | 2025-06-17 17:46:05 +0800 | [diff] [blame] | 1314 | const uint8 *cfun_state = (const uint8*)data;
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1315 | LOGE(GSW_NW,"gsw_operating_mode_event_callback,data = %d\n", *cfun_state);
|
q.huang | c8b9312 | 2025-06-17 17:46:05 +0800 | [diff] [blame] | 1316 | if(airplane_cb != NULL)
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1317 | {
|
q.huang | c8b9312 | 2025-06-17 17:46:05 +0800 | [diff] [blame] | 1318 | airplane_cb(*cfun_state);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1319 | }
|
| 1320 | }
|
| 1321 |
|
| 1322 | }
|
| 1323 |
|
q.huang | daa16d4 | 2025-07-03 14:32:48 +0800 | [diff] [blame] | 1324 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1325 | static void gsw_reject_callback(GSW_NW_RADIO_ACCESS_TECH_E rat, GSW_SERVICE_DOMAIN_E domain, int cause)
|
| 1326 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1327 | if (nw_init_flag == 0)
|
| 1328 | {
|
| 1329 | printf("%s nw not init\n",__func__);
|
| 1330 | return;
|
| 1331 | }
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1332 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1333 | LOGE(GSW_NW,"gsw_reject_callback start,rat = %d,domain = %d,cause = %d\n",rat,domain,cause);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1334 |
|
| 1335 | if(reject_cb != NULL)
|
| 1336 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1337 | GSW_NW_REJ_CAUSE_E rej_cause;
|
| 1338 | rej_cause.rej_cause = cause;
|
| 1339 | rej_cause.rej_rat = rat;
|
| 1340 | rej_cause.rej_domain = domain;
|
| 1341 |
|
| 1342 | LOGE(GSW_NW,"reject_cb called\n");
|
| 1343 | reject_cb(&rej_cause);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1344 | }
|
| 1345 | else
|
| 1346 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1347 | LOGE(GSW_NW,"reject_cb is NULL\n");
|
| 1348 | }
|
| 1349 | }
|
| 1350 |
|
| 1351 | void gsw_serving_info_timer()
|
| 1352 | {
|
| 1353 | if(nw_init_flag == 0 || nw_info_handle == NULL)
|
| 1354 | {
|
| 1355 | return;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1356 | }
|
| 1357 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1358 | while(nw_init_flag)
|
| 1359 | {
|
| 1360 | gsw_serving_info_callback_thread();
|
| 1361 | sleep(SERVING_TIMER);
|
| 1362 | }
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1363 | }
|
| 1364 |
|
xy.he | c89938f | 2025-05-29 14:08:47 +0800 | [diff] [blame] | 1365 | void gsw_sig_info_timer()
|
| 1366 | {
|
xy.he | c89938f | 2025-05-29 14:08:47 +0800 | [diff] [blame] | 1367 | if(nw_init_flag == 0 || nw_info_handle == NULL)
|
| 1368 | {
|
| 1369 | return;
|
| 1370 | }
|
| 1371 |
|
| 1372 | mbtk_signal_info_t signal;
|
| 1373 | signalStrength_t sig_strength;
|
| 1374 |
|
| 1375 | while(nw_init_flag)
|
| 1376 | {
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 1377 | int ret = mbtk_net_signal_get(nw_info_handle, &signal);
|
xy.he | c89938f | 2025-05-29 14:08:47 +0800 | [diff] [blame] | 1378 | if(ret != 0)
|
| 1379 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1380 | LOGE(GSW_NW,"mbtk_net_signal_get fail, ret is %d\n",ret);
|
q.huang | 47a9bf1 | 2025-08-06 20:24:12 +0800 | [diff] [blame^] | 1381 | memset((void*) &sig_strength,0,sizeof (sig_strength));
|
xy.he | c89938f | 2025-05-29 14:08:47 +0800 | [diff] [blame] | 1382 | }
|
xy.he | c89938f | 2025-05-29 14:08:47 +0800 | [diff] [blame] | 1383 | else
|
| 1384 | {
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 1385 | convert_mbtk_sig_info_to_gsw_sig_info(&signal,&sig_strength);
|
q.huang | 47a9bf1 | 2025-08-06 20:24:12 +0800 | [diff] [blame^] | 1386 | }
|
| 1387 | if(sig_cb != NULL)
|
| 1388 | {
|
| 1389 | sig_cb(sig_strength);
|
xy.he | c89938f | 2025-05-29 14:08:47 +0800 | [diff] [blame] | 1390 | }
|
xy.he | c89938f | 2025-05-29 14:08:47 +0800 | [diff] [blame] | 1391 | sleep(SIG_TIMER);
|
| 1392 | }
|
| 1393 | }
|
| 1394 |
|
q.huang | daa16d4 | 2025-07-03 14:32:48 +0800 | [diff] [blame] | 1395 | int get_sdk_ready()
|
| 1396 | {
|
| 1397 | char buffer[MBTK_READY_STRING_SIZE_MAX];
|
| 1398 | FILE *fp = popen(SDK_READY_CMD, "r");
|
| 1399 | if(NULL == fp)
|
| 1400 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1401 | LOGE(GSW_NW,"popen sdk ready fail");
|
q.huang | daa16d4 | 2025-07-03 14:32:48 +0800 | [diff] [blame] | 1402 | return -1;
|
| 1403 | }
|
| 1404 | memset(buffer,0,sizeof(buffer));
|
| 1405 | if(fgets(buffer, sizeof(buffer), fp) == NULL)
|
| 1406 | {
|
| 1407 | pclose(fp);
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1408 | LOGE(GSW_NW,"fgets failed:");
|
q.huang | daa16d4 | 2025-07-03 14:32:48 +0800 | [diff] [blame] | 1409 | return -1;
|
| 1410 | }
|
| 1411 | pclose(fp);
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1412 | LOGE(GSW_NW,"get_sdk_ready:%s",buffer);
|
q.huang | daa16d4 | 2025-07-03 14:32:48 +0800 | [diff] [blame] | 1413 | return atoi(buffer);
|
| 1414 | }
|
| 1415 |
|
rx.xie | aad2b6f | 2025-08-01 00:55:33 -0700 | [diff] [blame] | 1416 | static int g_modem_state = ((int)(GSW_MODEM_STATE_UNKNOWN)) - 1;
|
| 1417 | static int g_gnss_state = ((int)(GSW_MODEM_STATE_UNKNOWN)) - 1;
|
q.huang | 66b7916 | 2025-06-27 17:45:34 +0800 | [diff] [blame] | 1418 |
|
q.huang | 66b7916 | 2025-06-27 17:45:34 +0800 | [diff] [blame] | 1419 | void gsw_modem_state_timer()
|
rx.xie | aad2b6f | 2025-08-01 00:55:33 -0700 | [diff] [blame] | 1420 | {
|
| 1421 | int modem_state;
|
| 1422 | int gnss_state;
|
| 1423 |
|
| 1424 | while (nw_init_flag)
|
q.huang | 66b7916 | 2025-06-27 17:45:34 +0800 | [diff] [blame] | 1425 | {
|
rx.xie | aad2b6f | 2025-08-01 00:55:33 -0700 | [diff] [blame] | 1426 | int uci_value = get_sdk_ready();
|
| 1427 | if (uci_value < 0)
|
q.huang | 66b7916 | 2025-06-27 17:45:34 +0800 | [diff] [blame] | 1428 | {
|
rx.xie | aad2b6f | 2025-08-01 00:55:33 -0700 | [diff] [blame] | 1429 | modem_state = GSW_MODEM_STATE_UNKNOWN;
|
| 1430 | gnss_state = GSW_SDK_STATE_GPS_DOWN;
|
| 1431 | }
|
| 1432 | else
|
| 1433 | {
|
| 1434 | if ((uci_value & 0x0F) == 0)
|
q.huang | 66b7916 | 2025-06-27 17:45:34 +0800 | [diff] [blame] | 1435 | {
|
rx.xie | aad2b6f | 2025-08-01 00:55:33 -0700 | [diff] [blame] | 1436 | modem_state = GSW_MODEM_STATE_ONLINE;
|
| 1437 | }
|
| 1438 | else if (uci_value > 0 && uci_value <= 15)
|
q.huang | 66b7916 | 2025-06-27 17:45:34 +0800 | [diff] [blame] | 1439 | {
|
rx.xie | aad2b6f | 2025-08-01 00:55:33 -0700 | [diff] [blame] | 1440 | modem_state = GSW_MODEM_STATE_OFFLINE;
|
q.huang | 66b7916 | 2025-06-27 17:45:34 +0800 | [diff] [blame] | 1441 | }
|
rx.xie | aad2b6f | 2025-08-01 00:55:33 -0700 | [diff] [blame] | 1442 | else
|
| 1443 | {
|
| 1444 | modem_state = GSW_MODEM_STATE_UNKNOWN;
|
| 1445 | }
|
| 1446 |
|
| 1447 | if (uci_value & (1 << 4))
|
| 1448 | {
|
| 1449 | gnss_state = GSW_SDK_STATE_GPS_DOWN;
|
| 1450 | }
|
| 1451 | else
|
| 1452 | {
|
| 1453 | gnss_state = GSW_SDK_STATE_GPS_UP;
|
| 1454 | }
|
| 1455 | }
|
| 1456 |
|
| 1457 | if (modem_cb != NULL)
|
| 1458 | {
|
| 1459 |
|
| 1460 | if (modem_state != g_modem_state)
|
| 1461 | {
|
| 1462 | LOGE(GSW_NW, "Modem state changed from %d to %d", g_modem_state, modem_state);
|
| 1463 | modem_cb(modem_state);
|
| 1464 | g_modem_state = modem_state;
|
| 1465 | }
|
| 1466 |
|
| 1467 | if (gnss_state != g_gnss_state)
|
| 1468 | {
|
| 1469 | LOGE(GSW_NW, "GNSS state changed from %d to %d", g_gnss_state, gnss_state);
|
| 1470 | modem_cb(gnss_state);
|
| 1471 | g_gnss_state = gnss_state;
|
| 1472 | }
|
| 1473 | }
|
| 1474 | sleep(MODEM_TIMER);
|
q.huang | 66b7916 | 2025-06-27 17:45:34 +0800 | [diff] [blame] | 1475 | }
|
| 1476 | }
|
| 1477 |
|
| 1478 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1479 |
|
| 1480 | /**
|
| 1481 | * @brief SDK interface to call back serving info
|
| 1482 | * @param [in] handle_ptr
|
| 1483 | * @retval 0: success
|
| 1484 | * @retval other: fail
|
| 1485 | */
|
| 1486 | int gsw_reg_serving_info_callback(GSW_NW_ServingInfoHandlePtr handle_ptr)
|
| 1487 | {
|
| 1488 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 1489 | {
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 1490 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1491 | }
|
| 1492 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1493 | void* cb_func;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1494 | if(handle_ptr == NULL)
|
| 1495 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1496 | LOGE(GSW_NW,"serving info handle_ptr is NULL\n");
|
| 1497 | cb_func=NULL;
|
| 1498 | }
|
| 1499 | else
|
| 1500 | {
|
| 1501 | cb_func=(void*) gsw_serving_info_callback;
|
| 1502 | }
|
| 1503 |
|
| 1504 | int ret = mbtk_net_state_change_cb_reg(nw_info_handle, cb_func);
|
| 1505 | if (ret != 0)
|
| 1506 | {
|
| 1507 | LOGW(GSW_NW,"mbtk_net_state_change_cb_reg fail, ret is %d",ret);
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 1508 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1509 | }
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1510 | serving_cb=handle_ptr;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1511 | return GSW_HAL_SUCCESS;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1512 | }
|
| 1513 |
|
| 1514 |
|
| 1515 | /**
|
| 1516 | * @brief SDK interface to call back sig info
|
| 1517 | * @param [in] handle_ptr
|
| 1518 | * @retval 0: success
|
| 1519 | * @retval other: fail
|
| 1520 | */
|
| 1521 | int gsw_reg_sig_info_callback(GSW_NW_SigInfoHandlePtr handle_ptr)
|
| 1522 | {
|
| 1523 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 1524 | {
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 1525 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1526 | }
|
q.huang | 81905ea | 2025-07-25 20:19:41 +0800 | [diff] [blame] | 1527 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1528 | void* cb_func;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1529 | if(handle_ptr == NULL)
|
| 1530 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1531 | LOGE(GSW_NW,"serving info handle_ptr is NULL\n");
|
| 1532 | cb_func=NULL;
|
| 1533 | }
|
| 1534 | else
|
| 1535 | {
|
| 1536 | cb_func=(void*) gsw_sig_info_callback;
|
| 1537 | }
|
| 1538 |
|
| 1539 | int ret = mbtk_signal_state_change_cb_reg(nw_info_handle, cb_func);
|
| 1540 |
|
| 1541 | if (ret != 0)
|
| 1542 | {
|
| 1543 | LOGE(GSW_NW,"mbtk_signal_state_change_cb_reg fail, ret is %d", ret);
|
| 1544 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1545 | }
|
| 1546 |
|
| 1547 | sig_cb = handle_ptr;
|
| 1548 |
|
| 1549 | return GSW_HAL_SUCCESS;
|
| 1550 |
|
| 1551 | }
|
| 1552 |
|
| 1553 |
|
| 1554 | /**
|
| 1555 | * @brief SDK interface to call back rej cause
|
| 1556 | * @param [in] handle_ptr
|
| 1557 | * @retval 0: success
|
| 1558 | * @retval other: fail
|
| 1559 | */
|
| 1560 | int gsw_reg_rej_cause_callback(GSW_NW_RejectCauseHandlePtr handle_ptr)
|
| 1561 | {
|
| 1562 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 1563 | {
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 1564 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1565 | }
|
| 1566 |
|
| 1567 | if(handle_ptr == NULL)
|
| 1568 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1569 | LOGE(GSW_NW,"rej cause handle_ptr is NULL\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1570 | }
|
| 1571 |
|
| 1572 | reject_cb = handle_ptr;
|
| 1573 |
|
| 1574 | return GSW_HAL_SUCCESS;
|
| 1575 | }
|
| 1576 |
|
q.huang | 81905ea | 2025-07-25 20:19:41 +0800 | [diff] [blame] | 1577 | static void gsw_un_reg_all()
|
| 1578 | {
|
| 1579 | gsw_reg_serving_info_callback(NULL);
|
| 1580 | gsw_reg_sig_info_callback(NULL);
|
| 1581 | gsw_reg_operating_mode_callback(NULL);
|
| 1582 | gsw_reg_set_modem_status_event_callback(NULL);
|
| 1583 | gsw_reg_rej_cause_callback(NULL);
|
| 1584 | }
|
| 1585 |
|
| 1586 | pthread_t s_tid[NW_THEAD_NUM] = {-1,-1,-1};
|
| 1587 | void* s_thread_func[NW_THEAD_NUM]={
|
| 1588 | (void*)gsw_sig_info_timer,
|
| 1589 | (void*)gsw_modem_state_timer,
|
| 1590 | (void*)gsw_serving_info_timer
|
| 1591 | };
|
| 1592 |
|
| 1593 | static void gsw_close_all_thread()
|
| 1594 | {
|
| 1595 | int i,ret;
|
| 1596 |
|
| 1597 |
|
| 1598 | nw_init_flag=0;
|
| 1599 |
|
| 1600 | /* had better not use thread cancel, maybe handle->send_mutex is locked now, cancel will not release this mutex
|
| 1601 | for(i=0; i<NW_THEAD_NUM; i++)
|
| 1602 | {
|
| 1603 | if(s_tid[i]!=-1)
|
| 1604 | {
|
| 1605 | ret = pthread_cancel(s_tid[i]);
|
| 1606 | LOGE(GSW_NW,"pthread %d cancel, ret is %d",i, ret);
|
| 1607 | }
|
| 1608 | }
|
| 1609 | */
|
| 1610 |
|
| 1611 | for(i=0;i<NW_THEAD_NUM;i++)
|
| 1612 | {
|
| 1613 | if(s_tid[i]!=-1)
|
| 1614 | {
|
| 1615 | ret = pthread_join(s_tid[i],NULL);
|
| 1616 | LOGE(GSW_NW,"pthread %d join, ret is %d",i, ret);
|
| 1617 | s_tid[i]=-1;
|
| 1618 | }
|
| 1619 | }
|
| 1620 | }
|
| 1621 |
|
| 1622 | static int gsw_start_all_thread()
|
| 1623 | {
|
| 1624 | int i,ret;
|
| 1625 | for(i=0; i<NW_THEAD_NUM;i++)
|
| 1626 | {
|
| 1627 | ret = pthread_create(&(s_tid[i]), NULL,s_thread_func[i], NULL);
|
| 1628 | if (ret != 0)
|
| 1629 | {
|
| 1630 | LOGE(GSW_NW,"pthread_create fail %d,ret is %d",i,ret);
|
| 1631 | gsw_close_all_thread();
|
| 1632 | return GSW_HAL_ERROR_GNSS_NO_THRESHOLDS;
|
| 1633 | }
|
| 1634 | }
|
| 1635 |
|
| 1636 | return GSW_HAL_SUCCESS;
|
| 1637 |
|
| 1638 | }
|
| 1639 |
|
| 1640 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1641 |
|
| 1642 | /**
|
| 1643 | * @brief network sdk init
|
| 1644 | * @param [in] token usr id define by who use
|
| 1645 | * @retval 0: success
|
| 1646 | * @retval other: fail
|
| 1647 | */
|
| 1648 | int gsw_nw_sdk_init(int token)
|
| 1649 | {
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1650 | if (nw_init_flag == 1 && nw_info_handle != NULL)
|
| 1651 | {
|
| 1652 | return GSW_HAL_SUCCESS;
|
| 1653 | }
|
| 1654 |
|
q.huang | 81905ea | 2025-07-25 20:19:41 +0800 | [diff] [blame] | 1655 | int ret = mbtk_nw_api_import();
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1656 | if (ret != 0)
|
| 1657 | {
|
q.huang | 81905ea | 2025-07-25 20:19:41 +0800 | [diff] [blame] | 1658 | printf("mbtk_nw_api_import fail");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 1659 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1660 | }
|
| 1661 |
|
| 1662 | nw_info_handle = mbtk_info_handle_get();
|
| 1663 |
|
| 1664 | if (nw_info_handle == NULL)
|
| 1665 | {
|
q.huang | 81905ea | 2025-07-25 20:19:41 +0800 | [diff] [blame] | 1666 | LOGE(GSW_NW,"mbtk_info_handle_get fail");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 1667 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1668 | }
|
| 1669 |
|
| 1670 | char fplmn[256] = {0};
|
| 1671 | ret = mbtk_fplmn_get(nw_info_handle, fplmn);
|
| 1672 | if(ret != 0)
|
| 1673 | {
|
q.huang | 81905ea | 2025-07-25 20:19:41 +0800 | [diff] [blame] | 1674 | LOGE(GSW_NW,"mbtk_fplmn_get failed, ret is %d",ret);
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 1675 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1676 | }
|
| 1677 | fplmn_max_length = (strlen(fplmn)/6);
|
q.huang | 81905ea | 2025-07-25 20:19:41 +0800 | [diff] [blame] | 1678 | LOGE(GSW_NW,"fplmn = %s, fplmn_max_length = %d",fplmn,fplmn_max_length);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1679 |
|
q.huang | 66b7916 | 2025-06-27 17:45:34 +0800 | [diff] [blame] | 1680 | nw_init_flag = 1;
|
q.huang | 81905ea | 2025-07-25 20:19:41 +0800 | [diff] [blame] | 1681 | ret=gsw_start_all_thread();
|
q.huang | 66b7916 | 2025-06-27 17:45:34 +0800 | [diff] [blame] | 1682 |
|
q.huang | 81905ea | 2025-07-25 20:19:41 +0800 | [diff] [blame] | 1683 | if(ret != 0)
|
xy.he | c89938f | 2025-05-29 14:08:47 +0800 | [diff] [blame] | 1684 | {
|
q.huang | 81905ea | 2025-07-25 20:19:41 +0800 | [diff] [blame] | 1685 | nw_init_flag = 0;
|
| 1686 | LOGE(GSW_NW,"gsw_start_all_thread failed , ret is %d",ret);
|
| 1687 | return GSW_HAL_NORMAL_FAIL;
|
xy.he | c89938f | 2025-05-29 14:08:47 +0800 | [diff] [blame] | 1688 | }
|
| 1689 |
|
q.huang | 81905ea | 2025-07-25 20:19:41 +0800 | [diff] [blame] | 1690 | LOGE(GSW_NW,"gsw nw init suc");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1691 |
|
| 1692 | return GSW_HAL_SUCCESS;
|
| 1693 | }
|
| 1694 |
|
| 1695 |
|
| 1696 | /**
|
| 1697 | * @brief network sdk deinit
|
| 1698 | * @param
|
| 1699 | * @retval 0: success
|
| 1700 | * @retval other: fail
|
| 1701 | */
|
| 1702 | int gsw_nw_sdk_deinit(void)
|
| 1703 | {
|
| 1704 | int ret = -1;
|
| 1705 |
|
| 1706 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 1707 | {
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 1708 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1709 | }
|
| 1710 |
|
q.huang | 81905ea | 2025-07-25 20:19:41 +0800 | [diff] [blame] | 1711 | gsw_un_reg_all();// had better un-reg before thread close
|
| 1712 | gsw_close_all_thread();//in it, nw_init_flag=0 and cb unreg
|
| 1713 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1714 | ret = mbtk_info_handle_free(&nw_info_handle);
|
| 1715 | if(ret != GSW_HAL_SUCCESS)
|
| 1716 | {
|
q.huang | 81905ea | 2025-07-25 20:19:41 +0800 | [diff] [blame] | 1717 | LOGE(GSW_NW,"mbtk_info_handle_free fail");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 1718 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1719 | }
|
| 1720 |
|
| 1721 | dlclose(dlHandle_mbtk);
|
| 1722 | nw_info_handle = NULL;
|
q.huang | 81905ea | 2025-07-25 20:19:41 +0800 | [diff] [blame] | 1723 |
|
| 1724 | LOGE(GSW_NW,"gsw_nw_sdk_deinit suc");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1725 |
|
| 1726 | return GSW_HAL_SUCCESS;
|
| 1727 |
|
| 1728 | }
|
| 1729 |
|
| 1730 |
|
| 1731 | /**
|
| 1732 | * @brief get current network reg info
|
| 1733 | * @param [out] serving_info struct for network info
|
| 1734 | * include regstate ps_state opreator name mcc mcn etc
|
| 1735 | * @retval 0: success
|
| 1736 | * @retval other: fail
|
| 1737 | */
|
| 1738 | int gsw_get_nwinfo(GSW_NW_SERVING_INFO *serving_info)
|
| 1739 | {
|
| 1740 |
|
| 1741 | int ret = -1;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1742 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 1743 | {
|
q.huang | 238b22a | 2025-06-10 14:36:59 +0800 | [diff] [blame] | 1744 | printf("nw_sdk_deinit not init\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 1745 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1746 | }
|
| 1747 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1748 | LOGE(GSW_NW,"mbtk_net_reg_get start \n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1749 | //regstate
|
| 1750 | mbtk_net_reg_info_t reg;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1751 | ret = mbtk_net_reg_get(nw_info_handle, ®);
|
| 1752 | if(ret)
|
| 1753 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1754 | LOGE(GSW_NW,"mbtk_net_reg_get fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 1755 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1756 | }
|
| 1757 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1758 | LOGE(GSW_NW,"convert_cs_reg_state\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1759 | //cs_state
|
| 1760 | serving_info->reg_state = convert_reg_state(reg.call_state);
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1761 | LOGE(GSW_NW,"convert_ps_reg_state\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1762 | //ps_state
|
| 1763 | serving_info->ps_state = convert_reg_state(reg.data_state);
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1764 | LOGE(GSW_NW,"convert_rat_mode\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1765 | //reg_rat
|
| 1766 | serving_info->reg_rat = convert_net_mode(reg.type);
|
| 1767 | //srv_domain
|
| 1768 | if(serving_info->reg_state == GSW_NETWORK_REG_REGISTERED || serving_info->reg_state == GSW_NETWORK_REG_REGISTRATION_ROAMING)
|
| 1769 | {
|
| 1770 | if(serving_info->ps_state == GSW_NETWORK_REG_REGISTERED || serving_info->ps_state == GSW_NETWORK_REG_REGISTRATION_ROAMING)
|
| 1771 | {
|
| 1772 | serving_info->srv_domain = GSW_SRV_DOMAIN_CS_PS;
|
| 1773 | }
|
| 1774 |
|
| 1775 | else
|
| 1776 | {
|
| 1777 | serving_info->srv_domain = GSW_SRV_DOMAIN_CS_ONLY;
|
| 1778 | }
|
| 1779 | }
|
| 1780 |
|
| 1781 | else if (serving_info->ps_state == GSW_NETWORK_REG_REGISTERED || serving_info->ps_state == GSW_NETWORK_REG_REGISTRATION_ROAMING)
|
| 1782 | {
|
| 1783 | serving_info->srv_domain = GSW_SRV_DOMAIN_PS_ONLY;
|
| 1784 | }
|
| 1785 |
|
| 1786 | else
|
| 1787 | {
|
| 1788 | serving_info->srv_domain = GSW_SRV_DOMAIN_NO_SVC;
|
| 1789 | //if ps and cs is both not registed, reg_rat seted to GSW_NETWORK_RADIO_NO_SVC
|
| 1790 | serving_info->reg_rat = GSW_NETWORK_RADIO_NO_SVC;
|
| 1791 | }
|
| 1792 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1793 | LOGD(GSW_NW,"roaming_ind\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1794 | //roaming_ind
|
| 1795 | if(serving_info->ps_state == GSW_NETWORK_REG_REGISTRATION_ROAMING)
|
| 1796 | {
|
| 1797 | serving_info->roaming_ind = GSW_NETWORK_ROAMING_ON;
|
| 1798 | }
|
| 1799 | else
|
| 1800 | {
|
| 1801 | serving_info->roaming_ind = GSW_NETWORK_ROAMING_OFF;
|
| 1802 | }
|
| 1803 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1804 | LOGD(GSW_NW,"reject\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1805 | //reject
|
| 1806 | if(serving_info->ps_state == GSW_NETWORK_REG_REGISTRATION_DENIED || serving_info->reg_state == GSW_NETWORK_REG_REGISTRATION_DENIED)
|
| 1807 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1808 | LOGD(GSW_NW,"reject_callback\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1809 | gsw_reject_callback(serving_info->reg_rat,serving_info->srv_domain,99);
|
| 1810 | }
|
| 1811 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1812 | LOGD(GSW_NW,"reg_plmn / operator name\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1813 | //reg_plmn / operator name
|
| 1814 | mbtk_net_info_t net;
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1815 | LOGD(GSW_NW,"mbtk_net_sel_mode_get start \n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1816 | ret = mbtk_net_sel_mode_get(nw_info_handle, &net);
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1817 | LOGD(GSW_NW,"mbtk_net_sel_mode_get end \n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1818 | if(ret == 0 && net.plmn > 0)
|
| 1819 | {
|
| 1820 | int i = 0;
|
| 1821 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1822 | LOGD(GSW_NW,"start to find mcc");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1823 | while(i < ARRAY_SIZE(lynq_operator_mcc_mnc))
|
| 1824 | {
|
| 1825 | if(lynq_operator_mcc_mnc[i].lynq_mcc_mnc == net.plmn)
|
| 1826 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1827 | LOGD(GSW_NW,"find mcc\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1828 | break;
|
| 1829 | }
|
| 1830 | i++;
|
| 1831 | }
|
| 1832 |
|
| 1833 |
|
| 1834 | if(i == ARRAY_SIZE(lynq_operator_mcc_mnc))
|
| 1835 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1836 | LOGD(GSW_NW,"not find mcc");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1837 | strcpy(serving_info->operator_name, "unknown");
|
hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 1838 | sprintf(serving_info->reg_plmn, "%u", net.plmn);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1839 | }
|
| 1840 |
|
| 1841 | else
|
| 1842 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1843 | LOGD(GSW_NW,"find mcc\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1844 | strcpy(serving_info->operator_name, lynq_operator_mcc_mnc[i].lynq_operator_l);
|
hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 1845 | sprintf(serving_info->reg_plmn, "%u", net.plmn);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1846 | }
|
| 1847 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1848 | LOGE(GSW_NW,"operator_name = %s\n", serving_info->operator_name);
|
| 1849 | LOGE(GSW_NW,"reg_plmn = %s\n", serving_info->reg_plmn);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1850 | }
|
| 1851 |
|
| 1852 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1853 | LOGD(GSW_NW,"get cell id/tac/lac/sid/nid\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1854 | //cell id/tac/lac/sid/nid
|
| 1855 | mbtk_cell_type_enum cell_type;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1856 | list_node_t* cell_list = NULL;
|
| 1857 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1858 | LOGD(GSW_NW,"mbtk_cell_get start\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1859 | ret = mbtk_cell_get(nw_info_handle, &cell_type, &cell_list);
|
| 1860 | if(ret != 0 || cell_list == NULL)
|
| 1861 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1862 | LOGE(GSW_NW,"mbtk_cell_get fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 1863 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1864 | }
|
| 1865 | else
|
| 1866 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1867 | LOGE(GSW_NW,"mbtk_cell_get end,start to get node\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1868 | list_first(cell_list);
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1869 | LOGE(GSW_NW,"list_first end\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1870 | mbtk_cell_info_t* cell = (mbtk_cell_info_t*) list_next(cell_list);
|
| 1871 | if(cell)
|
| 1872 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1873 | LOGE(GSW_NW,"cell is not null,value2 = %u\n",cell->value2);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1874 | switch(cell_type)
|
| 1875 | {
|
| 1876 | case MBTK_CELL_TYPE_LTE:
|
| 1877 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1878 | LOGE(GSW_NW,"is lte\n");
|
| 1879 | //LOGE(GSW_NW,"LTE : tac=%x, PCI=%x, dlEuarfcn=%x, ulEuarfcn=%x, band=%x\n", cell->value1, cell->value2, cell->value3, cell->value4, cell->value5);
|
| 1880 | LOGE(GSW_NW,"LTE : tac=%d, PCI=%d, dlEuarfcn=%d, ulEuarfcn=%d, band=%d\n", cell->value1, cell->value2, cell->value3, cell->value4, cell->value5);
|
hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 1881 | snprintf(serving_info->tac,sizeof(serving_info->tac),"%u",cell->value1);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1882 | strcpy(serving_info->lac,"");
|
hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 1883 | snprintf(serving_info->cell_id,sizeof(serving_info->cell_id),"%u",cell->value10);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1884 | break;
|
| 1885 | }
|
| 1886 |
|
| 1887 | case MBTK_CELL_TYPE_GSM:
|
| 1888 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1889 | LOGE(GSW_NW,"is gsm\n");
|
| 1890 | LOGE(GSW_NW,"GSM : lac=%d, ci=%d, arfcn=%d, bsic=%d\n", cell->value1, cell->value2, cell->value3, cell->value4);
|
hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 1891 | sprintf(serving_info->lac,"%u",cell->value1);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1892 | memset(serving_info->tac,0,sizeof(serving_info->tac));
|
hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 1893 | sprintf(serving_info->cell_id,"%u",cell->value2);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1894 | break;
|
| 1895 | }
|
| 1896 | case MBTK_CELL_TYPE_UMTS:
|
| 1897 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1898 | LOGE(GSW_NW,"is wcdma\n");
|
| 1899 | LOGE(GSW_NW,"UMTS : lac=%d, ci=%d, arfcn=%d\n", cell->value1, cell->value2, cell->value3);
|
hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 1900 | sprintf(serving_info->lac,"%u",cell->value1);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1901 | memset(serving_info->tac,0,sizeof(serving_info->tac));
|
hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 1902 | sprintf(serving_info->cell_id,"%u",cell->value2);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1903 | break;
|
| 1904 | }
|
| 1905 |
|
| 1906 | default:
|
| 1907 | break;
|
| 1908 | }
|
| 1909 | }
|
| 1910 | else
|
| 1911 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1912 | LOGE(GSW_NW,"cell is null\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1913 | }
|
| 1914 | }
|
| 1915 |
|
| 1916 | //not support now
|
| 1917 | serving_info->sid = 0;
|
| 1918 | serving_info->nid = 0;
|
| 1919 |
|
| 1920 | return GSW_HAL_SUCCESS;
|
| 1921 | }
|
| 1922 |
|
| 1923 |
|
| 1924 | /**
|
| 1925 | * @brief get current network type
|
| 1926 | * @param [out] netype as GSW_NW_RADIO_ACCESS_TECH_E type
|
| 1927 | * @retval 0: success
|
| 1928 | * @retval other: fail
|
| 1929 | */
|
hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 1930 | int gsw_get_netype(int32_t *netype)
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1931 | {
|
| 1932 | int ret = -1;
|
| 1933 |
|
| 1934 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 1935 | {
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 1936 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1937 | }
|
| 1938 |
|
| 1939 | //regstate
|
| 1940 | mbtk_net_reg_info_t reg;
|
| 1941 | ret = mbtk_net_reg_get(nw_info_handle, ®);
|
| 1942 | if(ret)
|
| 1943 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1944 | LOGE(GSW_NW,"mbtk_net_reg_get fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 1945 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1946 | }
|
| 1947 |
|
| 1948 | if(reg.data_state == MBTK_NET_REG_STATE_HOME || reg.data_state == MBTK_NET_REG_STATE_ROAMING)
|
| 1949 | {
|
| 1950 | *netype = convert_net_mode(reg.type);
|
| 1951 | }
|
| 1952 | else
|
| 1953 | {
|
| 1954 | *netype = GSW_NETWORK_RADIO_NO_SVC;
|
| 1955 | }
|
| 1956 |
|
| 1957 | return GSW_HAL_SUCCESS;
|
| 1958 | }
|
| 1959 |
|
| 1960 |
|
| 1961 | /**
|
| 1962 | * @brief get radio opmode, as open and close airplane mode
|
| 1963 | * @param [out] op_mode 1 is radio on, 0 is radio off
|
| 1964 | * @retval 0: success
|
| 1965 | * @retval other: fail
|
| 1966 | */
|
| 1967 | int gsw_get_opmode(int *op_mode)
|
| 1968 | {
|
| 1969 | int tmp_rf = -1;
|
| 1970 | int ret = -1;
|
| 1971 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 1972 | {
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 1973 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1974 | }
|
| 1975 |
|
| 1976 | ret = mbtk_get_modem_fun(nw_info_handle, &tmp_rf);
|
| 1977 | if (ret != 0)
|
| 1978 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 1979 | LOGE(GSW_NW,"mbtk_get_modem_fun fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 1980 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1981 | }
|
| 1982 | if(tmp_rf == LYNQ_AIR_CFUN_MODE_OFF)
|
| 1983 | {
|
| 1984 | *op_mode = GSW_OP_MODE_LPM;
|
| 1985 | }
|
| 1986 |
|
| 1987 | if(tmp_rf == LYNQ_AIR_PLANE_MODE_ON)
|
| 1988 | {
|
| 1989 | *op_mode = GSW_OP_MODE_OFFLINE;
|
| 1990 | }
|
| 1991 |
|
| 1992 | if(tmp_rf == LYNQ_AIR_PLANE_MODE_OFF)
|
| 1993 | {
|
| 1994 | *op_mode = GSW_OP_MODE_ONLINE;
|
| 1995 | }
|
| 1996 |
|
| 1997 | return GSW_HAL_SUCCESS;
|
| 1998 | }
|
| 1999 |
|
| 2000 |
|
| 2001 |
|
| 2002 | /**
|
| 2003 | * @brief set radio opmode, as open and close airplane mode
|
| 2004 | * @param [in] op_mode 1 is radio on, 0 is radio off
|
| 2005 | * @retval 0: success
|
| 2006 | * @retval other: fail
|
| 2007 | */
|
hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 2008 | int gsw_set_opmode(int32_t op_mode)
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2009 | {
|
| 2010 | mbtk_modem_info_t info;
|
| 2011 | int rf_mode = -1;
|
| 2012 | int ret = -1;
|
| 2013 |
|
| 2014 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 2015 | {
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2016 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2017 | }
|
| 2018 |
|
| 2019 | if(op_mode == GSW_OP_MODE_LPM)
|
| 2020 | {
|
| 2021 | rf_mode = LYNQ_AIR_CFUN_MODE_OFF;
|
| 2022 | }
|
| 2023 |
|
| 2024 | if(op_mode == GSW_OP_MODE_ONLINE)
|
| 2025 | {
|
| 2026 | rf_mode = LYNQ_AIR_PLANE_MODE_OFF;
|
| 2027 | }
|
| 2028 |
|
| 2029 | if(op_mode == GSW_OP_MODE_OFFLINE)
|
| 2030 | {
|
| 2031 | rf_mode = LYNQ_AIR_PLANE_MODE_ON;
|
| 2032 | }
|
| 2033 |
|
| 2034 | if (rf_mode != LYNQ_AIR_PLANE_MODE_ON && rf_mode != LYNQ_AIR_PLANE_MODE_OFF && rf_mode != LYNQ_AIR_CFUN_MODE_OFF)
|
| 2035 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2036 | LOGE(GSW_NW,"Input mode is error!\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2037 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2038 | }
|
| 2039 |
|
| 2040 | info.fun = rf_mode;
|
| 2041 | info.rst = 0;
|
| 2042 | ret = mbtk_set_modem_fun(nw_info_handle, &info);
|
| 2043 | if (ret != 0)
|
| 2044 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2045 | LOGE(GSW_NW,"gsw_set_opmode fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2046 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2047 | }
|
| 2048 |
|
| 2049 | return GSW_HAL_SUCCESS;
|
| 2050 |
|
| 2051 | }
|
| 2052 |
|
| 2053 |
|
| 2054 | /**
|
| 2055 | * @brief get network mode preference of mdm search network scale
|
| 2056 | * @param [out] mode_pref net_work pref mode:
|
| 2057 | * enum prefer_mode
|
| 2058 | * @retval 0: success
|
| 2059 | * @retval other: fail
|
| 2060 | */
|
hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 2061 | int gsw_get_mode_preference(int32_t *mode_pref)
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2062 | {
|
| 2063 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 2064 | {
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2065 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2066 | }
|
| 2067 |
|
| 2068 | int ret = -1;
|
| 2069 | mbtk_band_info_t band;
|
| 2070 | memset(&band, 0, sizeof(mbtk_band_info_t));
|
| 2071 |
|
| 2072 | ret = mbtk_current_band_get(nw_info_handle, &band);
|
| 2073 | if(ret != 0)
|
| 2074 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2075 | LOGE(GSW_NW,"mbtk_current_band_get fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2076 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2077 | }
|
| 2078 |
|
| 2079 | *mode_pref = convert_gsw_net_config(band.net_pref);
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2080 | LOGE(GSW_NW,"band.net_pref = %d\n", *mode_pref);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2081 | if(*mode_pref <= 0)
|
| 2082 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2083 | LOGE(GSW_NW,"no support mode\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2084 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2085 | }
|
| 2086 | return GSW_HAL_SUCCESS;
|
| 2087 |
|
| 2088 |
|
| 2089 | }
|
| 2090 |
|
| 2091 | /**
|
| 2092 | * @brief set network mode preference of mdm search network scale
|
| 2093 | * @param [in] mode_pref net_work pref mode:
|
| 2094 | * enum prefer_mode
|
| 2095 | * @retval 0: success
|
| 2096 | * @retval other: fail
|
| 2097 | */
|
hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 2098 | int gsw_set_mode_preference(int32_t mode_pref)
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2099 | {
|
| 2100 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 2101 | {
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2102 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2103 | }
|
| 2104 |
|
| 2105 | int ret = -1;
|
| 2106 |
|
| 2107 | mbtk_band_info_t band;
|
| 2108 | memset(&band, 0, sizeof(mbtk_band_info_t));
|
| 2109 |
|
| 2110 | band.net_pref = convert_mbtk_net_config(mode_pref);
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2111 | LOGE(GSW_NW,"band.net_pref = %d\n", band.net_pref);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2112 |
|
| 2113 | if(band.net_pref < 0)
|
| 2114 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2115 | LOGE(GSW_NW,"no support mode\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2116 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2117 | }
|
| 2118 |
|
| 2119 | ret = mbtk_current_band_set(nw_info_handle, &band);
|
| 2120 | if(ret != 0)
|
| 2121 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2122 | LOGE(GSW_NW,"mbtk_current_band_set fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2123 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2124 | }
|
| 2125 |
|
| 2126 | return GSW_HAL_SUCCESS;
|
| 2127 | }
|
| 2128 |
|
| 2129 | /**
|
| 2130 | * @brief get signal csq value
|
| 2131 | * @param [out] csq_value csq of signalstrengh 0 - 31, 99 invalid
|
| 2132 | * @retval 0: success
|
| 2133 | * @retval other: fail
|
| 2134 | */
|
hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 2135 | int gsw_get_sig_info(int32_t *csq_value)
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2136 | {
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2137 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 2138 | {
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2139 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2140 | }
|
| 2141 |
|
q.huang | daa16d4 | 2025-07-03 14:32:48 +0800 | [diff] [blame] | 2142 | mbtk_signal_info_t signal;
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 2143 | int ret = mbtk_net_signal_get(nw_info_handle, &signal);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2144 | if(ret != 0)
|
| 2145 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2146 | LOGE(GSW_NW,"mbtk_net_signal_get fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2147 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2148 | }
|
| 2149 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2150 | LOGD(GSW_NW,"signal.type=%d\n", signal.type);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2151 | switch(signal.type)
|
| 2152 | {
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 2153 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2154 | case MBTK_RADIO_TECH_E_UTRAN:
|
| 2155 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2156 | LOGD(GSW_NW,"lte rsrp = %d dbm",signal.rsrp-141);
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 2157 | *csq_value = rsrpToLevel(signal.rsrp-141);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2158 | break;
|
| 2159 | }
|
| 2160 | case MBTK_RADIO_TECH_UTRAN:
|
| 2161 | case MBTK_RADIO_TECH_UTRAN_HSDPA:
|
| 2162 | case MBTK_RADIO_TECH_UTRAN_HSUPA:
|
| 2163 | case MBTK_RADIO_TECH_UTRAN_HSDPA_HSUPA:
|
| 2164 | case MBTK_RADIO_TECH_UTRAN_HSPA:
|
| 2165 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2166 | LOGD(GSW_NW,"w rscp = %d dbm",signal.rscp-121);
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 2167 | *csq_value = rscpToLevel(signal.rscp-121);
|
| 2168 | break;
|
| 2169 | }
|
| 2170 | case MBTK_RADIO_TECH_GSM:
|
| 2171 | case MBTK_RADIO_TECH_GSM_COMPACT:
|
| 2172 | case MBTK_RADIO_TECH_GSM_EGPRS:
|
| 2173 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2174 | LOGD(GSW_NW,"gsm rxlev = %d (0-63)",signal.rxlev);
|
q.huang | 861c07d | 2025-06-24 16:54:58 +0800 | [diff] [blame] | 2175 | *csq_value = rxlevToLevel(signal.rxlev);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2176 | break;
|
| 2177 | }
|
| 2178 | default:
|
| 2179 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2180 | LOGE(GSW_NW,"[%s] unknown reg type.[%d]", __func__, signal.type);
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2181 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2182 | }
|
| 2183 | }
|
| 2184 | return GSW_HAL_SUCCESS;
|
| 2185 | }
|
| 2186 |
|
| 2187 | /**
|
| 2188 | * @brief set nework power mode, for tcam enter standby or exit standby
|
| 2189 | * @param [in] mode TRUE(1) when enter standby, FALSE(0) after wake up
|
| 2190 | * @retval 0: success
|
| 2191 | * @retval other: fail
|
| 2192 | */
|
lichengzhang | 0ba5896 | 2025-07-15 17:39:03 +0800 | [diff] [blame] | 2193 |
|
| 2194 | int gsw_nw_power_mode = 0;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2195 | int gsw_network_set_power_mode(char mode)
|
| 2196 | {
|
lichengzhang | 640b4f8 | 2025-07-21 16:19:33 +0800 | [diff] [blame] | 2197 | int ret = -1;
|
| 2198 | if (nw_init_flag == 0)//nw_info_handle == NULL Don't need
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2199 | {
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2200 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2201 | }
|
| 2202 |
|
| 2203 | if(mode != 0 && mode != 1)
|
| 2204 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2205 | LOGE(GSW_NW,"Input mode is error!\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2206 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2207 | }
|
| 2208 |
|
| 2209 | if(mode == 1)
|
lichengzhang | 0ba5896 | 2025-07-15 17:39:03 +0800 | [diff] [blame] | 2210 | gsw_nw_power_mode = 3;
|
| 2211 | else
|
| 2212 | gsw_nw_power_mode = 1;
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2213 |
|
| 2214 | LOGE(GSW_NW,"mode is %d\n",gsw_nw_power_mode);
|
lichengzhang | 640b4f8 | 2025-07-21 16:19:33 +0800 | [diff] [blame] | 2215 | ret = mbtk_wakeup_state_set(nw_info_handle, gsw_nw_power_mode);
|
| 2216 | if(ret != 0)
|
| 2217 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2218 | LOGE(GSW_NW,"mbtk_wakeup_state_set fail\n");
|
lichengzhang | 640b4f8 | 2025-07-21 16:19:33 +0800 | [diff] [blame] | 2219 | return GSW_HAL_NORMAL_FAIL;
|
| 2220 | }
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2221 |
|
| 2222 | return GSW_HAL_SUCCESS;
|
| 2223 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2224 | }
|
| 2225 |
|
| 2226 | /**
|
| 2227 | * @brief convert rsrp rscp rssi to csq value.
|
| 2228 | * @param [in] netType signal radio tech 2 means 2G 3 mens 3G,4 is 4G,5 is 5G
|
| 2229 | * @param [in] sigvalue input signal_strength for different nettype
|
| 2230 | * rsrp for 4G/5G, rscp for 3G, rssi for 2G
|
| 2231 |
|
| 2232 | * @retval csq
|
| 2233 | * @retval other: fail
|
| 2234 | */
|
hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 2235 | int gsw_sigInfo_to_csq(int32_t netType, int32_t sigValue)
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2236 | {
|
q.huang | 238b22a | 2025-06-10 14:36:59 +0800 | [diff] [blame] | 2237 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 2238 | {
|
| 2239 | return GSW_HAL_NORMAL_FAIL;
|
| 2240 | }
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2241 | switch(netType)
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 2242 | {
|
| 2243 | case 4:
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2244 | {
|
q.huang | 2dbc0bc | 2025-08-06 10:36:24 +0800 | [diff] [blame] | 2245 | return rsrpToLevel(-sigValue);
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 2246 | }
|
| 2247 | case 3: //WCDMA
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2248 | {
|
q.huang | 2dbc0bc | 2025-08-06 10:36:24 +0800 | [diff] [blame] | 2249 | return rscpToLevel(-sigValue);
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 2250 | }
|
| 2251 | case 2: //GSM
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2252 | {
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 2253 | return sigValue;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2254 | }
|
| 2255 |
|
| 2256 | default:
|
| 2257 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2258 | LOGE(GSW_NW,"parameter error\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2259 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2260 | }
|
| 2261 | }
|
| 2262 | }
|
| 2263 |
|
| 2264 | /*
|
| 2265 | * @brief get mobile operator name
|
| 2266 | @param [out] nw_operator_name_infos get the long and short operator name info
|
| 2267 | @retval 0: success
|
| 2268 | @retval 0: other: fail
|
| 2269 | */
|
| 2270 | int gsw_get_mobile_operator_name(gsw_mobile_operator_name *nw_operator_name_infos)
|
| 2271 | {
|
| 2272 | char OperatorFN[128];
|
| 2273 | char OperatorSH[128];
|
hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 2274 | char temp[12];
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2275 | mbtk_net_info_t net;
|
| 2276 |
|
| 2277 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 2278 | {
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2279 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2280 | }
|
| 2281 |
|
| 2282 | if(!mbtk_net_sel_mode_get(nw_info_handle, &net) && net.plmn > 0)
|
| 2283 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2284 | LOGE(GSW_NW,"Net : %d, %d, %d\n", net.net_sel_mode, net.net_type, net.plmn);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2285 | int i = 0;
|
| 2286 | while(i < ARRAY_SIZE(lynq_operator_mcc_mnc))
|
| 2287 | {
|
| 2288 | if(lynq_operator_mcc_mnc[i].lynq_mcc_mnc == net.plmn)
|
| 2289 | break;
|
| 2290 | i++;
|
| 2291 | }
|
| 2292 |
|
| 2293 | if(i == ARRAY_SIZE(lynq_operator_mcc_mnc)) // No found mcc&mnc
|
| 2294 | {
|
| 2295 | strcpy(OperatorFN, "UNKNOWN");
|
| 2296 | strcpy(OperatorSH, "UNKNOWN");
|
| 2297 | }
|
| 2298 | else
|
| 2299 | {
|
| 2300 | strcpy(OperatorFN, lynq_operator_mcc_mnc[i].lynq_operator_l);
|
| 2301 | strcpy(OperatorSH, lynq_operator_mcc_mnc[i].lynq_operator_s);
|
| 2302 |
|
q.huang | daa16d4 | 2025-07-03 14:32:48 +0800 | [diff] [blame] | 2303 |
|
hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 2304 | sprintf(temp, "%u", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)/100);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2305 | strncpy(nw_operator_name_infos->mcc, temp, strlen(temp));
|
| 2306 |
|
q.huang | daa16d4 | 2025-07-03 14:32:48 +0800 | [diff] [blame] | 2307 |
|
hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 2308 | sprintf(temp, "%u", (lynq_operator_mcc_mnc[i].lynq_mcc_mnc)%100);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2309 | strncpy(nw_operator_name_infos->mnc, temp, strlen(temp));
|
| 2310 | }
|
| 2311 |
|
| 2312 | memset(nw_operator_name_infos->long_eons,0,128);
|
| 2313 | memcpy(nw_operator_name_infos->long_eons,OperatorFN,strlen(OperatorFN));
|
| 2314 | memset(nw_operator_name_infos->short_eons,0,128);
|
| 2315 | memcpy(nw_operator_name_infos->short_eons,OperatorSH,strlen(OperatorSH));
|
| 2316 |
|
| 2317 | return GSW_HAL_SUCCESS;
|
| 2318 | }
|
| 2319 |
|
| 2320 | else
|
| 2321 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2322 | LOGE(GSW_NW,"mbtk_net_sel_mode_get fail\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2323 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2324 | }
|
| 2325 |
|
| 2326 | return GSW_HAL_SUCCESS;
|
| 2327 | }
|
| 2328 |
|
| 2329 |
|
| 2330 | /*
|
| 2331 | * @brief get current serving cell info
|
| 2332 | * @param cell_info: [out] struct for current cell info
|
| 2333 | * include earfcn mcc mnc pci psc tac lac etc.
|
| 2334 | * @return int: 0 is success, other failed
|
| 2335 | */
|
| 2336 | int gsw_get_cell_info(GSW_NW_CELL_INFO *cell_info)
|
| 2337 | {
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2338 |
|
| 2339 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 2340 | {
|
q.huang | 238b22a | 2025-06-10 14:36:59 +0800 | [diff] [blame] | 2341 | printf("nw_sdk_deinit not init\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2342 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2343 | }
|
| 2344 |
|
| 2345 | list_node_t* cell_list = NULL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2346 | mbtk_cell_type_enum type;
|
q.huang | 638d587 | 2025-06-21 13:44:43 +0800 | [diff] [blame] | 2347 | int ret = mbtk_cell_get(nw_info_handle, &type, &cell_list);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2348 | if(ret || cell_list == NULL) {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2349 | LOGE(GSW_NW,"mbtk_cell_get failed : %d\n", ret);
|
q.huang | 638d587 | 2025-06-21 13:44:43 +0800 | [diff] [blame] | 2350 | list_free(cell_list);
|
| 2351 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2352 | } else {
|
q.huang | 638d587 | 2025-06-21 13:44:43 +0800 | [diff] [blame] | 2353 | memset(cell_info,0,sizeof(GSW_NW_CELL_INFO));
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2354 | list_first(cell_list);
|
| 2355 | mbtk_cell_info_t* cell = (mbtk_cell_info_t*) list_next(cell_list);
|
| 2356 | if(cell) { // Current server cell.
|
| 2357 | switch(type)
|
| 2358 | {
|
| 2359 | case 0:
|
| 2360 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2361 | LOGD(GSW_NW,"GSM : lac=%d, ci=%d, arfcn=%d, bsic=%d\n", cell->value1, cell->value2, cell->value3, cell->value4);
|
q.huang | daa16d4 | 2025-07-03 14:32:48 +0800 | [diff] [blame] | 2362 | char gsm_temp[12];
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2363 |
|
| 2364 | cell_info->rat = GSW_NETWORK_RADIO_GSM;
|
| 2365 |
|
| 2366 | cell_info->mcc_valid = 1;
|
q.huang | 861c07d | 2025-06-24 16:54:58 +0800 | [diff] [blame] | 2367 | snprintf(gsm_temp, sizeof(gsm_temp) ,"%X", cell->value5);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2368 | strncpy(cell_info->mcc, gsm_temp, sizeof(cell_info->mcc));
|
| 2369 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2370 | cell_info->mnc_valid = 1;
|
q.huang | 861c07d | 2025-06-24 16:54:58 +0800 | [diff] [blame] | 2371 | snprintf(gsm_temp, sizeof(gsm_temp) ,"%X", cell->value6);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2372 | strncpy(cell_info->mnc, gsm_temp, sizeof(cell_info->mnc));
|
| 2373 |
|
| 2374 | cell_info->cell_id_valid = 1;
|
| 2375 | cell_info->cell_id = cell->value2;
|
| 2376 |
|
| 2377 | cell_info->lac_valid = 1;
|
| 2378 | cell_info->lac = cell->value1;
|
| 2379 |
|
| 2380 | cell_info->arfcn_valid = 1;
|
| 2381 | cell_info->arfcn = cell->value3;
|
q.huang | 861c07d | 2025-06-24 16:54:58 +0800 | [diff] [blame] | 2382 |
|
q.huang | 2dbc0bc | 2025-08-06 10:36:24 +0800 | [diff] [blame] | 2383 | cell_info->rssi=rxlevToLevel(cell->value7);
|
| 2384 | cell_info->rssi_valid = (cell_info->rssi!=INVALID_AT_SIGNAL_LEVEL);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2385 | break;
|
| 2386 | }
|
| 2387 |
|
| 2388 | case 1:
|
| 2389 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2390 | LOGD(GSW_NW,"UMTS : lac=%d, ci=%d, arfcn=%d\n", cell->value1, cell->value2, cell->value3);
|
q.huang | daa16d4 | 2025-07-03 14:32:48 +0800 | [diff] [blame] | 2391 | char wcdma_temp[12];
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2392 |
|
| 2393 | cell_info->rat = GSW_NETWORK_RADIO_UMTS;
|
| 2394 |
|
| 2395 | cell_info->mcc_valid = 1;
|
q.huang | 861c07d | 2025-06-24 16:54:58 +0800 | [diff] [blame] | 2396 | snprintf(wcdma_temp, sizeof(wcdma_temp) ,"%X", cell->value4);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2397 | strncpy(cell_info->mcc, wcdma_temp, sizeof(cell_info->mcc));
|
| 2398 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2399 | cell_info->mnc_valid = 1;
|
q.huang | 861c07d | 2025-06-24 16:54:58 +0800 | [diff] [blame] | 2400 | snprintf(wcdma_temp, sizeof(wcdma_temp) ,"%X", cell->value5);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2401 | strncpy(cell_info->mnc, wcdma_temp, sizeof(cell_info->mnc));
|
| 2402 |
|
| 2403 | cell_info->lac_valid = 1;
|
| 2404 | cell_info->lac = cell->value1;
|
| 2405 |
|
| 2406 | cell_info->cell_id_valid = 1;
|
| 2407 | cell_info->cell_id = cell->value2;
|
| 2408 |
|
| 2409 | cell_info->uarfcn_valid = 1;
|
| 2410 | cell_info->uarfcn = cell->value3;
|
| 2411 |
|
| 2412 | cell_info->psc_valid = 1;
|
| 2413 | cell_info->psc = cell->value6;
|
| 2414 | break;
|
| 2415 | }
|
| 2416 |
|
| 2417 | case 2:
|
| 2418 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2419 | LOGE(GSW_NW,"LTE : tac=%d, PCI=%d, dlEuarfcn=%d, ulEuarfcn=%d, band=%d\n", cell->value1, cell->value2, cell->value3, cell->value4, cell->value5);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2420 |
|
q.huang | daa16d4 | 2025-07-03 14:32:48 +0800 | [diff] [blame] | 2421 | char lte_temp[12];
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2422 | cell_info->rat = GSW_NETWORK_RADIO_LTE;
|
| 2423 |
|
| 2424 | cell_info->mcc_valid = 1;
|
| 2425 | snprintf(lte_temp, sizeof(lte_temp) ,"%X", cell->value6);
|
| 2426 | strncpy(cell_info->mcc, lte_temp, sizeof(cell_info->mcc));
|
| 2427 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2428 | cell_info->mnc_valid = 1;
|
| 2429 | snprintf(lte_temp, sizeof(lte_temp) ,"%X", cell->value7);
|
| 2430 | strncpy(cell_info->mnc, lte_temp, sizeof(cell_info->mnc));
|
| 2431 |
|
| 2432 | cell_info->tac_valid = 1;
|
| 2433 | cell_info->tac = cell->value1;
|
| 2434 |
|
| 2435 | cell_info->pci_valid = 1;
|
| 2436 | cell_info->pci = cell->value2;
|
| 2437 |
|
| 2438 | cell_info->earfcn_valid = 1;
|
| 2439 | cell_info->earfcn = cell->value3;
|
| 2440 |
|
| 2441 | cell_info->bler_valid = 1;
|
| 2442 | cell_info->bler = cell->value4;
|
| 2443 |
|
| 2444 | cell_info->band_valid = 1;
|
| 2445 | cell_info->band = cell->value5;
|
| 2446 |
|
q.huang | 638d587 | 2025-06-21 13:44:43 +0800 | [diff] [blame] | 2447 | cell_info->rssnr = sinr_convert_to_10_times_dB(cell->value11);
|
| 2448 | cell_info->rssnr_valid=(cell_info->rssnr!=INT_32_MAX);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2449 |
|
q.huang | 638d587 | 2025-06-21 13:44:43 +0800 | [diff] [blame] | 2450 | cell_info->lteMode_valid = 1;
|
| 2451 | cell_info->lteMode =(!(cell->value12));
|
| 2452 |
|
| 2453 |
|
| 2454 | cell_info->rsrp = rsrp_convert_to_minus_dBm(cell->value8);
|
| 2455 | cell_info->rsrp_valid = (cell_info->rsrp!=INT_32_MAX);
|
| 2456 |
|
| 2457 | cell_info->rsrq = rsrq_convert_to_minus_dB(cell->value9);
|
| 2458 | cell_info->rsrq_valid = (cell_info->rsrq!=INT_32_MAX);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2459 |
|
| 2460 | cell_info->cell_id_valid = 1;
|
| 2461 | cell_info->cell_id = cell->value10;
|
| 2462 |
|
| 2463 | break;
|
| 2464 | }
|
| 2465 |
|
| 2466 | default:
|
| 2467 | break;
|
| 2468 | }
|
| 2469 | }
|
q.huang | 638d587 | 2025-06-21 13:44:43 +0800 | [diff] [blame] | 2470 | int neibor_count = 0;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2471 | while ((cell = (mbtk_cell_info_t*) list_next(cell_list)) && neibor_count < 5)
|
| 2472 | {
|
| 2473 | switch(type)
|
| 2474 | {
|
| 2475 | //GSM
|
| 2476 | case 0:
|
| 2477 | {
|
| 2478 |
|
| 2479 | }
|
| 2480 | //WCDMA
|
| 2481 | case 1:
|
| 2482 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2483 | LOGE(GSW_NW,"CELL : lac=%d, ci=%d, arfcn=%d\n", cell->value1, cell->value2, cell->value3);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2484 |
|
| 2485 | //cell_info->ext_info[neibor_count]->lac = cell->value1;
|
| 2486 |
|
| 2487 | cell_info->ext_info[neibor_count].cell_id_valid = 1;
|
| 2488 | cell_info->ext_info[neibor_count].cell_id = cell->value2;
|
| 2489 |
|
| 2490 | cell_info->ext_info[neibor_count].arfcn_valid = 1;
|
| 2491 | cell_info->ext_info[neibor_count].arfcn = cell->value3;
|
| 2492 |
|
| 2493 | cell_info->ext_info[neibor_count].rat = cell_info->rat = GSW_NETWORK_RADIO_UMTS;
|
| 2494 |
|
| 2495 | neibor_count++;
|
| 2496 |
|
| 2497 | }
|
| 2498 | //LTE
|
| 2499 | case 2:
|
| 2500 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2501 | LOGE(GSW_NW,"CELL : phyCellId=%d, euArfcn=%d, rsrp=%d, rsrq=%d\n", cell->value1, cell->value2, cell->value3, cell->value4);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2502 | char lte_temp[12] = {0};
|
| 2503 | cell_info->ext_info[neibor_count].rat = GSW_NETWORK_RADIO_LTE;
|
| 2504 |
|
q.huang | daa16d4 | 2025-07-03 14:32:48 +0800 | [diff] [blame] | 2505 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2506 | cell_info->ext_info[neibor_count].pci = cell->value1;
|
| 2507 | cell_info->ext_info[neibor_count].pci_valid = 1;
|
| 2508 |
|
| 2509 | cell_info->ext_info[neibor_count].arfcn = cell->value2;
|
| 2510 | cell_info->ext_info[neibor_count].arfcn_valid = 1;
|
| 2511 |
|
q.huang | 638d587 | 2025-06-21 13:44:43 +0800 | [diff] [blame] | 2512 | cell_info->ext_info[neibor_count].rsrp = rsrp_convert_to_minus_dBm(cell->value3);
|
| 2513 | cell_info->ext_info[neibor_count].rsrp_valid = (cell_info->ext_info[neibor_count].rsrp!=INT_32_MAX);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2514 |
|
q.huang | 638d587 | 2025-06-21 13:44:43 +0800 | [diff] [blame] | 2515 | cell_info->ext_info[neibor_count].rsrq = rsrq_convert_to_minus_dB(cell->value4);
|
| 2516 | cell_info->ext_info[neibor_count].rsrq_valid = (cell_info->ext_info[neibor_count].rsrq!=INT_32_MAX);
|
| 2517 |
|
| 2518 | if(cell->value7!=INT_32_MAX)
|
| 2519 | {
|
| 2520 | cell_info->ext_info[neibor_count].cell_id = cell->value5;
|
| 2521 | cell_info->ext_info[neibor_count].cell_id_valid = 1;
|
| 2522 |
|
| 2523 | snprintf(lte_temp, sizeof(lte_temp) ,"%X", cell->value6);
|
| 2524 | strncpy(cell_info->ext_info[neibor_count].mcc, lte_temp, sizeof(cell_info->ext_info[neibor_count].mcc));
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2525 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2526 |
|
q.huang | 638d587 | 2025-06-21 13:44:43 +0800 | [diff] [blame] | 2527 | snprintf(lte_temp, sizeof(lte_temp) ,"%X", cell->value7);
|
| 2528 | strncpy(cell_info->ext_info[neibor_count].mnc, lte_temp, sizeof(cell_info->ext_info[neibor_count].mnc));
|
| 2529 |
|
| 2530 |
|
| 2531 | //value 8 is tac
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2532 |
|
q.huang | 638d587 | 2025-06-21 13:44:43 +0800 | [diff] [blame] | 2533 | cell_info->ext_info[neibor_count].band = cell->value9;
|
| 2534 | cell_info->ext_info[neibor_count].band_valid = 1;
|
q.huang | 638d587 | 2025-06-21 13:44:43 +0800 | [diff] [blame] | 2535 | }
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2536 |
|
| 2537 | neibor_count++;
|
| 2538 | }
|
| 2539 |
|
| 2540 | default:
|
| 2541 | break;
|
| 2542 | }
|
| 2543 | }
|
q.huang | 638d587 | 2025-06-21 13:44:43 +0800 | [diff] [blame] | 2544 | cell_info->ext_info_len=neibor_count;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2545 | }
|
| 2546 | list_free(cell_list);
|
| 2547 |
|
| 2548 | return GSW_HAL_SUCCESS;
|
| 2549 | }
|
| 2550 |
|
| 2551 | /*
|
| 2552 | * @brief set modem status event callback
|
| 2553 | @param [in] handle_ptr callback function address
|
| 2554 | @retval 0: success
|
| 2555 | @retval 0: other: fail
|
| 2556 | */
|
| 2557 | int gsw_reg_set_modem_status_event_callback(GSW_NW_ModemStateHandlePtr handle_ptr)
|
| 2558 | {
|
| 2559 |
|
| 2560 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 2561 | {
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2562 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2563 | }
|
| 2564 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2565 | if(handle_ptr == NULL)
|
| 2566 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2567 | LOGE(GSW_NW,"reg modem state cb, handle_ptr is NULL\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2568 | }
|
| 2569 |
|
| 2570 | modem_cb = handle_ptr;
|
| 2571 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2572 | return GSW_HAL_SUCCESS;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2573 | }
|
| 2574 |
|
| 2575 |
|
| 2576 | /*
|
| 2577 | * @brief get PLMNs from the FPLMN list
|
| 2578 | * @param [inout] plmn_list:
|
| 2579 | * @retval 0: success
|
| 2580 | * @retval other: fail
|
| 2581 | */
|
| 2582 | int gsw_get_forbidden_networks(gsw_nw_plmn_list_t *plmn_list)
|
| 2583 | {
|
| 2584 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 2585 | {
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2586 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2587 | }
|
| 2588 |
|
| 2589 | int ret = -1;
|
| 2590 | char fplmn[256] = {0};
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2591 | LOGE(GSW_NW,"mbtk_fplmn_get enter\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2592 | ret = mbtk_fplmn_get(nw_info_handle, fplmn);
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2593 | LOGE(GSW_NW,"mbtk_fplmn_get exit\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2594 | if(ret != 0)
|
| 2595 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2596 | LOGE(GSW_NW,"mbtk_fplmn_get failed : %d\n",ret);
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2597 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2598 | }
|
| 2599 |
|
| 2600 | update_fplmn_list(fplmn);
|
| 2601 | for(int i = 0; i < fplmn_index; i++)
|
| 2602 | {
|
| 2603 | if(strcmp(fplmn_array[i],"FFFFFF") == 0)
|
| 2604 | {
|
| 2605 | continue;
|
| 2606 | }
|
| 2607 | extract_mcc_mnc(fplmn_array[i], plmn_list->plmn_list[plmn_list->plmn_list_len].mcc, plmn_list->plmn_list[plmn_list->plmn_list_len].mnc);
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2608 | LOGE(GSW_NW,"mcc = %s, mnc = %s\n", plmn_list->plmn_list[plmn_list->plmn_list_len].mcc, plmn_list->plmn_list[plmn_list->plmn_list_len].mnc);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2609 | plmn_list->plmn_list_len++;
|
| 2610 | }
|
| 2611 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2612 | LOGE(GSW_NW,"fplmn = %s\n", fplmn);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2613 | return GSW_HAL_SUCCESS;
|
| 2614 | }
|
| 2615 |
|
| 2616 | /*
|
| 2617 | * @brief add PLMNs from the plmn_list to the FPLMN list
|
| 2618 | * @param [in] plmn_list:
|
| 2619 | * @retval 0: success
|
| 2620 | * @retval other: fail
|
| 2621 | */
|
| 2622 | int gsw_add_forbidden_networks(gsw_nw_plmn_list_t *plmn_list)
|
| 2623 | {
|
| 2624 |
|
| 2625 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 2626 | {
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2627 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2628 | }
|
| 2629 |
|
| 2630 | if(plmn_list->plmn_list_len >= fplmn_max_length)
|
| 2631 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2632 | LOGE(GSW_NW,"can't save all the plmn\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2633 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2634 | }
|
| 2635 |
|
| 2636 | int i = 0;
|
| 2637 | int index = -1;
|
| 2638 |
|
| 2639 | for(i = 0; i < plmn_list->plmn_list_len; i++)
|
| 2640 | {
|
| 2641 | index = check_index(plmn_list->plmn_list[i].mcc, plmn_list->plmn_list[i].mnc);
|
| 2642 |
|
| 2643 | if(index == -1)
|
| 2644 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2645 | LOGE(GSW_NW,"no this PLMN, add it\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2646 | if((fplmn_index + plmn_list->plmn_list_len) > fplmn_max_length)
|
| 2647 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2648 | LOGE(GSW_NW,"can't save all the plmn\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2649 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2650 | }
|
| 2651 |
|
| 2652 | else
|
| 2653 | {
|
| 2654 | memcpy(fplmn_array[fplmn_index], plmn_list->plmn_list[i].mcc, 3);
|
| 2655 | memcpy(fplmn_array[fplmn_index] + 3, plmn_list->plmn_list[i].mnc, 2);
|
| 2656 | fplmn_array[fplmn_index][5] = '\0';
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2657 | LOGE(GSW_NW,"fplmn_array[%d] = %s\n", fplmn_index, fplmn_array[fplmn_index]);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2658 | fplmn_index++;
|
| 2659 | }
|
| 2660 | }
|
| 2661 |
|
| 2662 | else
|
| 2663 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2664 | LOGE(GSW_NW,"already have this PLMN, don't add it\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2665 | }
|
| 2666 | }
|
| 2667 |
|
| 2668 | char fplmn_str[256] = {0};
|
| 2669 | convert_plmn_to_fplmn_str(fplmn_str);
|
| 2670 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2671 | LOGE(GSW_NW,"fplmn_str = %s\n", fplmn_str);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2672 |
|
| 2673 | int ret = mbtk_fplmn_set(nw_info_handle, fplmn_str);
|
| 2674 | if(ret != 0)
|
| 2675 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2676 | LOGE(GSW_NW,"mbtk_fplmn_set failed : %d\n",ret);
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2677 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2678 | }
|
| 2679 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2680 | LOGE(GSW_NW,"gsw_add_forbidden_networks exit\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2681 | return GSW_HAL_SUCCESS;
|
| 2682 | }
|
| 2683 |
|
| 2684 | /*
|
| 2685 | * @brief Remove PLMNs from the plmn_list from the FPLMN list
|
| 2686 | * @param [in] plmn_list:
|
| 2687 | * @retval 0: success
|
| 2688 | * @retval other: fail
|
| 2689 | */
|
| 2690 | int gsw_remove_forbidden_networks(gsw_nw_plmn_list_t *plmn_list)
|
| 2691 | {
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2692 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 2693 | {
|
q.huang | fa0a0a3 | 2025-06-12 17:07:23 +0800 | [diff] [blame] | 2694 | printf("nw sdk has not init\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2695 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2696 | }
|
| 2697 |
|
| 2698 | int i = 0;
|
| 2699 | int index = -1;
|
| 2700 |
|
| 2701 | for(i = 0; i < plmn_list->plmn_list_len; i++)
|
| 2702 | {
|
| 2703 | index = check_index(plmn_list->plmn_list[i].mcc, plmn_list->plmn_list[i].mnc);
|
| 2704 | if(index != -1)
|
| 2705 | {
|
| 2706 | remove_fplmn(index);
|
| 2707 | }
|
| 2708 | else
|
| 2709 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2710 | LOGE(GSW_NW,"no this PLMN, can't remove it\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2711 | }
|
| 2712 | }
|
| 2713 |
|
| 2714 | for(i = 0; i < fplmn_index; i++)
|
| 2715 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2716 | LOGE(GSW_NW,"fplmn_array[%d] = %s\n", i, fplmn_array[i]);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2717 | }
|
| 2718 |
|
| 2719 | char fplmn_str[256] = {0};
|
| 2720 | convert_plmn_to_fplmn_str(fplmn_str);
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2721 | LOGE(GSW_NW,"fplmn_str = %s\n", fplmn_str);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2722 |
|
| 2723 | int ret = mbtk_fplmn_set(nw_info_handle, fplmn_str);
|
| 2724 | if(ret != 0)
|
| 2725 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2726 | LOGE(GSW_NW,"mbtk_fplmn_set failed : %d\n",ret);
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2727 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2728 | }
|
| 2729 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2730 | LOGE(GSW_NW,"gsw_remove_forbidden_networks exit\n");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2731 | return GSW_HAL_SUCCESS;
|
| 2732 | }
|
| 2733 |
|
| 2734 | /*
|
| 2735 | * @brief clear FPLMN list
|
| 2736 | * @param
|
| 2737 | * @retval 0: success
|
| 2738 | * @retval other: fail
|
| 2739 | */
|
| 2740 | int gsw_clear_forbidden_networks(void)
|
| 2741 | {
|
| 2742 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 2743 | {
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2744 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2745 | }
|
| 2746 |
|
| 2747 | char fplmn_str[FPLMN_STRING_LENGTH+1];
|
| 2748 | memset(fplmn_str, 'F', (6 * fplmn_max_length));
|
| 2749 | fplmn_str[(6 * fplmn_max_length)] = '\0';
|
| 2750 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2751 | LOGE(GSW_NW,"%s\n", fplmn_str);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2752 | int ret = mbtk_fplmn_set(nw_info_handle, fplmn_str);
|
| 2753 | if(ret != 0)
|
| 2754 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2755 | LOGE(GSW_NW,"mbtk_fplmn_set failed : %d\n",ret);
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2756 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2757 | }
|
| 2758 |
|
| 2759 | return GSW_HAL_SUCCESS;
|
| 2760 | }
|
| 2761 |
|
| 2762 | /*
|
| 2763 | * @brief get oos config
|
| 2764 | * @param [in] oos_config
|
| 2765 | * @retval 0: success
|
| 2766 | * @retval other: fail
|
| 2767 | */
|
| 2768 | int gsw_oos_config_get(GSW_NW_OOS_CONFIG_INFO_T *pt_info)
|
| 2769 | {
|
| 2770 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 2771 | {
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2772 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2773 | }
|
| 2774 |
|
| 2775 | if(pt_info == NULL)
|
| 2776 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2777 | LOGE(GSW_NW,"pt_info is null\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2778 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2779 | }
|
| 2780 |
|
| 2781 | int ret = -1;
|
| 2782 |
|
| 2783 | mbtk_oos_info oos_info;
|
| 2784 | memset(&oos_info, 0x00, sizeof(mbtk_oos_info));
|
| 2785 |
|
| 2786 | ret = mbtk_oos_get(nw_info_handle, &oos_info);
|
| 2787 | if(ret != 0)
|
| 2788 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2789 | LOGE(GSW_NW,"mbtk_oos_get failed : %d\n",ret);
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2790 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2791 | }
|
| 2792 |
|
| 2793 | if(oos_info.mode == 0)
|
| 2794 | {
|
| 2795 | pt_info->t_min = 0;
|
| 2796 | pt_info->t_step = 0;
|
| 2797 | pt_info->t_max = 0;
|
| 2798 | }
|
| 2799 |
|
| 2800 | else
|
| 2801 | {
|
| 2802 | pt_info->t_min = (int)oos_info.oosPhase[0];
|
| 2803 | pt_info->t_step = (int)oos_info.oosPhase[1];
|
| 2804 | pt_info->t_max = (int)oos_info.oosPhase[2];
|
| 2805 | }
|
| 2806 |
|
| 2807 | return GSW_HAL_SUCCESS;
|
| 2808 | }
|
| 2809 |
|
| 2810 |
|
| 2811 | /*
|
| 2812 | * @brief set oos config
|
| 2813 | * @param [in] oos_config
|
| 2814 | * @retval 0: success
|
| 2815 | * @retval other: fail
|
| 2816 | */
|
| 2817 | int gsw_oos_config_set(GSW_NW_OOS_CONFIG_INFO_T *pt_info)
|
| 2818 | {
|
| 2819 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 2820 | {
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2821 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2822 | }
|
| 2823 |
|
| 2824 | if(pt_info == NULL)
|
| 2825 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2826 | LOGE(GSW_NW,"pt_info is null\n");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2827 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2828 | }
|
| 2829 |
|
| 2830 | int ret = -1;
|
| 2831 | mbtk_oos_info oos_info;
|
| 2832 | memset(&oos_info, 0x00, sizeof(mbtk_oos_info));
|
| 2833 |
|
| 2834 | if (pt_info->t_min < 0 || pt_info->t_step < 0 || pt_info->t_max < 0)
|
| 2835 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2836 | LOGE(GSW_NW,"gsw_oos_config_set set time < 0 ");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2837 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2838 | }
|
| 2839 | else if ((pt_info->t_min > 0 && pt_info->t_min <= 255) && pt_info->t_step == 0 && pt_info->t_max == 0)
|
| 2840 | {
|
| 2841 | oos_info.mode = 1;
|
| 2842 | oos_info.oosPhase[0] = pt_info->t_min;
|
| 2843 | }
|
| 2844 | else if ((pt_info->t_min > 0 && pt_info->t_min <= 255) && (pt_info->t_step > 0 && pt_info->t_step <= 255) && pt_info->t_max == 0)
|
| 2845 | {
|
| 2846 | oos_info.mode = 1;
|
| 2847 | oos_info.oosPhase[0] = pt_info->t_min;
|
| 2848 | oos_info.oosPhase[1] = pt_info->t_step;
|
| 2849 | }
|
| 2850 | else if ((pt_info->t_min > 0 && pt_info->t_min <= 255) && (pt_info->t_step > 0 && pt_info->t_step <= 255) && (pt_info->t_max > 0 && pt_info->t_max <= 255))
|
| 2851 | {
|
| 2852 | oos_info.mode = 1;
|
| 2853 | oos_info.oosPhase[0] = pt_info->t_min;
|
| 2854 | oos_info.oosPhase[1] = pt_info->t_step;
|
| 2855 | oos_info.oosPhase[2] = pt_info->t_max;
|
| 2856 | }
|
| 2857 | else if (pt_info->t_min == 0 && pt_info->t_step == 0 && pt_info->t_max == 0)
|
| 2858 | {
|
| 2859 | oos_info.mode = 0;
|
| 2860 | }
|
| 2861 | else
|
| 2862 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2863 | LOGE(GSW_NW,"gsw_oos_config_set set Format err");
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2864 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2865 | }
|
| 2866 |
|
| 2867 | ret = mbtk_oos_set(nw_info_handle, &oos_info);
|
| 2868 | if(ret != 0)
|
| 2869 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2870 | LOGE(GSW_NW,"mbtk_oos_set failed : %d\n",ret);
|
xy.he | b41615b | 2025-05-28 16:33:20 +0800 | [diff] [blame] | 2871 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2872 | }
|
| 2873 |
|
| 2874 | return GSW_HAL_SUCCESS;
|
| 2875 | }
|
| 2876 |
|
q.huang | 238b22a | 2025-06-10 14:36:59 +0800 | [diff] [blame] | 2877 | /**
|
| 2878 | * @brief get imei function
|
| 2879 | * @param [in] len imei length,max is 20
|
| 2880 | * @param [out] imei return imei from this func
|
| 2881 | * @retval 0: success
|
| 2882 | * @retval other: fail
|
| 2883 | */
|
| 2884 | int gsw_get_imei(int len, char *imei)
|
| 2885 | {
|
q.huang | 238b22a | 2025-06-10 14:36:59 +0800 | [diff] [blame] | 2886 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 2887 | {
|
| 2888 | printf("nw sdk has been deinit\n");
|
| 2889 | return GSW_HAL_NORMAL_FAIL;
|
| 2890 | }
|
| 2891 |
|
| 2892 | if(imei == NULL)
|
| 2893 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2894 | LOGE(GSW_NW,"imei is NULL.");
|
q.huang | 238b22a | 2025-06-10 14:36:59 +0800 | [diff] [blame] | 2895 | return GSW_HAL_ARG_INVALID;
|
| 2896 | }
|
| 2897 |
|
| 2898 | if(len < GSW_IMEI_LENGTH)
|
| 2899 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2900 | LOGE(GSW_NW,"imei len is too short,len = %d\n", len);
|
q.huang | 238b22a | 2025-06-10 14:36:59 +0800 | [diff] [blame] | 2901 | return GSW_HAL_NORMAL_FAIL;
|
| 2902 | }
|
| 2903 |
|
q.huang | 861c07d | 2025-06-24 16:54:58 +0800 | [diff] [blame] | 2904 | int ret = mbtk_imei_get(nw_info_handle, (void *)imei);
|
q.huang | 238b22a | 2025-06-10 14:36:59 +0800 | [diff] [blame] | 2905 | if(ret != MBTK_ERR_OK)
|
| 2906 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2907 | LOGE(GSW_NW,"[gsw_nw] mbtk_imei_get fail [err = %d].", ret);
|
q.huang | 238b22a | 2025-06-10 14:36:59 +0800 | [diff] [blame] | 2908 | return GSW_HAL_NORMAL_FAIL;
|
| 2909 | }
|
| 2910 |
|
| 2911 | return GSW_HAL_SUCCESS;
|
| 2912 | }
|
| 2913 |
|
| 2914 | /**
|
| 2915 | * @brief reset modem stack only, notice: after use this method, all ril sdk
|
| 2916 | * need restart by app, means network, sim, sms, data need deinit then init!
|
| 2917 | * @param
|
| 2918 | * @retval 0: success
|
| 2919 | * @retval other: fail
|
| 2920 | */
|
| 2921 | int gsw_reset_modem(void)
|
| 2922 | {
|
| 2923 | int ret = -1;
|
| 2924 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 2925 | {
|
| 2926 | printf("nw sdk has been deinit\n");
|
| 2927 | return GSW_HAL_NORMAL_FAIL;
|
| 2928 | }
|
| 2929 | mbtk_modem_info_t info;
|
| 2930 | info.fun = MBTK_DEV_MODEM_MIN_FUN;
|
| 2931 | info.rst = 0;
|
| 2932 |
|
| 2933 | ret = mbtk_set_modem_fun(nw_info_handle, &info);
|
| 2934 | if(ret)
|
| 2935 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2936 | LOGE(GSW_NW,"[gsw_nw] mbtk_set_modem_fun 0 fail [err = %d].", ret);
|
q.huang | 238b22a | 2025-06-10 14:36:59 +0800 | [diff] [blame] | 2937 | return GSW_HAL_NORMAL_FAIL;
|
| 2938 | }
|
| 2939 |
|
| 2940 | sleep(1);
|
| 2941 |
|
| 2942 | info.fun = MBTK_DEV_MODEM_FULL_FUN;
|
| 2943 | ret = mbtk_set_modem_fun(nw_info_handle, &info);
|
| 2944 | if(ret)
|
| 2945 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2946 | LOGE(GSW_NW,"[gsw_nw] mbtk_set_modem_fun 1 fail [err = %d].", ret);
|
q.huang | 238b22a | 2025-06-10 14:36:59 +0800 | [diff] [blame] | 2947 | return GSW_HAL_NORMAL_FAIL;
|
| 2948 | }
|
| 2949 | return GSW_HAL_SUCCESS;
|
| 2950 | }
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 2951 |
|
q.huang | c8b9312 | 2025-06-17 17:46:05 +0800 | [diff] [blame] | 2952 | int gsw_reg_operating_mode_callback(GSW_NW_AirplaneModeHandlePtr handle_ptr)
|
| 2953 | {
|
| 2954 | if (nw_init_flag == 0 || nw_info_handle == NULL)
|
| 2955 | {
|
| 2956 | return GSW_HAL_NORMAL_FAIL;
|
| 2957 | }
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2958 |
|
| 2959 | void* cb_func;
|
q.huang | c8b9312 | 2025-06-17 17:46:05 +0800 | [diff] [blame] | 2960 | if(handle_ptr == NULL)
|
| 2961 | {
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2962 | LOGE(GSW_NW,"reg airplane mode cb is NULL");
|
| 2963 | cb_func=NULL;
|
q.huang | c8b9312 | 2025-06-17 17:46:05 +0800 | [diff] [blame] | 2964 | }
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2965 | else
|
| 2966 | {
|
| 2967 | cb_func=(void*) gsw_operating_mode_event_callback;
|
q.huang | c8b9312 | 2025-06-17 17:46:05 +0800 | [diff] [blame] | 2968 | }
|
q.huang | c8b9312 | 2025-06-17 17:46:05 +0800 | [diff] [blame] | 2969 |
|
q.huang | 934ec0e | 2025-07-22 19:56:59 +0800 | [diff] [blame] | 2970 | int ret = mbtk_radio_state_change_cb_reg(nw_info_handle, cb_func);
|
| 2971 |
|
| 2972 | if (ret != 0)
|
| 2973 | {
|
| 2974 | LOGE(GSW_NW,"mbtk_radio_state_change_cb_reg fail, ret is %d",ret);
|
| 2975 | return GSW_HAL_NORMAL_FAIL;
|
| 2976 | }
|
| 2977 |
|
| 2978 | airplane_cb = handle_ptr;
|
| 2979 |
|
| 2980 | if(airplane_cb !=NULL)
|
| 2981 | {
|
| 2982 | int opmode;
|
| 2983 | ret = gsw_get_opmode(&opmode);
|
| 2984 | if(ret == 0)
|
| 2985 | {
|
| 2986 | airplane_cb(opmode);
|
| 2987 | }
|
| 2988 | else
|
| 2989 | {
|
| 2990 | LOGE(GSW_NW,"gsw_get_opmode fail, ret is%d", ret);
|
| 2991 | }
|
| 2992 | }
|
| 2993 |
|
| 2994 | return GSW_HAL_SUCCESS;
|
q.huang | c8b9312 | 2025-06-17 17:46:05 +0800 | [diff] [blame] | 2995 | }
|
| 2996 |
|
hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 2997 | int gsw_get_apn_reserved_id(const char *apn)
|
| 2998 | {
|
| 2999 | return 0;
|
| 3000 | }
|
| 3001 |
|
| 3002 | int gsw_set_apn_reserved_id(int reserved_id, const char *apn)
|
| 3003 | {
|
| 3004 | return 0;
|
| 3005 | }
|
| 3006 |
|
| 3007 | int gsw_data_call_clear_session(int linkid, Link_Info_s *LinkInf)
|
| 3008 | {
|
| 3009 | return 0;
|
| 3010 | }
|
| 3011 |
|
| 3012 | void *gsw_onUnsolicited(void *arg)
|
| 3013 | {
|
| 3014 | return 0;
|
| 3015 | }
|
| 3016 |
|
| 3017 | int gsw_sdk_init(void)
|
| 3018 | {
|
| 3019 | return 0;
|
| 3020 | }
|
| 3021 |
|
| 3022 | int gsw_get_modem_state_exp(void)
|
| 3023 | {
|
| 3024 | return 0;
|
| 3025 | }
|