b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame^] | 1 | #include <stdlib.h> |
| 2 | #include <stdint.h> |
| 3 | #include <string.h> |
| 4 | #include <stdbool.h> |
| 5 | #include <stdio.h> |
| 6 | |
| 7 | //gsw include |
| 8 | #define GSW_HAL_SUCCESS 0 |
| 9 | #define GSW_HAL_FAIL -1 |
| 10 | #define GSW_HAL_MEM_INVAILD -2 |
| 11 | #define GSW_NW_OPERATION_NAME_LEN 128 |
| 12 | #define GSW_NW_PLMN_LEN 6 |
| 13 | #define GSW_NW_MCC_LEN 3 |
| 14 | #define GSW_NW_MNC_LEN 3 |
| 15 | #define GSW_NW_PARA_MAX_LEN 128 |
| 16 | #define GSW_MCC_MAX_LEN 16 |
| 17 | #define GSW_MNC_MAX_LEN 16 |
| 18 | #define GSW_APN_CHANNEL_MAX 10 |
| 19 | #define GSW_POXY_ADDR_MAX_LEN 64 |
| 20 | #define GSW_PDP_TYPE_MAX_LEN 16 |
| 21 | #define GSW_APN_MAX_LEN 65 |
| 22 | #define GSW_APN_ID_MAX_LEN 32 |
| 23 | #define GSW_APN_TYPE_MAX_LEN 50 |
| 24 | #define GSW_USR_MAX_LEN 16 |
| 25 | #define GSW_PWD_MAX_LEN 16 |
| 26 | #define GSW_AUTH_TYPE_MAX_LEN 50 |
| 27 | #define GSW_PROTOCO_MAX_LEN 64 |
| 28 | #define GSW_CARRIER_ID_MAX_LEN 64 |
| 29 | #define GSW_IFACE_NAME_MAX_LEN 50 |
| 30 | #define GSW_PDP_ADDR_MAX_LEN 64 |
| 31 | #define GSW_DNS_ADDR_MAX_LEN 64 |
| 32 | #define GSW_GETWAYS_ADDR_MAX_LEN 64 |
| 33 | #define GSW_RSP_MAX_LEN 256 |
| 34 | #define GSW_PLMN_LIST_MAX_LEN 64 |
| 35 | #define MAX_CELL_EXT_INFO (5) |
| 36 | |
| 37 | |
| 38 | |
| 39 | typedef enum service_domain |
| 40 | { |
| 41 | GSW_SRV_DOMAIN_NO_SVC = 0x0, /**< no service */ |
| 42 | GSW_SRV_DOMAIN_CS_ONLY = 0x1, /**< cs only */ |
| 43 | GSW_SRV_DOMAIN_PS_ONLY = 0x2, /**< ps only */ |
| 44 | GSW_SRV_DOMAIN_CS_PS = 0x3, /**< reg all in service */ |
| 45 | } GSW_SERVICE_DOMAIN_E; |
| 46 | |
| 47 | typedef enum gsw_network_reg_state |
| 48 | { |
| 49 | GSW_NETWORK_REG_NOT_REGISTERED = 0x0, /**< no service */ |
| 50 | GSW_NETWORK_REG_REGISTERED = 0x1, /**< reg in service home */ |
| 51 | GSW_NETWORK_REG_NOT_REGISTERED_SEARCHING = 0x2, /**< searching network */ |
| 52 | GSW_NETWORK_REG_REGISTRATION_DENIED = 0x3, /**< network denny device */ |
| 53 | GSW_NETWORK_REG_REGISTRATION_UNKNOWN = 0x4, /**< unknown state */ |
| 54 | GSW_NETWORK_REG_REGISTRATION_ROAMING = 0x5, /**< roaming state in service */ |
| 55 | GSW_NETWORK_REG_LIMITED_SERVICE = 0x6, /**< limited service */ |
| 56 | } GSW_NW_REG_STATE_E; |
| 57 | |
| 58 | typedef enum gsw_network_radio_interface |
| 59 | { |
| 60 | GSW_NETWORK_RADIO_NO_SVC = 0x0, /**< radio state no service */ |
| 61 | GSW_NETWORK_RADIO_CDMA_1X = 0x1, /**< cdma 1x */ |
| 62 | GSW_NETWORK_RADIO_CDMA_1XEVDO = 0x2, /**< cdma evdo */ |
| 63 | GSW_NETWORK_RADIO_AMPS = 0x3, /**< amps gsm 2g*/ |
| 64 | GSW_NETWORK_RADIO_GSM = 0x4, /**< gsm */ |
| 65 | GSW_NETWORK_RADIO_UMTS = 0x5, /**< umts wcdma*/ |
| 66 | GSW_NETWORK_RADIO_LTE = 0x6, /**< LTE 4G */ |
| 67 | GSW_NETWORK_RADIO_TDSCDMA = 0x7, /**< TDS 3G*/ |
| 68 | GSW_NETWORK_RADIO_NR5G = 0x8, /**< NR 5G*/ |
| 69 | } GSW_NW_RADIO_ACCESS_TECH_E; |
| 70 | |
| 71 | |
| 72 | typedef enum gsw_network_roaming_state |
| 73 | { |
| 74 | GSW_NETWORK_ROAMING_OFF = 0x0, /**< roaming off */ |
| 75 | GSW_NETWORK_ROAMING_ON = 0x1, /**< roaming on*/ |
| 76 | } GSW_NW_ROAMING_STATE_E; |
| 77 | |
| 78 | typedef enum oprate_mode |
| 79 | { |
| 80 | GSW_OP_MODE_LPM = 0, /**< radio state off*/ |
| 81 | GSW_OP_MODE_ONLINE = 1, /**< radio state on*/ |
| 82 | GSW_OP_MODE_FTM = 2, /**< radio state ftm*/ |
| 83 | GSW_OP_MODE_OFFLINE = 3, /**< radio state offline*/ |
| 84 | } OPERATE_MODE_E; |
| 85 | |
| 86 | typedef enum prefer_mode |
| 87 | { |
| 88 | GSW_PREFER_MODE_GSW = 1, /**<2G only*/ |
| 89 | GSW_PREFER_MODE_WCDMA = 2, /**< 3G only*/ |
| 90 | GSW_PREFER_MODE_WCDMA_GSM = 3, /**< 3G/2G*/ |
| 91 | GSW_PREFER_MODE_LTE = 4, /**< 4G only*/ |
| 92 | GSW_PREFER_MODE_NR5G = 5, /**< 5G only*/ |
| 93 | GSW_PREFER_MODE_NR5G_LTE = 8, /**< 5G/4G*/ |
| 94 | GSW_PREFER_MODE_LTE_WCDMA_GSM = 9, /**< 4G/3G/2G*/ |
| 95 | GSW_PREFER_MODE_NR5G_LTE_WCDMA_GSM = 32, /**< 5G/4G/3G/2G*/ |
| 96 | } PREFER_MODE_E; |
| 97 | |
| 98 | typedef enum gsw_hal_nw_mode_state_type |
| 99 | { |
| 100 | GSW_MODEM_STATE_UNKNOWN = 0, |
| 101 | GSW_MODEM_STATE_ONLINE, |
| 102 | GSW_MODEM_STATE_OFFLINE, |
| 103 | GSW_SDK_STATE_SERVICE_DOWN, |
| 104 | GSW_SDK_STATE_SERVICE_UP,// service down->up 需要routectl 重启 |
| 105 | GSW_SDK_STATE_GPS_DOWN, |
| 106 | GSW_SDK_STATE_GPS_UP, |
| 107 | } gsw_mode_state_e; |
| 108 | |
| 109 | |
| 110 | typedef struct |
| 111 | { |
| 112 | GSW_NW_RADIO_ACCESS_TECH_E rej_rat; /**< current network radio tech*/ |
| 113 | GSW_SERVICE_DOMAIN_E rej_domain; /**< reject code from ps or cs*/ |
| 114 | int rej_cause; /**< reject code number*/ |
| 115 | } GSW_NW_REJ_CAUSE_E; |
| 116 | |
| 117 | typedef struct |
| 118 | { |
| 119 | int32_t gw_sig_valid; /**< 1 valid,1 invalid*/ |
| 120 | int32_t rssi; /**< Valid values are (0-31, 99) as defined in TS 27.007 8.5 */ |
| 121 | int32_t wcdma_sig_valid;/**< 1 valid,0 invalid*/ |
| 122 | int32_t rscp; /**< The Received Signal Code Power in dBm multipled by -1. |
| 123 | * Range : 25 to 120 |
| 124 | * INT_MAX: 0x7FFFFFFF denotes invalid value. |
| 125 | * Reference: 3GPP TS 25.123, section 9.1.1.1 */ |
| 126 | int32_t ecno; /**< Valid values are positive integers. This value is the actual Ec/Io multiplied |
| 127 | * by -10. Example: If the actual Ec/Io is -12.5 dB, then this response value |
| 128 | * will be 125.*/ |
| 129 | int32_t lte_sig_valid;/**< 1 valid,0 invalid*/ |
| 130 | int32_t rsrp; /**< The current Reference Signal Receive Power in dBm multipled by -1. |
| 131 | * Range: 44 to 140 dBm |
| 132 | * INT_MAX: 0x7FFFFFFF denotes invalid value. |
| 133 | * Reference: 3GPP TS 36.133 9.1.4 */ |
| 134 | int32_t rsrq; /**< The current Reference Signal Receive Quality in dB multiplied by -1. |
| 135 | * Range: 20 to 3 dB. |
| 136 | * INT_MAX: 0x7FFFFFFF denotes invalid value. |
| 137 | * Reference: 3GPP TS 36.133 9.1.7 */ |
| 138 | int32_t rssnr; /**< The current reference signal signal-to-noise ratio in 0.1 dB units. |
| 139 | * Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB). |
| 140 | * INT_MAX : 0x7FFFFFFF denotes invalid value. |
| 141 | * Reference: 3GPP TS 36.101 8.1.1 */ |
| 142 | int32_t nr_sig_valid;/**<1 valid,0 invalid*/ |
| 143 | int32_t ssRsrp; /**< SS(Synchronization Signal) reference signal received power, multipled by -1. |
| 144 | * Reference: 3GPP TS 38.215. |
| 145 | * Range [44, 140], INT_MAX means invalid/unreported.*/ |
| 146 | int32_t ssRsrq; /**< SS reference signal received quality, multipled by -1. |
| 147 | * Reference: 3GPP TS 38.215. |
| 148 | * Range [3, 20], INT_MAX means invalid/unreported.*/ |
| 149 | int32_t ssSinr; /**< SS signal-to-noise and interference ratio. |
| 150 | * Reference: 3GPP TS 38.215 section 5.1.*, 3GPP TS 38.133 section 10.1.16.1. |
| 151 | * Range [-23, 40], INT_MAX means invalid/unreported.*/ |
| 152 | int32_t csiRsrp; /**< CSI reference signal received power, multipled by -1. |
| 153 | * Reference: 3GPP TS 38.215. |
| 154 | * Range [44, 140], INT_MAX means invalid/unreported.*/ |
| 155 | int32_t csiRsrq; /**< CSI reference signal received quality, multipled by -1. |
| 156 | * Reference: 3GPP TS 38.215. |
| 157 | * Range [3, 20], INT_MAX means invalid/unreported.*/ |
| 158 | int32_t csiSinr; /**< CSI signal-to-noise and interference ratio. |
| 159 | * Reference: 3GPP TS 138.215 section 5.1.*, 3GPP TS 38.133 section 10.1.16.1. |
| 160 | * Range [-23, 40], INT_MAX means invalid/unreported.*/ |
| 161 | } signalStrength_t; |
| 162 | |
| 163 | typedef struct |
| 164 | { |
| 165 | GSW_NW_REG_STATE_E reg_state; /**< network cs regstate*/ |
| 166 | GSW_NW_REG_STATE_E ps_state; /**< network ps regstate*/ |
| 167 | GSW_NW_RADIO_ACCESS_TECH_E reg_rat; /**< current radio state*/ |
| 168 | GSW_SERVICE_DOMAIN_E srv_domain; /**< current cs or ps state*/ |
| 169 | GSW_NW_ROAMING_STATE_E roaming_ind; /**< roaming state*/ |
| 170 | char reg_plmn[GSW_NW_PLMN_LEN + 1]; /**< current cell plmn*/ |
| 171 | char operator_name[GSW_NW_OPERATION_NAME_LEN + 1]; /**< operator name*/ |
| 172 | char cell_id[128]; /**< cell id*/ |
| 173 | char tac[128]; /**< cell tac*/ |
| 174 | char lac[128]; /**< cell lac*/ |
| 175 | int sid; /**< cell sid cdma*/ |
| 176 | int nid; /**< cell nid cdma*/ |
| 177 | } GSW_NW_SERVING_INFO; |
| 178 | |
| 179 | |
| 180 | typedef struct |
| 181 | { |
| 182 | char long_eons[128]; /* Full name of the operator*/ |
| 183 | char short_eons[128]; /* Shor name of the operator*/ |
| 184 | char mcc[4]; /* Mobile country code*/ |
| 185 | char mnc[4]; /* Mobile network code*/ |
| 186 | }gsw_mobile_operator_name; |
| 187 | |
| 188 | |
| 189 | typedef struct |
| 190 | { |
| 191 | unsigned char cell_id_valid; |
| 192 | unsigned char pci_valid; |
| 193 | unsigned char psc_valid; |
| 194 | unsigned char band_valid; |
| 195 | unsigned char arfcn_valid; |
| 196 | unsigned char rssi_valid; |
| 197 | unsigned char rsrp_valid; |
| 198 | unsigned char rsrq_valid; |
| 199 | unsigned char sinr_valid; |
| 200 | unsigned char rscp_valid; |
| 201 | unsigned char ecio_valid; |
| 202 | GSW_NW_RADIO_ACCESS_TECH_E rat; |
| 203 | unsigned int cell_id; |
| 204 | int pci; |
| 205 | int psc; |
| 206 | int band; |
| 207 | int arfcn; |
| 208 | int rssi; |
| 209 | int rsrp; |
| 210 | int rsrq; |
| 211 | int sinr; |
| 212 | int rscp; |
| 213 | int ecio; |
| 214 | char mcc[5]; |
| 215 | char mnc[5]; |
| 216 | } GSW_NW_CELL_EXT_INFO; |
| 217 | |
| 218 | typedef struct |
| 219 | { |
| 220 | GSW_NW_RADIO_ACCESS_TECH_E rat; /**< current radio state*/ |
| 221 | |
| 222 | unsigned char mcc_valid; |
| 223 | char mcc[5]; |
| 224 | |
| 225 | unsigned char mnc_valid; |
| 226 | char mnc[5]; |
| 227 | |
| 228 | unsigned char cell_id_valid; |
| 229 | unsigned int cell_id; /**< cell id*/ |
| 230 | |
| 231 | unsigned char pci_valid; |
| 232 | int pci; /**<physical cell id*/ |
| 233 | |
| 234 | unsigned char psc_valid; |
| 235 | int psc; /*wcdma primary scramble code*/ |
| 236 | |
| 237 | unsigned char nrarfcn_valid; |
| 238 | int nrarfcn; /*nr cell freq*/ |
| 239 | |
| 240 | unsigned char earfcn_valid; |
| 241 | int earfcn; /*lte cell freq*/ |
| 242 | |
| 243 | unsigned char uarfcn_valid; |
| 244 | int uarfcn; /*wcdma cell freq*/ |
| 245 | |
| 246 | unsigned char arfcn_valid; |
| 247 | int arfcn; /*gsw cell freq*/ |
| 248 | |
| 249 | unsigned char tac_valid; |
| 250 | unsigned int tac; /**< cell tac*/ |
| 251 | |
| 252 | unsigned char lac_valid; |
| 253 | unsigned int lac; /**< cell lac*/ |
| 254 | |
| 255 | unsigned char sid_valid; |
| 256 | int sid; /**< cell sid cdma*/ |
| 257 | |
| 258 | unsigned char nid_valid; |
| 259 | int nid; /**< cell nid cdma*/ |
| 260 | |
| 261 | unsigned char lteMode_valid; |
| 262 | int lteMode; /*tdd 0, fdd 1*/ |
| 263 | |
| 264 | unsigned char rssi_valid; |
| 265 | int rssi; /**< Valid values are (0-31, 99) as defined in TS 27.007 8.5 */ |
| 266 | |
| 267 | unsigned char rscp_valid; |
| 268 | int rscp; /**< The Received Signal Code Power in dBm multipled by -1. |
| 269 | * Range : 25 to 120 |
| 270 | * INT_MAX: 0x7FFFFFFF denotes invalid value. |
| 271 | * Reference: 3GPP TS 25.123, section 9.1.1.1 */ |
| 272 | |
| 273 | unsigned char ecio_valid; |
| 274 | int ecio; /**< Valid values are positive integers. This value is the actual Ec/Io multiplied |
| 275 | * by -10. Example: If the actual Ec/Io is -12.5 dB, then this response value |
| 276 | * will be 125.*/ |
| 277 | |
| 278 | unsigned char rsrp_valid; |
| 279 | int rsrp; /**< The current Reference Signal Receive Power in dBm multipled by -1. |
| 280 | * Range: 44 to 140 dBm |
| 281 | * INT_MAX: 0x7FFFFFFF denotes invalid value. |
| 282 | * Reference: 3GPP TS 36.133 9.1.4 */ |
| 283 | |
| 284 | unsigned char rsrq_valid; |
| 285 | int rsrq; /**< The current Reference Signal Receive Quality in dB multiplied by -1. |
| 286 | * Range: 20 to 3 dB. |
| 287 | * INT_MAX: 0x7FFFFFFF denotes invalid value. |
| 288 | * Reference: 3GPP TS 36.133 9.1.7 */ |
| 289 | |
| 290 | unsigned char rssnr_valid; |
| 291 | int rssnr; /**< The current reference signal signal-to-noise ratio in 0.1 dB units. |
| 292 | * Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB). |
| 293 | * INT_MAX : 0x7FFFFFFF denotes invalid value. |
| 294 | * Reference: 3GPP TS 36.101 8.1.1 */ |
| 295 | |
| 296 | unsigned char band_valid; |
| 297 | int band; |
| 298 | |
| 299 | unsigned char bler_valid; |
| 300 | int bler; /*bit error rate*/ |
| 301 | |
| 302 | GSW_NW_CELL_EXT_INFO ext_info[MAX_CELL_EXT_INFO]; /* Used to hold neighborhood information for service cells. */ |
| 303 | } GSW_NW_CELL_INFO; |
| 304 | |
| 305 | typedef struct { |
| 306 | char mcc[GSW_MCC_MAX_LEN]; |
| 307 | char mnc[GSW_MNC_MAX_LEN]; |
| 308 | } gsw_nw_plmn_t; |
| 309 | |
| 310 | |
| 311 | typedef struct { |
| 312 | int plmn_list_len; |
| 313 | gsw_nw_plmn_t plmn_list[GSW_PLMN_LIST_MAX_LEN]; |
| 314 | } gsw_nw_plmn_list_t; |
| 315 | |
| 316 | typedef void (* GSW_NW_ServingInfoHandlePtr)(GSW_NW_SERVING_INFO serving_info); |
| 317 | typedef void (* GSW_NW_SigInfoHandlePtr)(signalStrength_t sig_info); |
| 318 | typedef void (* GSW_NW_RejectCauseHandlePtr)(GSW_NW_REJ_CAUSE_E *rej_cause); |
| 319 | typedef void (* GSW_NW_AirplaneModeHandlePtr)(int32_t airplane_mode); |
| 320 | typedef void (* GSW_NW_ModemStateHandlePtr)(gsw_mode_state_e state); |
| 321 | |
| 322 | |
| 323 | /*--------------------------------------------------------------------------------------------------------------------*/ |
| 324 | /* Data call */ |
| 325 | /*--------------------------------------------------------------------------------------------------------------------*/ |
| 326 | #define GSW_MCC_MAX_LEN 16 |
| 327 | #define GSW_MNC_MAX_LEN 16 |
| 328 | #define GSW_APN_CHANNEL_MAX 10 |
| 329 | #define GSW_POXY_ADDR_MAX_LEN 64 |
| 330 | #define GSW_PDP_TYPE_MAX_LEN 16 |
| 331 | #define GSW_APN_MAX_LEN 65 |
| 332 | #define GSW_APN_ID_MAX_LEN 32 |
| 333 | #define GSW_APN_TYPE_MAX_LEN 50 |
| 334 | #define GSW_USR_MAX_LEN 16 |
| 335 | #define GSW_PWD_MAX_LEN 16 |
| 336 | #define GSW_AUTH_TYPE_MAX_LEN 50 |
| 337 | #define GSW_PROTOCO_MAX_LEN 64 |
| 338 | #define GSW_CARRIER_ID_MAX_LEN 64 |
| 339 | #define GSW_IFACE_NAME_MAX_LEN 50 |
| 340 | #define GSW_PDP_ADDR_MAX_LEN 64 |
| 341 | #define GSW_DNS_ADDR_MAX_LEN 64 |
| 342 | #define GSW_GETWAYS_ADDR_MAX_LEN 64 |
| 343 | #define GSW_RSP_MAX_LEN 256 |
| 344 | |
| 345 | typedef struct { |
| 346 | int handle; /**< data connection handle*/ |
| 347 | int cid; /**< data connection cid*/ |
| 348 | int state; /**< data connection state*/ |
| 349 | int fail_cause; /**< data connection fail cause*/ |
| 350 | char *type; /**< data connection type*/ |
| 351 | char *ifname; /**< ifname*/ |
| 352 | |
| 353 | char *v4_ip; /**< ipv4 address*/ |
| 354 | char *v4_pdns; /**< ipv4 pdns address*/ |
| 355 | char *v4_sdns; /**< ipv4 sdns address*/ |
| 356 | char *v4_gw; /**< ipv4 gateway address*/ |
| 357 | |
| 358 | char *v6_ip; /**< ipv6 address*/ |
| 359 | char *v6_pdns; /**< ipv6 gateway address*/ |
| 360 | char *v6_sdns; /**< ipv6 gateway address*/ |
| 361 | }Wan_State_ind_s; |
| 362 | |
| 363 | typedef struct { |
| 364 | char ip[GSW_PDP_ADDR_MAX_LEN]; /**< ip address */ |
| 365 | char pdns[GSW_DNS_ADDR_MAX_LEN]; /**< pdns address*/ |
| 366 | char sdns[GSW_DNS_ADDR_MAX_LEN]; /**< sdns address*/ |
| 367 | char gw[GSW_GETWAYS_ADDR_MAX_LEN]; /**< gate way address*/ |
| 368 | }V4_Addr_s; |
| 369 | |
| 370 | typedef struct { |
| 371 | char ip[GSW_PDP_ADDR_MAX_LEN]; /**< ip address*/ |
| 372 | char pdns[GSW_DNS_ADDR_MAX_LEN]; /**< pdns address*/ |
| 373 | char sdns[GSW_DNS_ADDR_MAX_LEN]; /**< sdns address*/ |
| 374 | }V6_Addr_s; |
| 375 | |
| 376 | typedef struct { |
| 377 | int handle; /**< data connection handle*/ |
| 378 | |
| 379 | /* req info */ |
| 380 | char mcc[GSW_MCC_MAX_LEN]; /**< apn mcc value*/ |
| 381 | char mnc[GSW_MNC_MAX_LEN]; /**< apn mnc value*/ |
| 382 | char apnid[GSW_APN_ID_MAX_LEN]; /**< apn id*/ |
| 383 | char apn[GSW_APN_MAX_LEN]; /**< apn name*/ |
| 384 | char apnType[GSW_APN_TYPE_MAX_LEN]; /**< apn type ipv4 ipv4v6 ipv6*/ |
| 385 | char usr[GSW_USR_MAX_LEN]; /**< apn usr name*/ |
| 386 | char pwd[GSW_PWD_MAX_LEN]; /**< apn password*/ |
| 387 | char authType[GSW_AUTH_TYPE_MAX_LEN]; /**< apn auth type*/ |
| 388 | char normalProtocol[GSW_PROTOCO_MAX_LEN]; /**< apn auth protoco*/ |
| 389 | char roamingProtocol[GSW_PROTOCO_MAX_LEN]; /**< apn auth protoco roaming*/ |
| 390 | char carrier[GSW_CARRIER_ID_MAX_LEN]; /**< carrier id*/ |
| 391 | |
| 392 | /* rsp */ |
| 393 | int cid; /**< data connection cid for mdm sdk*/ |
| 394 | int active; /**< pdn context active state: 2,actived; other,not active */ |
| 395 | char ifname[GSW_IFACE_NAME_MAX_LEN]; /**< if name of current datalink */ |
| 396 | int type; /**< data connection type*/ |
| 397 | V4_Addr_s v4; /**< ipv4 addr*/ |
| 398 | V6_Addr_s v6; /**< ipv6 addr*/ |
| 399 | int mtu; /**< mtu value*/ |
| 400 | |
| 401 | char out[GSW_RSP_MAX_LEN]; /**< sdk return value*/ |
| 402 | }Link_Info_s; |
| 403 | |
| 404 | typedef struct |
| 405 | { |
| 406 | uint64_t tx_pkts; /* the number of packet sent*/ |
| 407 | uint64_t tx_bytes; /* the number of packet sent bytes */ |
| 408 | uint64_t tx_dropped_pkts; /* the number of packet dropped by sent*/ |
| 409 | uint64_t rx_pkts; /* the number of packet received*/ |
| 410 | uint64_t rx_bytes; /* the number of packet receivedbytes */ |
| 411 | uint64_t rx_dropped_pkts; /* the number of packet dropped by received*/ |
| 412 | }gsw_data_pkt_stats; |
| 413 | |
| 414 | |
| 415 | typedef void (*gsw_data_call_evt_cb_t)(Wan_State_ind_s *linkState); |
| 416 | |
| 417 | |
| 418 | /*--------------------------------------------------------------------------------------------------------------------*/ |
| 419 | /* sim */ |
| 420 | /*--------------------------------------------------------------------------------------------------------------------*/ |
| 421 | |
| 422 | typedef enum sim_status |
| 423 | { |
| 424 | SIM_STATUS_ABSENT = 0, /**< sim absent*/ |
| 425 | SIM_STATUS_PRESENT = 1, /**< sim present mtk as ready*/ |
| 426 | SIM_STATUS_ERROR = 2, /**< sim error*/ |
| 427 | SIM_STATUS_READY = 3, /**< sim state ready mtk no this value*/ |
| 428 | SIM_STATUS_PIN = 4, /**< pinlock status*/ |
| 429 | } sim_status_e_type; |
| 430 | |
| 431 | |
| 432 | |
| 433 | /** |
| 434 | * @brief SDK interface to call back serving info |
| 435 | * @param [in] handle_ptr |
| 436 | * @retval 0: success |
| 437 | * @retval other: fail |
| 438 | */ |
| 439 | int gsw_reg_serving_info_callback(GSW_NW_ServingInfoHandlePtr handle_ptr); |
| 440 | |
| 441 | /** |
| 442 | * @brief SDK interface to call back sig info |
| 443 | * @param [in] handle_ptr |
| 444 | * @retval 0: success |
| 445 | * @retval other: fail |
| 446 | */ |
| 447 | int gsw_reg_sig_info_callback(GSW_NW_SigInfoHandlePtr handle_ptr); |
| 448 | |
| 449 | /** |
| 450 | * @brief SDK interface to call back rej cause |
| 451 | * @param [in] handle_ptr |
| 452 | * @retval 0: success |
| 453 | * @retval other: fail |
| 454 | */ |
| 455 | int gsw_reg_rej_cause_callback(GSW_NW_RejectCauseHandlePtr handle_ptr); |
| 456 | |
| 457 | /** |
| 458 | * @brief network sdk init |
| 459 | * @param [in] token usr id define by who use |
| 460 | * @retval 0: success |
| 461 | * @retval other: fail |
| 462 | */ |
| 463 | int gsw_nw_sdk_init(int token); |
| 464 | |
| 465 | /** |
| 466 | * @brief network sdk deinit |
| 467 | * @param |
| 468 | * @retval 0: success |
| 469 | * @retval other: fail |
| 470 | */ |
| 471 | int gsw_nw_sdk_deinit(void); |
| 472 | |
| 473 | /** |
| 474 | * @brief get current network reg info |
| 475 | * @param [out] serving_info struct for network info |
| 476 | * include regstate ps_state opreator name mcc mcn etc |
| 477 | * @retval 0: success |
| 478 | * @retval other: fail |
| 479 | */ |
| 480 | int gsw_get_nwinfo(GSW_NW_SERVING_INFO *serving_info); |
| 481 | |
| 482 | /** |
| 483 | * @brief get current network type |
| 484 | * @param [out] netype as GSW_NW_RADIO_ACCESS_TECH_E type |
| 485 | * @retval 0: success |
| 486 | * @retval other: fail |
| 487 | */ |
| 488 | int gsw_get_netype(int32_t *netype); |
| 489 | |
| 490 | /** |
| 491 | * @brief get radio opmode, as open and close airplane mode |
| 492 | * @param [out] op_mode 1 is radio on, 0 is radio off |
| 493 | * @retval 0: success |
| 494 | * @retval other: fail |
| 495 | */ |
| 496 | int gsw_get_opmode(int *op_mode); |
| 497 | |
| 498 | /** |
| 499 | * @brief set radio opmode, as open and close airplane mode |
| 500 | * @param [in] op_mode 1 is radio on, 0 is radio off |
| 501 | * @retval 0: success |
| 502 | * @retval other: fail |
| 503 | */ |
| 504 | int gsw_set_opmode(int32_t op_mode); |
| 505 | |
| 506 | /** |
| 507 | * @brief get network mode preference of mdm search network scale |
| 508 | * @param [out] mode_pref net_work pref mode: |
| 509 | * enum prefer_mode |
| 510 | * @retval 0: success |
| 511 | * @retval other: fail |
| 512 | */ |
| 513 | int gsw_get_mode_preference(int32_t *mode_pref); |
| 514 | |
| 515 | /** |
| 516 | * @brief set network mode preference of mdm search network scale |
| 517 | * @param [in] mode_pref net_work pref mode: |
| 518 | * enum prefer_mode |
| 519 | * @retval 0: success |
| 520 | * @retval other: fail |
| 521 | */ |
| 522 | int gsw_set_mode_preference(int32_t mode_pref); |
| 523 | |
| 524 | /** |
| 525 | * @brief get signal csq value |
| 526 | * @param [out] csq_value csq of signalstrengh 0 - 31, 99 invalid |
| 527 | * @retval 0: success |
| 528 | * @retval other: fail |
| 529 | */ |
| 530 | int gsw_get_sig_info(int32_t *csq_value); |
| 531 | |
| 532 | /** |
| 533 | * @brief set nework power mode, for tcam enter standby or exit standby |
| 534 | * @param [in] mode TRUE(1) when enter standby, FALSE(0) after wake up |
| 535 | * @retval 0: success |
| 536 | * @retval other: fail |
| 537 | */ |
| 538 | int gsw_network_set_power_mode(int8_t mode); |
| 539 | |
| 540 | /** |
| 541 | * @brief convert rsrp rscp rssi to csq value. |
| 542 | * @param [in] netType signal radio tech 2 means 2G 3 mens 3G,4 is 4G,5 is 5G |
| 543 | * @param [in] sigvalue input signal_strength for different nettype |
| 544 | * rsrp for 4G/5G, rscp for 3G, rssi for 2G |
| 545 | |
| 546 | * @retval csq |
| 547 | * @retval other: fail |
| 548 | */ |
| 549 | int gsw_sigInfo_to_csq(int32_t netType, int32_t sigValue); |
| 550 | |
| 551 | /* |
| 552 | * @brief get PLMNs from the FPLMN list |
| 553 | * @param [inout] plmn_list: |
| 554 | * @retval 0: success |
| 555 | * @retval other: fail |
| 556 | */ |
| 557 | int gsw_get_forbidden_networks(gsw_nw_plmn_list_t *plmn_list); |
| 558 | |
| 559 | /* |
| 560 | * @brief add PLMNs from the plmn_list to the FPLMN list |
| 561 | * @param [in] plmn_list: |
| 562 | * @retval 0: success |
| 563 | * @retval other: fail |
| 564 | */ |
| 565 | int gsw_add_forbidden_networks(gsw_nw_plmn_list_t *plmn_list); |
| 566 | |
| 567 | /* |
| 568 | * @brief Remove PLMNs from the plmn_list from the FPLMN list |
| 569 | * @param [in] plmn_list: |
| 570 | * @retval 0: success |
| 571 | * @retval other: fail |
| 572 | */ |
| 573 | int gsw_remove_forbidden_networks(gsw_nw_plmn_list_t *plmn_list); |
| 574 | |
| 575 | /* |
| 576 | * @brief clear FPLMN list |
| 577 | * @param |
| 578 | * @retval 0: success |
| 579 | * @retval other: fail |
| 580 | */ |
| 581 | int gsw_clear_forbidden_networks(void); |
| 582 | |
| 583 | |
| 584 | |
| 585 | /* |
| 586 | * @brief get mobile operator name |
| 587 | @param [out] nw_operator_name_infos get the long and short operator name info |
| 588 | @retval 0: success |
| 589 | @retval 0: other: fail |
| 590 | */ |
| 591 | int gsw_get_mobile_operator_name(gsw_mobile_operator_name *nw_operator_name_infos); |
| 592 | |
| 593 | |
| 594 | |
| 595 | /* |
| 596 | * @brief set modem status event callback |
| 597 | @param [in] handle_ptr callback function address |
| 598 | @retval 0: success |
| 599 | @retval 0: other: fail |
| 600 | */ |
| 601 | int gsw_reg_set_modem_status_event_callback(GSW_NW_ModemStateHandlePtr handle_ptr); |
| 602 | |
| 603 | |
| 604 | /* |
| 605 | * @brief get current serving cell info |
| 606 | * @param cell_info: [out] struct for current cell info |
| 607 | * include earfcn mcc mnc pci psc tac lac etc. |
| 608 | * @return int: 0 is success, other failed |
| 609 | */ |
| 610 | int gsw_get_cell_info(GSW_NW_CELL_INFO *cell_info); |
| 611 | |
| 612 | /** |
| 613 | * @brief datacall sdk init |
| 614 | * @param [in] evt_cb callback function for data connection state change event |
| 615 | * call back; |
| 616 | * @retval 0: success |
| 617 | * @retval other: fail |
| 618 | */ |
| 619 | int gsw_data_call_init(gsw_data_call_evt_cb_t evt_cb); |
| 620 | |
| 621 | |
| 622 | /** |
| 623 | * @brief data_call sdk deinit |
| 624 | * @param |
| 625 | * @retval 0: success |
| 626 | * @retval other: fail |
| 627 | */ |
| 628 | int gsw_data_call_deinit(void); |
| 629 | |
| 630 | /** |
| 631 | * @brief set apn parameters for data call |
| 632 | * @param [in/out] LinkInf apn info for pub or private datacall |
| 633 | * inlcude apn name mcc mnc, passwork apnid type cid etc |
| 634 | * @retval 0: success |
| 635 | * @retval other: fail |
| 636 | */ |
| 637 | int gsw_data_call_set_apn(Link_Info_s *LinkInf); |
| 638 | |
| 639 | |
| 640 | /** |
| 641 | * @brief set apn parameters for data call |
| 642 | * @param [in] linkid data connetion link number |
| 643 | * @param [in/out] LinkInf link info req: apn info for pub or private datacall |
| 644 | * inlcude apn name mcc mnc, passwork apnid etc |
| 645 | * resp: data call link state ipaddress type etc |
| 646 | * @retval 0: success |
| 647 | * @retval other: fail |
| 648 | */ |
| 649 | int gsw_data_call_connect(int linkid, Link_Info_s *LinkInf); |
| 650 | |
| 651 | |
| 652 | /** |
| 653 | * @brief set apn parameters for data call |
| 654 | * @param [in] linkid |
| 655 | * @param [in/out] LinkInf link info req: apn info for pub or private datacall |
| 656 | * inlcude apn name mcc mnc, passwork apnid etc |
| 657 | * resp: data call link state ipaddress type etc |
| 658 | * @retval 0: success |
| 659 | * @retval other: fail |
| 660 | */ |
| 661 | int gsw_data_call_disconnect(int linkid, Link_Info_s *LinkInf); |
| 662 | |
| 663 | |
| 664 | |
| 665 | /* |
| 666 | * @brief get mobile operator name |
| 667 | @param [in] linkid apn id |
| 668 | @param [out] data_pkt obtian actual data call network card data traffic |
| 669 | @retval 0: success |
| 670 | @retval 0: other: fail |
| 671 | */ |
| 672 | int gsw_get_data_call_pkt_stats(int linkid, gsw_data_pkt_stats *data_pkt); |
| 673 | |
| 674 | |
| 675 | /** |
| 676 | * @brief sim sdk init |
| 677 | * @param [in] token usr id define by who use |
| 678 | * @retval 0: success |
| 679 | * @retval other: fail |
| 680 | */ |
| 681 | int gsw_sim_sdk_init(int32_t token); |
| 682 | |
| 683 | |
| 684 | /** |
| 685 | * @brief sim sdk deinit |
| 686 | * @param |
| 687 | * @retval 0: success |
| 688 | * @retval other: fail |
| 689 | */ |
| 690 | int gsw_sim_sdk_deinit(void); |
| 691 | |
| 692 | /** |
| 693 | * @brief get sim state |
| 694 | * @param [out] sim_state sim status as sim_status_e_type |
| 695 | * @retval 0: success |
| 696 | * @retval other: fail |
| 697 | */ |
| 698 | int gsw_get_sim_status(int32_t *sim_state); |
| 699 | |
| 700 | /** |
| 701 | * @brief get iccid function |
| 702 | * @param [in] len iccid length,max is 20 |
| 703 | * @param [out] iccid return iccid from this func |
| 704 | * @retval 0: success |
| 705 | * @retval other: fail |
| 706 | */ |
| 707 | int gsw_get_sim_iccid(int32_t len, int8_t *iccid); |
| 708 | |
| 709 | /** |
| 710 | * @brief get imsi function |
| 711 | * @param [in] len imsi length,max is 20 |
| 712 | * @param [out] iccid return imsi from this func |
| 713 | * @retval 0: success |
| 714 | * @retval other: fail |
| 715 | */ |
| 716 | int gsw_get_sim_imsi(int32_t len, int8_t *imsi); |
| 717 | |
| 718 | /** |
| 719 | * @brief get sim msisdn function |
| 720 | * @param [in] len msisdn length,max is 20 |
| 721 | * @param [out] msisdn msisdn length,max is 20 |
| 722 | * @retval 0: success |
| 723 | * @retval other: fail |
| 724 | */ |
| 725 | int gsw_get_sim_msisdn(int32_t len, int8_t *msisdn); |
| 726 | |
| 727 | /** |
| 728 | * @brief get imei function |
| 729 | * @param [in] len imei length,max is 20 |
| 730 | * @param [out] imei return imei from this func |
| 731 | * @retval 0: success |
| 732 | * @retval other: fail |
| 733 | */ |
| 734 | int gsw_get_imei(int32_t len, int8_t *imei); |
| 735 | |
| 736 | /** |
| 737 | * @brief set sim power down |
| 738 | * @param |
| 739 | * @retval 0: success |
| 740 | * @retval other: fail |
| 741 | */ |
| 742 | int gsw_set_sim_power_down(void); |
| 743 | |
| 744 | /** |
| 745 | * @brief set sim power up |
| 746 | * @param |
| 747 | * @retval 0: success |
| 748 | * @retval other: fail |
| 749 | */ |
| 750 | int gsw_set_sim_power_up(void); |
| 751 | |
| 752 | /** |
| 753 | * @brief reset modem stack only, notice: after use this method, all ril sdk |
| 754 | * need restart by app, means network, sim, sms, data need deinit then init! |
| 755 | * @param |
| 756 | * @retval 0: success |
| 757 | * @retval other: fail |
| 758 | */ |
| 759 | int gsw_reset_modem(void); |
| 760 | |
| 761 | |
| 762 | |