blob: 2e34df531265610f871c57f683d14a4a50223620 [file] [log] [blame]
b.liu68a94c92025-05-24 12:53:41 +08001/**
2* @file : gsw_nw_interface.h
3* @brief : sim and apn
4* @date :
5* @author : wind
6* @version : v1.0
7* @copyright
8*/
9#ifndef GSW_NWINFO_INTERFACE_H
10#define GSW_NWINFO_INTERFACE_H
11
12#include <stdio.h>
13#include <stdlib.h>
14#include <stdbool.h>
15#include <string.h>
16#include <unistd.h>
17#include <pthread.h>
18#include "gsw_hal_errcode.h"
19
20#if defined(__cplusplus)
21extern "C" {
22#endif
23
24#define GSWOL_5G_SDK
25
26#define GSW_NW_OPERATION_NAME_LEN (32)
27#define GSW_NW_PLMN_LEN (6)
28#define GSW_NW_MCC_LEN (3)
29#define GSW_NW_MNC_LEN (3)
30#define GSW_NW_SUCCESS GSW_HAL_SUCCESS
31#define GSW_NW_FAIL GSW_HAL_NORMAL_FAIL
32
33#define GSW_MCC_MAX_LEN (16)
34#define GSW_MNC_MAX_LEN (16)
35#define GSW_APN_CHANNEL_MAX (10)
36#define GSW_POXY_ADDR_MAX_LEN (64)
37#define GSW_PDP_TYPE_MAX_LEN (16)
38#define GSW_APN_MAX_LEN (32)
39#define GSW_APN_ID_MAX_LEN (32)
40#define GSW_APN_TYPE_MAX_LEN (50)
41#define GSW_USR_MAX_LEN (16)
42#define GSW_PWD_MAX_LEN (16)
43#define GSW_AUTH_TYPE_MAX_LEN (50)
44#define GSW_PROTOCO_MAX_LEN (64)
45#define GSW_CARRIER_ID_MAX_LEN (64)
46#define GSW_IFACE_NAME_MAX_LEN (50)
47#define GSW_PDP_ADDR_MAX_LEN (64)
48#define GSW_DNS_ADDR_MAX_LEN (64)
49#define GSW_GETWAYS_ADDR_MAX_LEN (64)
50#define GSW_RSP_MAX_LEN (256)
51
52#define DATA_TOKEN (2022)
53
54#define MAX_CELL_EXT_INFO (5)
55
56#ifndef uint8_t
57typedef unsigned char uint8_t;
58#endif
59
60typedef enum roaming_status
61{
62 WAN_ROAM_STATUS_UNKOWN = 0, /**< init value */
63 WAN_ROAM_STATUS_HOME = 1, /**< china home */
64 WAN_ROAM_STATUS_INTERNAL = 2, /**< china roaming */
65 WAN_ROAM_STATUS_INTERNATIONA = 3, /**< other country roaming */
66} roaming_status_e_type;
67
68typedef enum gsw_network_roaming_state
69{
70 GSW_NETWORK_ROAMING_OFF = 0x0, /**< roaming off */
71 GSW_NETWORK_ROAMING_ON = 0x1, /**< roaming on*/
72} GSW_NW_ROAMING_STATE_E;
73
74typedef enum service_domain
75{
76 GSW_SRV_DOMAIN_NO_SVC = 0x0, /**< no service */
77 GSW_SRV_DOMAIN_CS_ONLY = 0x1, /**< cs only */
78 GSW_SRV_DOMAIN_PS_ONLY = 0x2, /**< ps only */
79 GSW_SRV_DOMAIN_CS_PS = 0x3, /**< reg all in service */
80} GSW_SERVICE_DOMAIN_E;
81
82typedef enum gsw_network_reg_state
83{
84 GSW_NETWORK_REG_NOT_REGISTERED = 0x0, /**< no service */
85 GSW_NETWORK_REG_REGISTERED = 0x1, /**< reg in service home */
86 GSW_NETWORK_REG_NOT_REGISTERED_SEARCHING = 0x2, /**< searching network */
87 GSW_NETWORK_REG_REGISTRATION_DENIED = 0x3, /**< network denny device */
88 GSW_NETWORK_REG_REGISTRATION_UNKNOWN = 0x4, /**< unknown state */
89 GSW_NETWORK_REG_REGISTRATION_ROAMING = 0x5, /**< roaming state in service */
90 GSW_NETWORK_REG_LIMITED_SERVICE = 0x6, /**< limited service */
91} GSW_NW_REG_STATE_E;
92
93typedef enum gsw_network_radio_interface
94{
95 GSW_NETWORK_RADIO_NO_SVC = 0x0, /**< radio state no service */
96 GSW_NETWORK_RADIO_CDMA_1X = 0x1, /**< cdma 1x */
97 GSW_NETWORK_RADIO_CDMA_1XEVDO = 0x2, /**< cdma evdo */
98 GSW_NETWORK_RADIO_AMPS = 0x3, /**< amps gsm 2g*/
99 GSW_NETWORK_RADIO_GSM = 0x4, /**< gsm */
100 GSW_NETWORK_RADIO_UMTS = 0x5, /**< umts wcdma*/
101 GSW_NETWORK_RADIO_LTE = 0x6, /**< LTE 4G */
102 GSW_NETWORK_RADIO_TDSCDMA = 0x7, /**< TDS 3G*/
103 GSW_NETWORK_RADIO_NR5G = 0x8, /**< NR 5G*/
104} GSW_NW_RADIO_ACCESS_TECH_E;
105
106typedef enum data_conn_status
107{
108 DIAL_STATUS_MIN_ENUM_VAL = -1, /**< default value*/
109 DIAL_STATUS_CONNECTING = 0, /**< data connecting*/
110 DIAL_STATUS_CONNECTED = 1, /**< data conneted*/
111 DIAL_STATUS_DISCONNECTING = 2, /**< data disconnecting*/
112 DIAL_STATUS_DISCONNECTED = 3, /**< data disconnected*/
113 DIAL_STATUS_MAX_ENUM_VAL, /**< default max value*/
114} data_conn_status_e_type;
115
116typedef enum sim_status
117{
118 SIM_STATUS_ABSENT = 0, /**< sim absent*/
119 SIM_STATUS_PRESENT = 1, /**< sim present mtk as ready*/
120 SIM_STATUS_ERROR = 2, /**< sim error*/
121 SIM_STATUS_READY = 3, /**< sim state ready mtk no this value*/
122 SIM_STATUS_PIN = 4, /**< pinlock status*/
123} sim_status_e_type;
124
125typedef enum oprate_mode
126{
127 GSW_OP_MODE_LPM = 0, /**< radio state off*/
128 GSW_OP_MODE_ONLINE = 1, /**< radio state on*/
129 GSW_OP_MODE_FTM = 2, /**< radio state ftm*/
130 GSW_OP_MODE_OFFLINE = 3, /**< radio state offline*/
131} OPERATE_MODE_E;
132
133typedef struct
134{
135 unsigned char cell_id_valid;
136 unsigned char pci_valid;
137 unsigned char psc_valid;
138 unsigned char band_valid;
139 unsigned char arfcn_valid;
140 unsigned char rssi_valid;
141 unsigned char rsrp_valid;
142 unsigned char rsrq_valid;
143 unsigned char sinr_valid;
144 unsigned char rscp_valid;
145 unsigned char ecio_valid;
146 GSW_NW_RADIO_ACCESS_TECH_E rat;
147 unsigned int cell_id;
148 int pci;
149 int psc;
150 int band;
151 int arfcn;
152 int rssi;
153 int rsrp;
154 int rsrq;
155 int sinr;
156 int rscp;
157 int ecio;
158 char mcc[5];
159 char mnc[5];
160} GSW_NW_CELL_EXT_INFO;
161
162typedef struct
163{
164 GSW_NW_RADIO_ACCESS_TECH_E rat; /**< current radio state*/
165
166 uint8_t mcc_valid;
167 char mcc[5];
168 uint8_t mnc_valid;
169 char mnc[5];
170 uint8_t cell_id_valid;
171 unsigned int cell_id; /**< cell id*/
172 uint8_t pci_valid;
173 int pci; /**<physical cell id*/
174 uint8_t psc_valid;
175 int psc; /**<wcdma primary scramble code*/
176 uint8_t narfcn_valid;
177 int narfcn; /**<nr cell freq*/
178 uint8_t earfcn_valid;
179 int earfcn; /**<lte cell freq*/
180 uint8_t uarfcn_valid;
181 int uarfcn; /**<wcdma cell freq*/
182 uint8_t arfcn_valid;
183 int arfcn; /**<gsw cell freq*/
184 uint8_t tac_valid;
185 unsigned int tac; /**< cell tac*/
186 uint8_t lac_valid;
187 unsigned int lac; /**< cell lac*/
188 uint8_t sid_valid;
189 int sid; /**< cell sid cdma*/
190 uint8_t nid_valid;
191 int nid; /**< cell nid cdma*/
192 uint8_t lteMode_valid;
193 int lteMode; /**<tdd 0, fdd 1*/
194
195 uint8_t rssi_valid;
196 int rssi; /**< Valid values are (0-31, 99) as defined in TS 27.007 8.5 */
197
198 uint8_t rscp_valid;
199 int rscp; /**< The Received Signal Code Power in dBm multipled by -1.
200 * Range : 25 to 120
201 * INT_MAX: 0x7FFFFFFF denotes invalid value.
202 * Reference: 3GPP TS 25.123, section 9.1.1.1 */
203
204 uint8_t ecio_valid;
205 int ecio; /**< Valid values are positive integers. This value is the actual Ec/Io multiplied
206 * by -10. Example: If the actual Ec/Io is -12.5 dB, then this response value
207 * will be 125.*/
208
209 uint8_t rsrp_valid;
210 int rsrp; /**< The current Reference Signal Receive Power in dBm multipled by -1.
211 * Range: 44 to 140 dBm
212 * INT_MAX: 0x7FFFFFFF denotes invalid value.
213 * Reference: 3GPP TS 36.133 9.1.4 */
214
215 uint8_t rsrq_valid;
216 int rsrq; /**< The current Reference Signal Receive Quality in dB multiplied by -1.
217 * Range: 20 to 3 dB.
218 * INT_MAX: 0x7FFFFFFF denotes invalid value.
219 * Reference: 3GPP TS 36.133 9.1.7 */
220
221 uint8_t rssnr_valid;
222 int rssnr; /**< The current reference signal signal-to-noise ratio in 0.1 dB units.
223 * Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB).
224 * INT_MAX : 0x7FFFFFFF denotes invalid value.
225 * Reference: 3GPP TS 36.101 8.1.1 */
226
227 uint8_t band_valid;
228 int band;
229
230 uint8_t bler_valid;
231 int bler; /**<bit error rate*/
232 int ext_info_len; /**<ext_info len*/
233 GSW_NW_CELL_EXT_INFO ext_info[MAX_CELL_EXT_INFO];
234
235} GSW_NW_CELL_INFO;
236
237typedef struct
238{
239 GSW_NW_REG_STATE_E reg_state; /**< network cs regstate*/
240 GSW_NW_REG_STATE_E ps_state; /**< network ps regstate*/
241 GSW_NW_RADIO_ACCESS_TECH_E reg_rat; /**< current radio state*/
242 GSW_SERVICE_DOMAIN_E srv_domain; /**< current cs or ps state*/
243 GSW_NW_ROAMING_STATE_E roaming_ind; /**< roaming state*/
244 char reg_plmn[GSW_NW_PLMN_LEN + 1]; /**< current cell plmn*/
245 char operator_name[GSW_NW_OPERATION_NAME_LEN + 1]; /**< operator name*/
246 char cell_id[128]; /**< cell id*/
247 char tac[128]; /**< cell tac*/
248 char lac[128]; /**< cell lac*/
249 int sid; /**< cell sid cdma*/
250 int nid; /**< cell nid cdma*/
251} GSW_NW_SERVING_INFO;
252
253typedef struct
254{
255 GSW_NW_RADIO_ACCESS_TECH_E rej_rat; /**< current network radio tech*/
256 GSW_SERVICE_DOMAIN_E rej_domain; /**< reject code from ps or cs*/
257 int rej_cause; /**< reject code number*/
258} GSW_NW_REJ_CAUSE_E;
259
260typedef enum
261{
262 SMS_FORMAT_GSM_7BIT = 0, /**< 7bit econde*/
263 SMS_FORMAT_BINARY_DATA = 1, /**< 8bit binary encode*/
264 SMS_FORMAT_UCS2 = 2, /**< ucs2 encode*/
265}gsw_sms_format_e;
266
267typedef struct
268{
269 unsigned char year[5]; /**< year of date*/
270 unsigned char month[3]; /**< month of date*/
271 unsigned char day[3]; /**< day of date*/
272 unsigned char hour[3]; /**< hour of time*/
273 unsigned char minutes[3]; /**< minute of time*/
274 unsigned char seconds[3]; /**< second of time*/
275 unsigned char timezone[4]; /**< timezone*/
276}gsw_sms_date_t;
277
278#define GSW_SMS_SEND_NUM_MAX 5 /**< dest num max count */
279#define GSW_SMS_ADDRESS_LEN 32 /**< one dest number max length*/
280#define GSW_SMS_CONCAT_SMS_COUNT_MAX 160 /**< one page max bytes*/
281#define GSW_SMS_MSG_CONTENT_LEN_MAX 3 /**< sms page max count*/
282#define GSW_SMS_CONTENT_LEN_MAX 3 /**< newmsg recv one page*/
283#define GSW_SMS_SEND_CONT_MAX (GSW_SMS_MSG_CONTENT_LEN_MAX*GSW_SMS_CONCAT_SMS_COUNT_MAX*2) /**< sms send max len*/
284#define GSW_SMS_RECV_CONT_MAX 1440 /**< sms receive max len*/
285
286typedef struct
287{
288 char src_num[GSW_SMS_ADDRESS_LEN+1]; /**< sms phone num send msg*/
289 char dest_num[GSW_SMS_ADDRESS_LEN + 1]; /**< sms phone num recv msg*/
290 gsw_sms_format_e content_encode; /**< sms content is 7bit or 8bit or Ucs2 encode*/
291 unsigned int content_len; /**< sms content size*/
292 char content[GSW_SMS_RECV_CONT_MAX + 1]; /**< sms content*/
293 gsw_sms_date_t date; /**< message time*/
294}gsw_sms_msg_type_t;
295
296typedef struct
297{
298 gsw_sms_format_e content_encode; /**< content encode*/
299 int content_len; /**< content len*/
300 char content[GSW_SMS_RECV_CONT_MAX + 1]; /**< sms content*/
301 gsw_sms_date_t date; /**< sms date */
302} gsw_sms_content_t;
303
304typedef enum
305{
306 GSW_SMS_FULL_FLG, /**< sms full flag*/
307 GSW_SMS_RECEIVED_FLG, /**<recv new sms flag*/
308}gsw_sms_state_e;
309
310/*--------------------------------------------------------------------------------------------------------------------*/
311/* Data call adaptation layer struct */
312/*--------------------------------------------------------------------------------------------------------------------*/
313#define LINK0 (0) /**< public use APN2 or APN3 */
314#define LINK1 (1) /**< private use APN1 */
315#define LINK2 (2) /**< public use APN2 or APN3 */
316#define MAX_LINKS (3)
317
318#define INACTIVED (0)
319#define ACTIVED (2)
320
321#define TYPE_IPV4 (0)
322#define TYPE_IPV6 (1)
323#define TYPE_IPV4V6 (2)
324
325typedef struct {
326 char ip[GSW_PDP_ADDR_MAX_LEN]; /**< ip address */
327 char pdns[GSW_DNS_ADDR_MAX_LEN]; /**< pdns address*/
328 char sdns[GSW_DNS_ADDR_MAX_LEN]; /**< sdns address*/
329 char gw[GSW_GETWAYS_ADDR_MAX_LEN]; /**< gate way address*/
330}V4_Addr_s;
331
332typedef struct {
333 char ip[GSW_PDP_ADDR_MAX_LEN]; /**< ip address*/
334 char pdns[GSW_DNS_ADDR_MAX_LEN]; /**< pdns address*/
335 char sdns[GSW_DNS_ADDR_MAX_LEN]; /**< sdns address*/
336}V6_Addr_s;
337
338typedef struct {
339 int handle; /**< data connection handle*/
340
341 /* req info */
342 char mcc[GSW_MCC_MAX_LEN]; /**< apn mcc value*/
343 char mnc[GSW_MNC_MAX_LEN]; /**< apn mnc value*/
344 char apnid[GSW_APN_ID_MAX_LEN]; /**< apn id*/
345 char apn[GSW_APN_MAX_LEN]; /**< apn name*/
346 char apnType[GSW_APN_TYPE_MAX_LEN]; /**< apn type ipv4 ipv4v6 ipv6*/
347 char usr[GSW_USR_MAX_LEN]; /**< apn usr name*/
348 char pwd[GSW_PWD_MAX_LEN]; /**< apn password*/
349 char authType[GSW_AUTH_TYPE_MAX_LEN]; /**< apn auth type*/
350 char normalProtocol[GSW_PROTOCO_MAX_LEN]; /**< apn auth protoco*/
351 char roamingProtocol[GSW_PROTOCO_MAX_LEN]; /**< apn auth protoco roaming*/
352 char carrier[GSW_CARRIER_ID_MAX_LEN]; /**< carrier id*/
353
354 /* rsp */
355 int cid; /**< data connection cid for mdm sdk*/
356 int active; /**< pdn context active state: 2,actived; other,not active */
357 char ifname[GSW_IFACE_NAME_MAX_LEN]; /**< if name of current datalink */
358 int type; /**< data connection type*/
359 V4_Addr_s v4; /**< ipv4 addr*/
360 V6_Addr_s v6; /**< ipv6 addr*/
361 int mtu; /**< mtu value*/
362
363 char out[GSW_RSP_MAX_LEN]; /**< sdk return value*/
364}Link_Info_s;
365
366typedef struct {
367 int handle; /**< data connection handle*/
368 int cid; /**< data connection cid*/
369 int state; /**< data connection state*/
370 int fail_cause; /**< data connection fail cause*/
371 char *type; /**< data connection type*/
372 char *ifname; /**< ifname*/
373
374 char *v4_ip; /**< ipv4 address*/
375 char *v4_pdns; /**< ipv4 pdns address*/
376 char *v4_sdns; /**< ipv4 sdns address*/
377 char *v4_gw; /**< ipv4 gateway address*/
378
379 char *v6_ip; /**< ipv6 address*/
380 char *v6_pdns; /**< ipv6 gateway address*/
381 char *v6_sdns; /**< ipv6 gateway address*/
382}Wan_State_ind_s;
383
384typedef struct{
385 int gw_sig_valid; /**< 1 valid,1 invalid*/
386 int rssi; /**< Valid values are (0-31, 99) as defined in TS 27.007 8.5 */
387 int wcdma_sig_valid;/**< 1 valid,0 invalid*/
388 int rscp; /**< The Received Signal Code Power in dBm multipled by -1.
389 * Range : 25 to 120
390 * INT_MAX: 0x7FFFFFFF denotes invalid value.
391 * Reference: 3GPP TS 25.123, section 9.1.1.1 */
392 int ecno; /**< Valid values are positive integers. This value is the actual Ec/Io multiplied
393 * by -10. Example: If the actual Ec/Io is -12.5 dB, then this response value
394 * will be 125.*/
395 int lte_sig_valid;/**< 1 valid,0 invalid*/
396 int rsrp; /**< The current Reference Signal Receive Power in dBm multipled by -1.
397 * Range: 44 to 140 dBm
398 * INT_MAX: 0x7FFFFFFF denotes invalid value.
399 * Reference: 3GPP TS 36.133 9.1.4 */
400 int rsrq; /**< The current Reference Signal Receive Quality in dB multiplied by -1.
401 * Range: 20 to 3 dB.
402 * INT_MAX: 0x7FFFFFFF denotes invalid value.
403 * Reference: 3GPP TS 36.133 9.1.7 */
404 int rssnr; /**< The current reference signal signal-to-noise ratio in 0.1 dB units.
405 * Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB).
406 * INT_MAX : 0x7FFFFFFF denotes invalid value.
407 * Reference: 3GPP TS 36.101 8.1.1 */
408 int nr_sig_valid;/**<1 valid,0 invalid*/
409 int ssRsrp; /**< SS(Synchronization Signal) reference signal received power, multipled by -1.
410 * Reference: 3GPP TS 38.215.
411 * Range [44, 140], INT_MAX means invalid/unreported.*/
412 int ssRsrq; /**< SS reference signal received quality, multipled by -1.
413 * Reference: 3GPP TS 38.215.
414 * Range [3, 20], INT_MAX means invalid/unreported.*/
415 int ssSinr; /**< SS signal-to-noise and interference ratio.
416 * Reference: 3GPP TS 38.215 section 5.1.*, 3GPP TS 38.133 section 10.1.16.1.
417 * Range [-23, 40], INT_MAX means invalid/unreported.*/
418 int csiRsrp; /**< CSI reference signal received power, multipled by -1.
419 * Reference: 3GPP TS 38.215.
420 * Range [44, 140], INT_MAX means invalid/unreported.*/
421 int csiRsrq; /**< CSI reference signal received quality, multipled by -1.
422 * Reference: 3GPP TS 38.215.
423 * Range [3, 20], INT_MAX means invalid/unreported.*/
424 int csiSinr; /**< CSI signal-to-noise and interference ratio.
425 * Reference: 3GPP TS 138.215 section 5.1.*, 3GPP TS 38.133 section 10.1.16.1.
426 * Range [-23, 40], INT_MAX means invalid/unreported.*/
427} signalStrength_t;
428
429typedef struct
430{
431 int regState; /**< voice or data reg service state */
432 char CID[128]; /**< gsm/wcdma cid */
433 char LAC[128]; /**< cell lac */
434 int netType; /**< radio tech */
435 int radioTechFam; /**< 1-3GPP; 2-3GPP2 */
436 int netRejectedCode; /**< denied code */
437} lynq_nw_reg_status_t;
438
439typedef enum mode_state_type
440{
441 GSW_MODEM_STATE_UNKNOWN = 0, /**< modem unknow */
442 GSW_MODEM_STATE_ONLINE, /**< modem work online */
443 GSW_MODEM_STATE_OFFLINE, /**< modem offline */
hong.liud2417072025-06-27 07:10:37 -0700444 GSW_SDK_STATE_SERVICE_DOWN,
445 GSW_SDK_STATE_SERVICE_UP,
446 GSW_SDK_STATE_GPS_DOWN,
447 GSW_SDK_STATE_GPS_UP,
b.liu68a94c92025-05-24 12:53:41 +0800448}gsw_mode_state_e;
449
450
451typedef struct
452{
453 char long_eons[128]; /**< Full name of the operator*/
454 char short_eons[128]; /**< Shor name of the operator*/
455 char mcc[4]; /**< Mobile country code*/
456 char mnc[4]; /**< Mobile network code*/
457}gsw_mobile_operator_name;
458
459
460#define GSW_MCC_MAX_LEN (16)
461#define GSW_MNC_MAX_LEN (16)
462#define GSW_PLMN_LIST_MAX_LEN (85)
463
464
465typedef struct {
466 char mcc[GSW_MCC_MAX_LEN]; /**< Mobile country code*/
467 char mnc[GSW_MNC_MAX_LEN]; /**< Mobile network code*/
468} gsw_nw_plmn_t;
469
470
471typedef struct {
472 int plmn_list_len;
473 gsw_nw_plmn_t plmn_list[GSW_PLMN_LIST_MAX_LEN];
474} gsw_nw_plmn_list_t;
475
476typedef struct
477{
478 uint64_t tx_pkts; /**< the number of packet sent*/
479 uint64_t tx_bytes; /**< the number of packet sent bytes */
480 uint64_t tx_dropped_pkts; /**< the number of packet dropped by sent*/
481 uint64_t rx_pkts; /**< the number of packet received*/
482 uint64_t rx_bytes; /**< the number of packet receivedbytes */
483 uint64_t rx_dropped_pkts; /**< the number of packet dropped by received*/
484}gsw_data_pkt_stats;
485
486typedef struct {
487 char apn_name[GSW_APN_MAX_LEN];
488 char apn_accont[GSW_USR_MAX_LEN];
489 char apn_password[GSW_PWD_MAX_LEN];
490 uint8_t auth_type;
491} gsw_apn_param_t;
492
493/* Callback function registered to QL_SMS_AddRxMsgHandler, msgRef contains the detail msg infor */
494typedef void (* GSW_SMS_Callback_fun)(gsw_sms_state_e state, gsw_sms_msg_type_t *report_info);
495typedef void (* GSW_NW_ServingInfoHandlePtr)(GSW_NW_SERVING_INFO serving_info);
496typedef void (* GSW_NW_SigInfoHandlePtr)(signalStrength_t sig_info);
497typedef void (* GSW_NW_RejectCauseHandlePtr)(GSW_NW_REJ_CAUSE_E *rej_cause);
498typedef void (* GSW_NW_AirplaneModeHandlePtr)(int airplane_mode);
499typedef void (* GSW_NW_ModemStateHandlePtr)(gsw_mode_state_e state);
500
501/**
502 * @brief SDK interface to call back serving info
503 * @param [in] GSW_NW_ServingInfoHandlePtr:
504 * @retval 0: success
505 * @retval other: fail
506 */
507int gsw_reg_serving_info_callback(GSW_NW_ServingInfoHandlePtr handle_ptr);
508
509
510/**
511 * @brief SDK interface to call back sig info
512 * report: event + cycle(5s) 事件+周期上报
513 * 如果底层(modem 上报)有信号上报,就执行回调函数进行上报
514 * 如果底层(modem 上报)超过 5s 没有上报,服务层就自己获取一次信号,做一次补充上报
515 * @param [in] GSW_NW_SigInfoHandlePtr:
516 * @retval 0: success
517 * @retval other: fail
518 */
519int gsw_reg_sig_info_callback(GSW_NW_SigInfoHandlePtr handle_ptr);
520
521
522/**
523 * @brief SDK interface to call back rej cause
524 * @param [in] GSW_NW_RejectCauseHandlePtr:
525 * @retval 0: success
526 * @retval other: fail
527 */
528int gsw_reg_rej_cause_callback(GSW_NW_RejectCauseHandlePtr handle_ptr);
529
530
531/**
532 * @brief SDK interface to call back airplane mode
533 * @param [in] GSW_NW_AirplaneModeHandlePtr:
534 * @retval 0: success
535 * @retval other: fail
536 */
537int gsw_reg_operating_mode_callback(GSW_NW_AirplaneModeHandlePtr handle_ptr);
538
539
540/**
541 * @brief SDK interface to call back sms messages
542 * @param [in] GSW_SMS_Callback_fun:
543 * @retval 0: success
544 * @retval other: fail
545 */
546int gsw_sms_reg_callback(GSW_SMS_Callback_fun handle_ptr);
547
548
549/**
550 * @brief mdm sdk service init before all other sdk init
551 * @param
552 * @retval 0: success
553 * @retval other: fail
554 */
555int gsw_sdk_init(void);
556
557
558/**
559 * @brief network sdk init
560 * @param [in] token usr id define by who use
561 * @retval 0: success
562 * @retval other: fail
563 */
564int gsw_nw_sdk_init(int token);
565
566
567/**
568 * @brief network sdk deinit
569 * @param
570 * @retval 0: success
571 * @retval other: fail
572 */
573int gsw_nw_sdk_deinit(void);
574
575
576/**
577 * @brief sim sdk init
578 * @param [in] token usr id define by who use
579 * @retval 0: success
580 * @retval other: fail
581 */
582int gsw_sim_sdk_init(int token);
583
584
585/**
586 * @brief sim sdk deinit
587 * @param
588 * @retval 0: success
589 * @retval other: fail
590 */
591int gsw_sim_sdk_deinit(void);
592
593
594/**
595 * @brief sms sdk init
596 * @param [in] token
597 * @retval 0: success
598 * @retval other: fail
599 */
600int gsw_sms_sdk_init(int token);
601
602
603/**
604 * @brief sms sdk deinit
605 * @param
606 * @retval 0: success
607 * @retval other: fail
608 */
609int gsw_sms_sdk_deinit(void);
610
611
612/**
613 * @brief get current network reg info
hong.liud2417072025-06-27 07:10:37 -0700614 * @details support thread safe
b.liu68a94c92025-05-24 12:53:41 +0800615 * @param [out] GSW_NW_SERVING_INFO struct for network info
616 * include regstate ps_state opreator name mcc mcn etc
617 * @retval 0: success
618 * @retval other: fail
619 */
620int gsw_get_nwinfo(GSW_NW_SERVING_INFO *serving_info);
621
622
623/**
624 * @brief get current network type
hong.liud2417072025-06-27 07:10:37 -0700625 * @details support thread safe
b.liu68a94c92025-05-24 12:53:41 +0800626 * @param [out] netype as GSW_NW_RADIO_ACCESS_TECH_E type
627 * @retval 0: success
628 * @retval other: fail
629 */
630int gsw_get_netype(int *netype);
631
632
633/**
634 * @brief get radio opmode, as open and close airplane mode
635 * @param [out] op_mode 1 is radio on, 0 is radio off
636 * @retval 0: success
637 * @retval other: fail
638 */
639int gsw_get_opmode(int *op_mode);
640
641
642/**
643 * @brief set radio opmode, as open and close airplane mode
644 * @param [in] op_mode 1 is radio on, 0 is radio off
645 * @retval 0: success
646 * @retval other: fail
647 */
648int gsw_set_opmode(int op_mode);
649
650
651/**
652 * @brief get network mode preference of mdm search network scale
653 * @param [out] mode_pref net_work pref mode:
654 * 32 - all mode 2G/3G/4G/5G;
655 * 9 - 2G/3G/4G;
656 * 3 - 2G/3G;
657 * 1 - 2G only
658 * @retval 0: success
659 * @retval other: fail
660 */
661int gsw_get_mode_preference(int *mode_pref);
662
663
664/**
665 * @brief set network mode preference of mdm search network scale
666 * @param [in] mode_pref net_work pref mode:
667 * 32 - all mode 2G/3G/4G/5G;
668 * 9 - 2G/3G/4G;
669 * 3 - 2G/3G;
670 * 1 - 2G only
671 * @retval 0: success
672 * @retval other: fail
673 */
674int gsw_set_mode_preference(int mode_pref);
675
676
677/**
678 * @brief get signal csq value
hong.liud2417072025-06-27 07:10:37 -0700679 * @details support thread safe
b.liu68a94c92025-05-24 12:53:41 +0800680 * @param [out] csq_value csq of signalstrengh 0 - 31
681 * @retval 0: success
682 * @retval other: fail
683 */
684int gsw_get_sig_info(int *csq_value);
685
686/**
687 * @brief get current serving cell info
hong.liud2417072025-06-27 07:10:37 -0700688 * @details support thread safe
b.liu68a94c92025-05-24 12:53:41 +0800689 * @param [out] GSW_NW_CELL_INFO: struct for current cell info
690 * include earfcn mcc mnc pci psc tac lac etc.
691 * @return int: 0 is success, other failed
692 */
693int gsw_get_cell_info(GSW_NW_CELL_INFO *cell_info);
694
695/**
696 * @brief get mobile operator name
hong.liud2417072025-06-27 07:10:37 -0700697 * @details support thread safe
b.liu68a94c92025-05-24 12:53:41 +0800698 * @param [out] gsw_mobile_operator_name: get the long and short operator name info
699 * @retval 0: success
700 * @retval 0: other: fail
701 */
702int gsw_get_mobile_operator_name(gsw_mobile_operator_name *nw_operator_name_infos);
703
704/**
705 * @brief get PLMNs from the FPLMN list
706 * @param [inout] gsw_nw_plmn_list_t:
707 * @retval 0: success
708 * @retval other: fail
709 */
710int gsw_get_forbidden_networks(gsw_nw_plmn_list_t *plmn_list);
711
712/**
713 * @brief add PLMNs from the plmn_list to the FPLMN list
714 * @param [in] gsw_nw_plmn_list_t:
715 * @retval 0: success
716 * @retval other: fail
717 */
718int gsw_add_forbidden_networks(gsw_nw_plmn_list_t *plmn_list);
719
720/**
721 * @brief Remove PLMNs from the plmn_list from the FPLMN list
722 * @param [in] gsw_nw_plmn_list_t:
723 * @retval 0: success
724 * @retval other: fail
725 */
726int gsw_remove_forbidden_networks(gsw_nw_plmn_list_t *plmn_list);
727
728/**
729 * @brief clear FPLMN list
730 * @param
731 * @retval 0: success
732 * @retval other: fail
733 */
734int gsw_clear_forbidden_networks(void);
735
736
737/**
738 * @brief set nework power mode, for tcam enter standby or exit standby
739 * @param [in] mode TRUE(1) when enter standby, FALSE(0) after wake up
740 * @retval 0: success
741 * @retval other: fail
742 */
743int gsw_network_set_power_mode(char mode);
744
745
746/**
747 * @brief get sim state
hong.liud2417072025-06-27 07:10:37 -0700748 * @details support thread safe
b.liu68a94c92025-05-24 12:53:41 +0800749 * @param [out] sim_state sim status as sim_status_e_type
750 * @retval 0: success
751 * @retval other: fail
752 */
753int gsw_get_sim_status(int *sim_state);
754
755
756/**
757 * @brief get iccid function
hong.liud2417072025-06-27 07:10:37 -0700758 * @details support thread safe
b.liu68a94c92025-05-24 12:53:41 +0800759 * @param [in] len iccid length,max is 20
760 * @param [out] iccid return iccid from this func
761 * @retval 0: success
762 * @retval other: fail
763 */
764int gsw_get_sim_iccid(int len, char *iccid);
765
766
767/**
768 * @brief get imsi function
hong.liud2417072025-06-27 07:10:37 -0700769 * @details support thread safe
b.liu68a94c92025-05-24 12:53:41 +0800770 * @param [in] len imsi length,max is 20
771 * @param [out] iccid return imsi from this func
772 * @retval 0: success
773 * @retval other: fail
774 */
775int gsw_get_sim_imsi(int len, char *imsi);
776
777
778/**
779 * @brief get sim msisdn function
hong.liud2417072025-06-27 07:10:37 -0700780 * @details support thread safe
b.liu68a94c92025-05-24 12:53:41 +0800781 * @param [in] len msisdn length,max is 20
782 * @param [out] msisdn msisdn length,max is 20
783 * @retval 0: success
784 * @retval other: fail
785 */
786int gsw_get_sim_msisdn(int len, char *msisdn);
787
788
789/**
790 * @brief get imei function
hong.liud2417072025-06-27 07:10:37 -0700791 * @details support thread safe
b.liu68a94c92025-05-24 12:53:41 +0800792 * @param [in] len imei length,max is 20
793 * @param [out] imei return imei from this func
794 * @retval 0: success
795 * @retval other: fail
796 */
797int gsw_get_imei(int len, char *imei);
798
799
800/**
801 * @brief set sim power down
802 * @param
803 * @retval 0: success
804 * @retval other: fail
805 */
806int gsw_set_sim_power_down(void);
807
808
809/**
810 * @brief set sim power up
811 * @param
812 * @retval 0: success
813 * @retval other: fail
814 */
815int gsw_set_sim_power_up(void);
816
817
818/**
819 * @brief reset modem stack only,
820 * @details notice: after use this method, all ril sdk
821 * need restart, means network, sim, sms, data need deinit then init!
822 *
823 * @param
824 * @retval 0: success
825 * @retval other: fail
826 */
827int gsw_reset_modem(void);
828
829
830/**
831 * @brief send sms fuction
832 * @param [in] phone_num dest phone num send sms
833 * @param [in] char_set encode format for sms 0-7bit; 1-binary; 2-usc2
834 * @param [in] msg sms content
835 * @param [in] msg_len send sms length,max is 1024
836 * @retval 0: success
837 * @retval other: fail
838 */
839int gsw_send_sms(char *phone_num, int char_set, char *msg, int msg_len);
840
841
842/**
843 * @brief get smsc fuction
844 * @param [in] len input buf len for smsc,max is 32
845 * @param [out] smsc address for smsc get from this func *
846 * @retval 0: success
847 * @retval other: fail
848 */
849int gsw_get_smsc_address(int len, char *smsc);
850
851
852/**
853 * @brief set smsc fuction
854 * @param [out] smsc string value for smsc,max length is 32
855 * @retval 0: success
856 * @retval other: fail
857 */
858int gsw_set_smsc_address(const char *smsc);
859
860
861/**
862 * @brief convert rsrp rscp rssi to csq value.
863 * @param [in] netType signal radio tech 2 means 2G 3 mens 3G,4 is 4G,5 is 5G
864 * @param [in] sigvalue input signal_strength for different nettype
865 * rsrp for 4G/5G, rscp for 3G, rssi for 2G
866 * @retval 0: success
867 * @retval other: fail
868 */
869int gsw_sigInfo_to_csq(int netType, int sigValue);
870
871
872/**
873 * @brief data call event sdk callback function define
874 * @param [out] Wan_State_ind_s: data connection state and params indication struct
875 * include datacall state , ipv4 ipv6 address, dns address and ifname
876 * @retval void
877 */
878typedef void (*gsw_data_call_evt_cb_t)(Wan_State_ind_s *linkState);
879
880
881/**
882 * @brief use this api to wait data call event ind call back
883 * @param [out] arg
884 * @retval void
885 */
886void *gsw_onUnsolicited(void *arg);
887
888
889/**
890 * @brief datacall sdk init
891 * @param [in] gsw_data_call_evt_cb_t: data connection state change event
892 * call back;
893 * @retval 0: success
894 * @retval other: fail
895 */
896int gsw_data_call_init(gsw_data_call_evt_cb_t evt_cb);
897
898
899/**
900 * @brief data_call sdk deinit
901 * @param
902 * @retval 0: success
903 * @retval other: fail
904 */
905int gsw_data_call_deinit(void);
906
907/**
908 * @brief get apn info
909 * @param [in/out] gsw_apn_param_t:apn info for pub or private apn
910 * inlcude apn name mcc mnc, passwork apnid authtype iptype etc
911 * @return int : 0 is success , other failed
912 */
913void gsw_get_apn_info(int linkid, gsw_apn_param_t *apn_para);
914
915/**
916 * @brief set apn parameters for data call
917 * @param [in/out] Link_Info_s: for pub or private datacall
918 * inlcude apn name mcc mnc, passwork apnid type cid etc
919 * @retval 0: success
920 * @retval other: fail
921 */
922int gsw_data_call_set_apn(Link_Info_s *LinkInf);
923
924
925/**
926 * @brief set apn parameters for data call
927 * 接口超时时间:120s
928 * 如接口返回失败,不要给apn回调:gsw_data_call_evt_cb_t
929 * 如接口返回成功,从接口调用开始计时,到收到apn回调:gsw_data_call_evt_cb_t,不能超过120s
930 * @param [in] linkid data connetion link number
931 * @param [in/out] Link_Info_s: apn info for pub or private datacall
932 * inlcude apn name mcc mnc, passwork apnid etc
933 * resp: data call link state ipaddress type etc
934 * @retval 0: success
935 * @retval other: fail
936 */
937int gsw_data_call_connect(int linkid, Link_Info_s *LinkInf);
938
939
940/**
941 * @brief set apn parameters for data call
942 * @param [in] linkid
943 * @param [in/out] Link_Info_s: apn info for pub or private datacall
944 * inlcude apn name mcc mnc, passwork apnid etc
945 * resp: data call link state ipaddress type etc
946 * @retval 0: success
947 * @retval other: fail
948 */
949int gsw_data_call_disconnect(int linkid, Link_Info_s *LinkInf);
950
951
952/**
953 * @brief get the data traffic infos
954 @param [in] linkid apn id
955 @param [out] gsw_data_pkt_stats obtian actual data call network card data traffic
956 @retval 0: success
957 @retval 0: other: fail
958 */
959int gsw_get_data_call_pkt_stats(int linkid, gsw_data_pkt_stats *data_pkt);
960
961/**
962 * @brief clear data call if needed when receive apn down event
963 * @param [in] linkid
964 * @param [in/out] Link_Info_s: apn info for pub or private datacall
965 * inlcude apn name mcc mnc, passwork apnid etc
966 * resp: data call link state ipaddress type etc
967 * @retval 0: success
968 * @retval other: fail
969 */
970int gsw_data_call_clear_session(int linkid, Link_Info_s *LinkInf);
971
972/**
973 * @brief Set apn binding to specify interface id
974 * @details This interface supports a total of 8 reserved id information
975 * and the reserved id value ranges from 0-7
976 *
977 * @param [in] reserved_id: -1 unset reserved id,0-7 set reserved id
978 * @param [in] apn APN name
979 * @retval 0: success
980 * @retval other: fail
981 */
982int gsw_set_apn_reserved_id(int reserved_id, const char *apn);
983
984/**
985 * @brief Get the apn name bound to the specified interface id
986 * @param [in] reserved_id Network reserved interface id
987 * @param [out] apn_str APN name
988 * @param [in] apn_str_size APN name size
989 * @retval 0-7: success
990 * @retval -1: unbind reserved id
991 */
992int gsw_get_apn_reserved_name(int reserved_id, char *apn_str, int apn_str_size);
993
994/**
995 * @brief Get apn binding to specify interface id
996 * @param [in] apn
997 * @retval 0: success
998 * @retval 0-7: success
999 * @retval -1: unbind reserved id
1000 */
1001int gsw_get_apn_reserved_id(const char *apn);
1002
1003/**
1004 * @brief Get get modem state
1005 * @param
1006 * @retval 0: ok
1007 * @retval other: error
1008 */
1009
1010int gsw_get_modem_state_exp(void);
1011
1012/**
1013 * @brief set modem status event callback
1014 * @param [in] GSW_NW_ModemStateHandlePtr
1015 * @retval 0 : success
1016 * @retval other: fail
1017 */
1018int gsw_reg_set_modem_status_event_callback(GSW_NW_ModemStateHandlePtr handle_ptr);
1019
1020/**
1021 * @brief get tcamid function
hong.liud2417072025-06-27 07:10:37 -07001022 * @details support thread safe
b.liu68a94c92025-05-24 12:53:41 +08001023 * @param [in] len tcamid length
1024 * @param [out] iccid return tcamid from this func
1025 * @retval 0 : success
1026 * @retval other: fail
1027 */
1028int gsw_get_tcamid(int len, char *tcamid);
1029
1030
1031/**
1032* @brief Module log disk drop, used when restarting or hibernating
1033* @param [in]void
1034* @retval void
1035*/
1036void gsw_modem_log_sync(void);
1037
1038#if defined(__cplusplus)
1039extern "C" }
1040#endif
1041
1042#endif /*GSW_NWINFO_INTERFACE_H*/