blob: b3e0326e2fdb345d2a992a88e5d20a856a465ff5 [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 */
444}gsw_mode_state_e;
445
446
447typedef struct
448{
449 char long_eons[128]; /**< Full name of the operator*/
450 char short_eons[128]; /**< Shor name of the operator*/
451 char mcc[4]; /**< Mobile country code*/
452 char mnc[4]; /**< Mobile network code*/
453}gsw_mobile_operator_name;
454
455
456#define GSW_MCC_MAX_LEN (16)
457#define GSW_MNC_MAX_LEN (16)
458#define GSW_PLMN_LIST_MAX_LEN (85)
459
460
461typedef struct {
462 char mcc[GSW_MCC_MAX_LEN]; /**< Mobile country code*/
463 char mnc[GSW_MNC_MAX_LEN]; /**< Mobile network code*/
464} gsw_nw_plmn_t;
465
466
467typedef struct {
468 int plmn_list_len;
469 gsw_nw_plmn_t plmn_list[GSW_PLMN_LIST_MAX_LEN];
470} gsw_nw_plmn_list_t;
471
472typedef struct
473{
474 uint64_t tx_pkts; /**< the number of packet sent*/
475 uint64_t tx_bytes; /**< the number of packet sent bytes */
476 uint64_t tx_dropped_pkts; /**< the number of packet dropped by sent*/
477 uint64_t rx_pkts; /**< the number of packet received*/
478 uint64_t rx_bytes; /**< the number of packet receivedbytes */
479 uint64_t rx_dropped_pkts; /**< the number of packet dropped by received*/
480}gsw_data_pkt_stats;
481
482typedef struct {
483 char apn_name[GSW_APN_MAX_LEN];
484 char apn_accont[GSW_USR_MAX_LEN];
485 char apn_password[GSW_PWD_MAX_LEN];
486 uint8_t auth_type;
487} gsw_apn_param_t;
488
489/* Callback function registered to QL_SMS_AddRxMsgHandler, msgRef contains the detail msg infor */
490typedef void (* GSW_SMS_Callback_fun)(gsw_sms_state_e state, gsw_sms_msg_type_t *report_info);
491typedef void (* GSW_NW_ServingInfoHandlePtr)(GSW_NW_SERVING_INFO serving_info);
492typedef void (* GSW_NW_SigInfoHandlePtr)(signalStrength_t sig_info);
493typedef void (* GSW_NW_RejectCauseHandlePtr)(GSW_NW_REJ_CAUSE_E *rej_cause);
494typedef void (* GSW_NW_AirplaneModeHandlePtr)(int airplane_mode);
495typedef void (* GSW_NW_ModemStateHandlePtr)(gsw_mode_state_e state);
496
497/**
498 * @brief SDK interface to call back serving info
499 * @param [in] GSW_NW_ServingInfoHandlePtr:
500 * @retval 0: success
501 * @retval other: fail
502 */
503int gsw_reg_serving_info_callback(GSW_NW_ServingInfoHandlePtr handle_ptr);
504
505
506/**
507 * @brief SDK interface to call back sig info
508 * report: event + cycle(5s) 事件+周期上报
509 * 如果底层(modem 上报)有信号上报,就执行回调函数进行上报
510 * 如果底层(modem 上报)超过 5s 没有上报,服务层就自己获取一次信号,做一次补充上报
511 * @param [in] GSW_NW_SigInfoHandlePtr:
512 * @retval 0: success
513 * @retval other: fail
514 */
515int gsw_reg_sig_info_callback(GSW_NW_SigInfoHandlePtr handle_ptr);
516
517
518/**
519 * @brief SDK interface to call back rej cause
520 * @param [in] GSW_NW_RejectCauseHandlePtr:
521 * @retval 0: success
522 * @retval other: fail
523 */
524int gsw_reg_rej_cause_callback(GSW_NW_RejectCauseHandlePtr handle_ptr);
525
526
527/**
528 * @brief SDK interface to call back airplane mode
529 * @param [in] GSW_NW_AirplaneModeHandlePtr:
530 * @retval 0: success
531 * @retval other: fail
532 */
533int gsw_reg_operating_mode_callback(GSW_NW_AirplaneModeHandlePtr handle_ptr);
534
535
536/**
537 * @brief SDK interface to call back sms messages
538 * @param [in] GSW_SMS_Callback_fun:
539 * @retval 0: success
540 * @retval other: fail
541 */
542int gsw_sms_reg_callback(GSW_SMS_Callback_fun handle_ptr);
543
544
545/**
546 * @brief mdm sdk service init before all other sdk init
547 * @param
548 * @retval 0: success
549 * @retval other: fail
550 */
551int gsw_sdk_init(void);
552
553
554/**
555 * @brief network sdk init
556 * @param [in] token usr id define by who use
557 * @retval 0: success
558 * @retval other: fail
559 */
560int gsw_nw_sdk_init(int token);
561
562
563/**
564 * @brief network sdk deinit
565 * @param
566 * @retval 0: success
567 * @retval other: fail
568 */
569int gsw_nw_sdk_deinit(void);
570
571
572/**
573 * @brief sim sdk init
574 * @param [in] token usr id define by who use
575 * @retval 0: success
576 * @retval other: fail
577 */
578int gsw_sim_sdk_init(int token);
579
580
581/**
582 * @brief sim sdk deinit
583 * @param
584 * @retval 0: success
585 * @retval other: fail
586 */
587int gsw_sim_sdk_deinit(void);
588
589
590/**
591 * @brief sms sdk init
592 * @param [in] token
593 * @retval 0: success
594 * @retval other: fail
595 */
596int gsw_sms_sdk_init(int token);
597
598
599/**
600 * @brief sms sdk deinit
601 * @param
602 * @retval 0: success
603 * @retval other: fail
604 */
605int gsw_sms_sdk_deinit(void);
606
607
608/**
609 * @brief get current network reg info
610 * @param [out] GSW_NW_SERVING_INFO struct for network info
611 * include regstate ps_state opreator name mcc mcn etc
612 * @retval 0: success
613 * @retval other: fail
614 */
615int gsw_get_nwinfo(GSW_NW_SERVING_INFO *serving_info);
616
617
618/**
619 * @brief get current network type
620 * @param [out] netype as GSW_NW_RADIO_ACCESS_TECH_E type
621 * @retval 0: success
622 * @retval other: fail
623 */
624int gsw_get_netype(int *netype);
625
626
627/**
628 * @brief get radio opmode, as open and close airplane mode
629 * @param [out] op_mode 1 is radio on, 0 is radio off
630 * @retval 0: success
631 * @retval other: fail
632 */
633int gsw_get_opmode(int *op_mode);
634
635
636/**
637 * @brief set radio opmode, as open and close airplane mode
638 * @param [in] op_mode 1 is radio on, 0 is radio off
639 * @retval 0: success
640 * @retval other: fail
641 */
642int gsw_set_opmode(int op_mode);
643
644
645/**
646 * @brief get network mode preference of mdm search network scale
647 * @param [out] mode_pref net_work pref mode:
648 * 32 - all mode 2G/3G/4G/5G;
649 * 9 - 2G/3G/4G;
650 * 3 - 2G/3G;
651 * 1 - 2G only
652 * @retval 0: success
653 * @retval other: fail
654 */
655int gsw_get_mode_preference(int *mode_pref);
656
657
658/**
659 * @brief set network mode preference of mdm search network scale
660 * @param [in] mode_pref net_work pref mode:
661 * 32 - all mode 2G/3G/4G/5G;
662 * 9 - 2G/3G/4G;
663 * 3 - 2G/3G;
664 * 1 - 2G only
665 * @retval 0: success
666 * @retval other: fail
667 */
668int gsw_set_mode_preference(int mode_pref);
669
670
671/**
672 * @brief get signal csq value
673 * @param [out] csq_value csq of signalstrengh 0 - 31
674 * @retval 0: success
675 * @retval other: fail
676 */
677int gsw_get_sig_info(int *csq_value);
678
679/**
680 * @brief get current serving cell info
681 * @param [out] GSW_NW_CELL_INFO: struct for current cell info
682 * include earfcn mcc mnc pci psc tac lac etc.
683 * @return int: 0 is success, other failed
684 */
685int gsw_get_cell_info(GSW_NW_CELL_INFO *cell_info);
686
687/**
688 * @brief get mobile operator name
689 * @param [out] gsw_mobile_operator_name: get the long and short operator name info
690 * @retval 0: success
691 * @retval 0: other: fail
692 */
693int gsw_get_mobile_operator_name(gsw_mobile_operator_name *nw_operator_name_infos);
694
695/**
696 * @brief get PLMNs from the FPLMN list
697 * @param [inout] gsw_nw_plmn_list_t:
698 * @retval 0: success
699 * @retval other: fail
700 */
701int gsw_get_forbidden_networks(gsw_nw_plmn_list_t *plmn_list);
702
703/**
704 * @brief add PLMNs from the plmn_list to the FPLMN list
705 * @param [in] gsw_nw_plmn_list_t:
706 * @retval 0: success
707 * @retval other: fail
708 */
709int gsw_add_forbidden_networks(gsw_nw_plmn_list_t *plmn_list);
710
711/**
712 * @brief Remove PLMNs from the plmn_list from the FPLMN list
713 * @param [in] gsw_nw_plmn_list_t:
714 * @retval 0: success
715 * @retval other: fail
716 */
717int gsw_remove_forbidden_networks(gsw_nw_plmn_list_t *plmn_list);
718
719/**
720 * @brief clear FPLMN list
721 * @param
722 * @retval 0: success
723 * @retval other: fail
724 */
725int gsw_clear_forbidden_networks(void);
726
727
728/**
729 * @brief set nework power mode, for tcam enter standby or exit standby
730 * @param [in] mode TRUE(1) when enter standby, FALSE(0) after wake up
731 * @retval 0: success
732 * @retval other: fail
733 */
734int gsw_network_set_power_mode(char mode);
735
736
737/**
738 * @brief get sim state
739 * @param [out] sim_state sim status as sim_status_e_type
740 * @retval 0: success
741 * @retval other: fail
742 */
743int gsw_get_sim_status(int *sim_state);
744
745
746/**
747 * @brief get iccid function
748 * @param [in] len iccid length,max is 20
749 * @param [out] iccid return iccid from this func
750 * @retval 0: success
751 * @retval other: fail
752 */
753int gsw_get_sim_iccid(int len, char *iccid);
754
755
756/**
757 * @brief get imsi function
758 * @param [in] len imsi length,max is 20
759 * @param [out] iccid return imsi from this func
760 * @retval 0: success
761 * @retval other: fail
762 */
763int gsw_get_sim_imsi(int len, char *imsi);
764
765
766/**
767 * @brief get sim msisdn function
768 * @param [in] len msisdn length,max is 20
769 * @param [out] msisdn msisdn length,max is 20
770 * @retval 0: success
771 * @retval other: fail
772 */
773int gsw_get_sim_msisdn(int len, char *msisdn);
774
775
776/**
777 * @brief get imei function
778 * @param [in] len imei length,max is 20
779 * @param [out] imei return imei from this func
780 * @retval 0: success
781 * @retval other: fail
782 */
783int gsw_get_imei(int len, char *imei);
784
785
786/**
787 * @brief set sim power down
788 * @param
789 * @retval 0: success
790 * @retval other: fail
791 */
792int gsw_set_sim_power_down(void);
793
794
795/**
796 * @brief set sim power up
797 * @param
798 * @retval 0: success
799 * @retval other: fail
800 */
801int gsw_set_sim_power_up(void);
802
803
804/**
805 * @brief reset modem stack only,
806 * @details notice: after use this method, all ril sdk
807 * need restart, means network, sim, sms, data need deinit then init!
808 *
809 * @param
810 * @retval 0: success
811 * @retval other: fail
812 */
813int gsw_reset_modem(void);
814
815
816/**
817 * @brief send sms fuction
818 * @param [in] phone_num dest phone num send sms
819 * @param [in] char_set encode format for sms 0-7bit; 1-binary; 2-usc2
820 * @param [in] msg sms content
821 * @param [in] msg_len send sms length,max is 1024
822 * @retval 0: success
823 * @retval other: fail
824 */
825int gsw_send_sms(char *phone_num, int char_set, char *msg, int msg_len);
826
827
828/**
829 * @brief get smsc fuction
830 * @param [in] len input buf len for smsc,max is 32
831 * @param [out] smsc address for smsc get from this func *
832 * @retval 0: success
833 * @retval other: fail
834 */
835int gsw_get_smsc_address(int len, char *smsc);
836
837
838/**
839 * @brief set smsc fuction
840 * @param [out] smsc string value for smsc,max length is 32
841 * @retval 0: success
842 * @retval other: fail
843 */
844int gsw_set_smsc_address(const char *smsc);
845
846
847/**
848 * @brief convert rsrp rscp rssi to csq value.
849 * @param [in] netType signal radio tech 2 means 2G 3 mens 3G,4 is 4G,5 is 5G
850 * @param [in] sigvalue input signal_strength for different nettype
851 * rsrp for 4G/5G, rscp for 3G, rssi for 2G
852 * @retval 0: success
853 * @retval other: fail
854 */
855int gsw_sigInfo_to_csq(int netType, int sigValue);
856
857
858/**
859 * @brief data call event sdk callback function define
860 * @param [out] Wan_State_ind_s: data connection state and params indication struct
861 * include datacall state , ipv4 ipv6 address, dns address and ifname
862 * @retval void
863 */
864typedef void (*gsw_data_call_evt_cb_t)(Wan_State_ind_s *linkState);
865
866
867/**
868 * @brief use this api to wait data call event ind call back
869 * @param [out] arg
870 * @retval void
871 */
872void *gsw_onUnsolicited(void *arg);
873
874
875/**
876 * @brief datacall sdk init
877 * @param [in] gsw_data_call_evt_cb_t: data connection state change event
878 * call back;
879 * @retval 0: success
880 * @retval other: fail
881 */
882int gsw_data_call_init(gsw_data_call_evt_cb_t evt_cb);
883
884
885/**
886 * @brief data_call sdk deinit
887 * @param
888 * @retval 0: success
889 * @retval other: fail
890 */
891int gsw_data_call_deinit(void);
892
893/**
894 * @brief get apn info
895 * @param [in/out] gsw_apn_param_t:apn info for pub or private apn
896 * inlcude apn name mcc mnc, passwork apnid authtype iptype etc
897 * @return int : 0 is success , other failed
898 */
899void gsw_get_apn_info(int linkid, gsw_apn_param_t *apn_para);
900
901/**
902 * @brief set apn parameters for data call
903 * @param [in/out] Link_Info_s: for pub or private datacall
904 * inlcude apn name mcc mnc, passwork apnid type cid etc
905 * @retval 0: success
906 * @retval other: fail
907 */
908int gsw_data_call_set_apn(Link_Info_s *LinkInf);
909
910
911/**
912 * @brief set apn parameters for data call
913 * 接口超时时间:120s
914 * 如接口返回失败,不要给apn回调:gsw_data_call_evt_cb_t
915 * 如接口返回成功,从接口调用开始计时,到收到apn回调:gsw_data_call_evt_cb_t,不能超过120s
916 * @param [in] linkid data connetion link number
917 * @param [in/out] Link_Info_s: apn info for pub or private datacall
918 * inlcude apn name mcc mnc, passwork apnid etc
919 * resp: data call link state ipaddress type etc
920 * @retval 0: success
921 * @retval other: fail
922 */
923int gsw_data_call_connect(int linkid, Link_Info_s *LinkInf);
924
925
926/**
927 * @brief set apn parameters for data call
928 * @param [in] linkid
929 * @param [in/out] Link_Info_s: apn info for pub or private datacall
930 * inlcude apn name mcc mnc, passwork apnid etc
931 * resp: data call link state ipaddress type etc
932 * @retval 0: success
933 * @retval other: fail
934 */
935int gsw_data_call_disconnect(int linkid, Link_Info_s *LinkInf);
936
937
938/**
939 * @brief get the data traffic infos
940 @param [in] linkid apn id
941 @param [out] gsw_data_pkt_stats obtian actual data call network card data traffic
942 @retval 0: success
943 @retval 0: other: fail
944 */
945int gsw_get_data_call_pkt_stats(int linkid, gsw_data_pkt_stats *data_pkt);
946
947/**
948 * @brief clear data call if needed when receive apn down event
949 * @param [in] linkid
950 * @param [in/out] Link_Info_s: apn info for pub or private datacall
951 * inlcude apn name mcc mnc, passwork apnid etc
952 * resp: data call link state ipaddress type etc
953 * @retval 0: success
954 * @retval other: fail
955 */
956int gsw_data_call_clear_session(int linkid, Link_Info_s *LinkInf);
957
958/**
959 * @brief Set apn binding to specify interface id
960 * @details This interface supports a total of 8 reserved id information
961 * and the reserved id value ranges from 0-7
962 *
963 * @param [in] reserved_id: -1 unset reserved id,0-7 set reserved id
964 * @param [in] apn APN name
965 * @retval 0: success
966 * @retval other: fail
967 */
968int gsw_set_apn_reserved_id(int reserved_id, const char *apn);
969
970/**
971 * @brief Get the apn name bound to the specified interface id
972 * @param [in] reserved_id Network reserved interface id
973 * @param [out] apn_str APN name
974 * @param [in] apn_str_size APN name size
975 * @retval 0-7: success
976 * @retval -1: unbind reserved id
977 */
978int gsw_get_apn_reserved_name(int reserved_id, char *apn_str, int apn_str_size);
979
980/**
981 * @brief Get apn binding to specify interface id
982 * @param [in] apn
983 * @retval 0: success
984 * @retval 0-7: success
985 * @retval -1: unbind reserved id
986 */
987int gsw_get_apn_reserved_id(const char *apn);
988
989/**
990 * @brief Get get modem state
991 * @param
992 * @retval 0: ok
993 * @retval other: error
994 */
995
996int gsw_get_modem_state_exp(void);
997
998/**
999 * @brief set modem status event callback
1000 * @param [in] GSW_NW_ModemStateHandlePtr
1001 * @retval 0 : success
1002 * @retval other: fail
1003 */
1004int gsw_reg_set_modem_status_event_callback(GSW_NW_ModemStateHandlePtr handle_ptr);
1005
1006/**
1007 * @brief get tcamid function
1008 * @param [in] len tcamid length
1009 * @param [out] iccid return tcamid from this func
1010 * @retval 0 : success
1011 * @retval other: fail
1012 */
1013int gsw_get_tcamid(int len, char *tcamid);
1014
1015
1016/**
1017* @brief Module log disk drop, used when restarting or hibernating
1018* @param [in]void
1019* @retval void
1020*/
1021void gsw_modem_log_sync(void);
1022
1023#if defined(__cplusplus)
1024extern "C" }
1025#endif
1026
1027#endif /*GSW_NWINFO_INTERFACE_H*/