| #include <stdlib.h> |
| #include <stdint.h> |
| #include <string.h> |
| #include <stdbool.h> |
| #include <stdio.h> |
| |
| //gsw include |
| #define GSW_HAL_SUCCESS 0 |
| #define GSW_HAL_FAIL -1 |
| #define GSW_HAL_MEM_INVAILD -2 |
| #define GSW_NW_OPERATION_NAME_LEN 128 |
| #define GSW_NW_PLMN_LEN 6 |
| #define GSW_NW_MCC_LEN 3 |
| #define GSW_NW_MNC_LEN 3 |
| #define GSW_NW_PARA_MAX_LEN 128 |
| #define GSW_MCC_MAX_LEN 16 |
| #define GSW_MNC_MAX_LEN 16 |
| #define GSW_APN_CHANNEL_MAX 10 |
| #define GSW_POXY_ADDR_MAX_LEN 64 |
| #define GSW_PDP_TYPE_MAX_LEN 16 |
| #define GSW_APN_MAX_LEN 65 |
| #define GSW_APN_ID_MAX_LEN 32 |
| #define GSW_APN_TYPE_MAX_LEN 50 |
| #define GSW_USR_MAX_LEN 16 |
| #define GSW_PWD_MAX_LEN 16 |
| #define GSW_AUTH_TYPE_MAX_LEN 50 |
| #define GSW_PROTOCO_MAX_LEN 64 |
| #define GSW_CARRIER_ID_MAX_LEN 64 |
| #define GSW_IFACE_NAME_MAX_LEN 50 |
| #define GSW_PDP_ADDR_MAX_LEN 64 |
| #define GSW_DNS_ADDR_MAX_LEN 64 |
| #define GSW_GETWAYS_ADDR_MAX_LEN 64 |
| #define GSW_RSP_MAX_LEN 256 |
| #define GSW_PLMN_LIST_MAX_LEN 64 |
| #define MAX_CELL_EXT_INFO (5) |
| |
| |
| |
| typedef enum service_domain |
| { |
| GSW_SRV_DOMAIN_NO_SVC = 0x0, /**< no service */ |
| GSW_SRV_DOMAIN_CS_ONLY = 0x1, /**< cs only */ |
| GSW_SRV_DOMAIN_PS_ONLY = 0x2, /**< ps only */ |
| GSW_SRV_DOMAIN_CS_PS = 0x3, /**< reg all in service */ |
| } GSW_SERVICE_DOMAIN_E; |
| |
| typedef enum gsw_network_reg_state |
| { |
| GSW_NETWORK_REG_NOT_REGISTERED = 0x0, /**< no service */ |
| GSW_NETWORK_REG_REGISTERED = 0x1, /**< reg in service home */ |
| GSW_NETWORK_REG_NOT_REGISTERED_SEARCHING = 0x2, /**< searching network */ |
| GSW_NETWORK_REG_REGISTRATION_DENIED = 0x3, /**< network denny device */ |
| GSW_NETWORK_REG_REGISTRATION_UNKNOWN = 0x4, /**< unknown state */ |
| GSW_NETWORK_REG_REGISTRATION_ROAMING = 0x5, /**< roaming state in service */ |
| GSW_NETWORK_REG_LIMITED_SERVICE = 0x6, /**< limited service */ |
| } GSW_NW_REG_STATE_E; |
| |
| typedef enum gsw_network_radio_interface |
| { |
| GSW_NETWORK_RADIO_NO_SVC = 0x0, /**< radio state no service */ |
| GSW_NETWORK_RADIO_CDMA_1X = 0x1, /**< cdma 1x */ |
| GSW_NETWORK_RADIO_CDMA_1XEVDO = 0x2, /**< cdma evdo */ |
| GSW_NETWORK_RADIO_AMPS = 0x3, /**< amps gsm 2g*/ |
| GSW_NETWORK_RADIO_GSM = 0x4, /**< gsm */ |
| GSW_NETWORK_RADIO_UMTS = 0x5, /**< umts wcdma*/ |
| GSW_NETWORK_RADIO_LTE = 0x6, /**< LTE 4G */ |
| GSW_NETWORK_RADIO_TDSCDMA = 0x7, /**< TDS 3G*/ |
| GSW_NETWORK_RADIO_NR5G = 0x8, /**< NR 5G*/ |
| } GSW_NW_RADIO_ACCESS_TECH_E; |
| |
| |
| typedef enum gsw_network_roaming_state |
| { |
| GSW_NETWORK_ROAMING_OFF = 0x0, /**< roaming off */ |
| GSW_NETWORK_ROAMING_ON = 0x1, /**< roaming on*/ |
| } GSW_NW_ROAMING_STATE_E; |
| |
| typedef enum oprate_mode |
| { |
| GSW_OP_MODE_LPM = 0, /**< radio state off*/ |
| GSW_OP_MODE_ONLINE = 1, /**< radio state on*/ |
| GSW_OP_MODE_FTM = 2, /**< radio state ftm*/ |
| GSW_OP_MODE_OFFLINE = 3, /**< radio state offline*/ |
| } OPERATE_MODE_E; |
| |
| typedef enum prefer_mode |
| { |
| GSW_PREFER_MODE_GSW = 1, /**<2G only*/ |
| GSW_PREFER_MODE_WCDMA = 2, /**< 3G only*/ |
| GSW_PREFER_MODE_WCDMA_GSM = 3, /**< 3G/2G*/ |
| GSW_PREFER_MODE_LTE = 4, /**< 4G only*/ |
| GSW_PREFER_MODE_NR5G = 5, /**< 5G only*/ |
| GSW_PREFER_MODE_NR5G_LTE = 8, /**< 5G/4G*/ |
| GSW_PREFER_MODE_LTE_WCDMA_GSM = 9, /**< 4G/3G/2G*/ |
| GSW_PREFER_MODE_NR5G_LTE_WCDMA_GSM = 32, /**< 5G/4G/3G/2G*/ |
| } PREFER_MODE_E; |
| |
| typedef enum gsw_hal_nw_mode_state_type |
| { |
| GSW_MODEM_STATE_UNKNOWN = 0, |
| GSW_MODEM_STATE_ONLINE, |
| GSW_MODEM_STATE_OFFLINE, |
| GSW_SDK_STATE_SERVICE_DOWN, |
| GSW_SDK_STATE_SERVICE_UP,// service down->up 需要routectl 重启 |
| GSW_SDK_STATE_GPS_DOWN, |
| GSW_SDK_STATE_GPS_UP, |
| } gsw_mode_state_e; |
| |
| |
| typedef struct |
| { |
| GSW_NW_RADIO_ACCESS_TECH_E rej_rat; /**< current network radio tech*/ |
| GSW_SERVICE_DOMAIN_E rej_domain; /**< reject code from ps or cs*/ |
| int rej_cause; /**< reject code number*/ |
| } GSW_NW_REJ_CAUSE_E; |
| |
| typedef struct |
| { |
| int32_t gw_sig_valid; /**< 1 valid,1 invalid*/ |
| int32_t rssi; /**< Valid values are (0-31, 99) as defined in TS 27.007 8.5 */ |
| int32_t wcdma_sig_valid;/**< 1 valid,0 invalid*/ |
| int32_t rscp; /**< The Received Signal Code Power in dBm multipled by -1. |
| * Range : 25 to 120 |
| * INT_MAX: 0x7FFFFFFF denotes invalid value. |
| * Reference: 3GPP TS 25.123, section 9.1.1.1 */ |
| int32_t ecno; /**< Valid values are positive integers. This value is the actual Ec/Io multiplied |
| * by -10. Example: If the actual Ec/Io is -12.5 dB, then this response value |
| * will be 125.*/ |
| int32_t lte_sig_valid;/**< 1 valid,0 invalid*/ |
| int32_t rsrp; /**< The current Reference Signal Receive Power in dBm multipled by -1. |
| * Range: 44 to 140 dBm |
| * INT_MAX: 0x7FFFFFFF denotes invalid value. |
| * Reference: 3GPP TS 36.133 9.1.4 */ |
| int32_t rsrq; /**< The current Reference Signal Receive Quality in dB multiplied by -1. |
| * Range: 20 to 3 dB. |
| * INT_MAX: 0x7FFFFFFF denotes invalid value. |
| * Reference: 3GPP TS 36.133 9.1.7 */ |
| int32_t rssnr; /**< The current reference signal signal-to-noise ratio in 0.1 dB units. |
| * Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB). |
| * INT_MAX : 0x7FFFFFFF denotes invalid value. |
| * Reference: 3GPP TS 36.101 8.1.1 */ |
| int32_t nr_sig_valid;/**<1 valid,0 invalid*/ |
| int32_t ssRsrp; /**< SS(Synchronization Signal) reference signal received power, multipled by -1. |
| * Reference: 3GPP TS 38.215. |
| * Range [44, 140], INT_MAX means invalid/unreported.*/ |
| int32_t ssRsrq; /**< SS reference signal received quality, multipled by -1. |
| * Reference: 3GPP TS 38.215. |
| * Range [3, 20], INT_MAX means invalid/unreported.*/ |
| int32_t ssSinr; /**< SS signal-to-noise and interference ratio. |
| * Reference: 3GPP TS 38.215 section 5.1.*, 3GPP TS 38.133 section 10.1.16.1. |
| * Range [-23, 40], INT_MAX means invalid/unreported.*/ |
| int32_t csiRsrp; /**< CSI reference signal received power, multipled by -1. |
| * Reference: 3GPP TS 38.215. |
| * Range [44, 140], INT_MAX means invalid/unreported.*/ |
| int32_t csiRsrq; /**< CSI reference signal received quality, multipled by -1. |
| * Reference: 3GPP TS 38.215. |
| * Range [3, 20], INT_MAX means invalid/unreported.*/ |
| int32_t csiSinr; /**< CSI signal-to-noise and interference ratio. |
| * Reference: 3GPP TS 138.215 section 5.1.*, 3GPP TS 38.133 section 10.1.16.1. |
| * Range [-23, 40], INT_MAX means invalid/unreported.*/ |
| } signalStrength_t; |
| |
| typedef struct |
| { |
| GSW_NW_REG_STATE_E reg_state; /**< network cs regstate*/ |
| GSW_NW_REG_STATE_E ps_state; /**< network ps regstate*/ |
| GSW_NW_RADIO_ACCESS_TECH_E reg_rat; /**< current radio state*/ |
| GSW_SERVICE_DOMAIN_E srv_domain; /**< current cs or ps state*/ |
| GSW_NW_ROAMING_STATE_E roaming_ind; /**< roaming state*/ |
| char reg_plmn[GSW_NW_PLMN_LEN + 1]; /**< current cell plmn*/ |
| char operator_name[GSW_NW_OPERATION_NAME_LEN + 1]; /**< operator name*/ |
| char cell_id[128]; /**< cell id*/ |
| char tac[128]; /**< cell tac*/ |
| char lac[128]; /**< cell lac*/ |
| int sid; /**< cell sid cdma*/ |
| int nid; /**< cell nid cdma*/ |
| } GSW_NW_SERVING_INFO; |
| |
| |
| typedef struct |
| { |
| char long_eons[128]; /* Full name of the operator*/ |
| char short_eons[128]; /* Shor name of the operator*/ |
| char mcc[4]; /* Mobile country code*/ |
| char mnc[4]; /* Mobile network code*/ |
| }gsw_mobile_operator_name; |
| |
| |
| typedef struct |
| { |
| unsigned char cell_id_valid; |
| unsigned char pci_valid; |
| unsigned char psc_valid; |
| unsigned char band_valid; |
| unsigned char arfcn_valid; |
| unsigned char rssi_valid; |
| unsigned char rsrp_valid; |
| unsigned char rsrq_valid; |
| unsigned char sinr_valid; |
| unsigned char rscp_valid; |
| unsigned char ecio_valid; |
| GSW_NW_RADIO_ACCESS_TECH_E rat; |
| unsigned int cell_id; |
| int pci; |
| int psc; |
| int band; |
| int arfcn; |
| int rssi; |
| int rsrp; |
| int rsrq; |
| int sinr; |
| int rscp; |
| int ecio; |
| char mcc[5]; |
| char mnc[5]; |
| } GSW_NW_CELL_EXT_INFO; |
| |
| typedef struct |
| { |
| GSW_NW_RADIO_ACCESS_TECH_E rat; /**< current radio state*/ |
| |
| unsigned char mcc_valid; |
| char mcc[5]; |
| |
| unsigned char mnc_valid; |
| char mnc[5]; |
| |
| unsigned char cell_id_valid; |
| unsigned int cell_id; /**< cell id*/ |
| |
| unsigned char pci_valid; |
| int pci; /**<physical cell id*/ |
| |
| unsigned char psc_valid; |
| int psc; /*wcdma primary scramble code*/ |
| |
| unsigned char nrarfcn_valid; |
| int nrarfcn; /*nr cell freq*/ |
| |
| unsigned char earfcn_valid; |
| int earfcn; /*lte cell freq*/ |
| |
| unsigned char uarfcn_valid; |
| int uarfcn; /*wcdma cell freq*/ |
| |
| unsigned char arfcn_valid; |
| int arfcn; /*gsw cell freq*/ |
| |
| unsigned char tac_valid; |
| unsigned int tac; /**< cell tac*/ |
| |
| unsigned char lac_valid; |
| unsigned int lac; /**< cell lac*/ |
| |
| unsigned char sid_valid; |
| int sid; /**< cell sid cdma*/ |
| |
| unsigned char nid_valid; |
| int nid; /**< cell nid cdma*/ |
| |
| unsigned char lteMode_valid; |
| int lteMode; /*tdd 0, fdd 1*/ |
| |
| unsigned char rssi_valid; |
| int rssi; /**< Valid values are (0-31, 99) as defined in TS 27.007 8.5 */ |
| |
| unsigned char rscp_valid; |
| int rscp; /**< The Received Signal Code Power in dBm multipled by -1. |
| * Range : 25 to 120 |
| * INT_MAX: 0x7FFFFFFF denotes invalid value. |
| * Reference: 3GPP TS 25.123, section 9.1.1.1 */ |
| |
| unsigned char ecio_valid; |
| int ecio; /**< Valid values are positive integers. This value is the actual Ec/Io multiplied |
| * by -10. Example: If the actual Ec/Io is -12.5 dB, then this response value |
| * will be 125.*/ |
| |
| unsigned char rsrp_valid; |
| int rsrp; /**< The current Reference Signal Receive Power in dBm multipled by -1. |
| * Range: 44 to 140 dBm |
| * INT_MAX: 0x7FFFFFFF denotes invalid value. |
| * Reference: 3GPP TS 36.133 9.1.4 */ |
| |
| unsigned char rsrq_valid; |
| int rsrq; /**< The current Reference Signal Receive Quality in dB multiplied by -1. |
| * Range: 20 to 3 dB. |
| * INT_MAX: 0x7FFFFFFF denotes invalid value. |
| * Reference: 3GPP TS 36.133 9.1.7 */ |
| |
| unsigned char rssnr_valid; |
| int rssnr; /**< The current reference signal signal-to-noise ratio in 0.1 dB units. |
| * Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB). |
| * INT_MAX : 0x7FFFFFFF denotes invalid value. |
| * Reference: 3GPP TS 36.101 8.1.1 */ |
| |
| unsigned char band_valid; |
| int band; |
| |
| unsigned char bler_valid; |
| int bler; /*bit error rate*/ |
| |
| GSW_NW_CELL_EXT_INFO ext_info[MAX_CELL_EXT_INFO]; /* Used to hold neighborhood information for service cells. */ |
| } GSW_NW_CELL_INFO; |
| |
| typedef struct { |
| char mcc[GSW_MCC_MAX_LEN]; |
| char mnc[GSW_MNC_MAX_LEN]; |
| } gsw_nw_plmn_t; |
| |
| |
| typedef struct { |
| int plmn_list_len; |
| gsw_nw_plmn_t plmn_list[GSW_PLMN_LIST_MAX_LEN]; |
| } gsw_nw_plmn_list_t; |
| |
| typedef void (* GSW_NW_ServingInfoHandlePtr)(GSW_NW_SERVING_INFO serving_info); |
| typedef void (* GSW_NW_SigInfoHandlePtr)(signalStrength_t sig_info); |
| typedef void (* GSW_NW_RejectCauseHandlePtr)(GSW_NW_REJ_CAUSE_E *rej_cause); |
| typedef void (* GSW_NW_AirplaneModeHandlePtr)(int32_t airplane_mode); |
| typedef void (* GSW_NW_ModemStateHandlePtr)(gsw_mode_state_e state); |
| |
| |
| /*--------------------------------------------------------------------------------------------------------------------*/ |
| /* Data call */ |
| /*--------------------------------------------------------------------------------------------------------------------*/ |
| #define GSW_MCC_MAX_LEN 16 |
| #define GSW_MNC_MAX_LEN 16 |
| #define GSW_APN_CHANNEL_MAX 10 |
| #define GSW_POXY_ADDR_MAX_LEN 64 |
| #define GSW_PDP_TYPE_MAX_LEN 16 |
| #define GSW_APN_MAX_LEN 65 |
| #define GSW_APN_ID_MAX_LEN 32 |
| #define GSW_APN_TYPE_MAX_LEN 50 |
| #define GSW_USR_MAX_LEN 16 |
| #define GSW_PWD_MAX_LEN 16 |
| #define GSW_AUTH_TYPE_MAX_LEN 50 |
| #define GSW_PROTOCO_MAX_LEN 64 |
| #define GSW_CARRIER_ID_MAX_LEN 64 |
| #define GSW_IFACE_NAME_MAX_LEN 50 |
| #define GSW_PDP_ADDR_MAX_LEN 64 |
| #define GSW_DNS_ADDR_MAX_LEN 64 |
| #define GSW_GETWAYS_ADDR_MAX_LEN 64 |
| #define GSW_RSP_MAX_LEN 256 |
| |
| typedef struct { |
| int handle; /**< data connection handle*/ |
| int cid; /**< data connection cid*/ |
| int state; /**< data connection state*/ |
| int fail_cause; /**< data connection fail cause*/ |
| char *type; /**< data connection type*/ |
| char *ifname; /**< ifname*/ |
| |
| char *v4_ip; /**< ipv4 address*/ |
| char *v4_pdns; /**< ipv4 pdns address*/ |
| char *v4_sdns; /**< ipv4 sdns address*/ |
| char *v4_gw; /**< ipv4 gateway address*/ |
| |
| char *v6_ip; /**< ipv6 address*/ |
| char *v6_pdns; /**< ipv6 gateway address*/ |
| char *v6_sdns; /**< ipv6 gateway address*/ |
| }Wan_State_ind_s; |
| |
| typedef struct { |
| char ip[GSW_PDP_ADDR_MAX_LEN]; /**< ip address */ |
| char pdns[GSW_DNS_ADDR_MAX_LEN]; /**< pdns address*/ |
| char sdns[GSW_DNS_ADDR_MAX_LEN]; /**< sdns address*/ |
| char gw[GSW_GETWAYS_ADDR_MAX_LEN]; /**< gate way address*/ |
| }V4_Addr_s; |
| |
| typedef struct { |
| char ip[GSW_PDP_ADDR_MAX_LEN]; /**< ip address*/ |
| char pdns[GSW_DNS_ADDR_MAX_LEN]; /**< pdns address*/ |
| char sdns[GSW_DNS_ADDR_MAX_LEN]; /**< sdns address*/ |
| }V6_Addr_s; |
| |
| typedef struct { |
| int handle; /**< data connection handle*/ |
| |
| /* req info */ |
| char mcc[GSW_MCC_MAX_LEN]; /**< apn mcc value*/ |
| char mnc[GSW_MNC_MAX_LEN]; /**< apn mnc value*/ |
| char apnid[GSW_APN_ID_MAX_LEN]; /**< apn id*/ |
| char apn[GSW_APN_MAX_LEN]; /**< apn name*/ |
| char apnType[GSW_APN_TYPE_MAX_LEN]; /**< apn type ipv4 ipv4v6 ipv6*/ |
| char usr[GSW_USR_MAX_LEN]; /**< apn usr name*/ |
| char pwd[GSW_PWD_MAX_LEN]; /**< apn password*/ |
| char authType[GSW_AUTH_TYPE_MAX_LEN]; /**< apn auth type*/ |
| char normalProtocol[GSW_PROTOCO_MAX_LEN]; /**< apn auth protoco*/ |
| char roamingProtocol[GSW_PROTOCO_MAX_LEN]; /**< apn auth protoco roaming*/ |
| char carrier[GSW_CARRIER_ID_MAX_LEN]; /**< carrier id*/ |
| |
| /* rsp */ |
| int cid; /**< data connection cid for mdm sdk*/ |
| int active; /**< pdn context active state: 2,actived; other,not active */ |
| char ifname[GSW_IFACE_NAME_MAX_LEN]; /**< if name of current datalink */ |
| int type; /**< data connection type*/ |
| V4_Addr_s v4; /**< ipv4 addr*/ |
| V6_Addr_s v6; /**< ipv6 addr*/ |
| int mtu; /**< mtu value*/ |
| |
| char out[GSW_RSP_MAX_LEN]; /**< sdk return value*/ |
| }Link_Info_s; |
| |
| typedef struct |
| { |
| uint64_t tx_pkts; /* the number of packet sent*/ |
| uint64_t tx_bytes; /* the number of packet sent bytes */ |
| uint64_t tx_dropped_pkts; /* the number of packet dropped by sent*/ |
| uint64_t rx_pkts; /* the number of packet received*/ |
| uint64_t rx_bytes; /* the number of packet receivedbytes */ |
| uint64_t rx_dropped_pkts; /* the number of packet dropped by received*/ |
| }gsw_data_pkt_stats; |
| |
| |
| typedef void (*gsw_data_call_evt_cb_t)(Wan_State_ind_s *linkState); |
| |
| |
| /*--------------------------------------------------------------------------------------------------------------------*/ |
| /* sim */ |
| /*--------------------------------------------------------------------------------------------------------------------*/ |
| |
| typedef enum sim_status |
| { |
| SIM_STATUS_ABSENT = 0, /**< sim absent*/ |
| SIM_STATUS_PRESENT = 1, /**< sim present mtk as ready*/ |
| SIM_STATUS_ERROR = 2, /**< sim error*/ |
| SIM_STATUS_READY = 3, /**< sim state ready mtk no this value*/ |
| SIM_STATUS_PIN = 4, /**< pinlock status*/ |
| } sim_status_e_type; |
| |
| |
| |
| /** |
| * @brief SDK interface to call back serving info |
| * @param [in] handle_ptr |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_reg_serving_info_callback(GSW_NW_ServingInfoHandlePtr handle_ptr); |
| |
| /** |
| * @brief SDK interface to call back sig info |
| * @param [in] handle_ptr |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_reg_sig_info_callback(GSW_NW_SigInfoHandlePtr handle_ptr); |
| |
| /** |
| * @brief SDK interface to call back rej cause |
| * @param [in] handle_ptr |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_reg_rej_cause_callback(GSW_NW_RejectCauseHandlePtr handle_ptr); |
| |
| /** |
| * @brief network sdk init |
| * @param [in] token usr id define by who use |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_nw_sdk_init(int token); |
| |
| /** |
| * @brief network sdk deinit |
| * @param |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_nw_sdk_deinit(void); |
| |
| /** |
| * @brief get current network reg info |
| * @param [out] serving_info struct for network info |
| * include regstate ps_state opreator name mcc mcn etc |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_get_nwinfo(GSW_NW_SERVING_INFO *serving_info); |
| |
| /** |
| * @brief get current network type |
| * @param [out] netype as GSW_NW_RADIO_ACCESS_TECH_E type |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_get_netype(int32_t *netype); |
| |
| /** |
| * @brief get radio opmode, as open and close airplane mode |
| * @param [out] op_mode 1 is radio on, 0 is radio off |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_get_opmode(int *op_mode); |
| |
| /** |
| * @brief set radio opmode, as open and close airplane mode |
| * @param [in] op_mode 1 is radio on, 0 is radio off |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_set_opmode(int32_t op_mode); |
| |
| /** |
| * @brief get network mode preference of mdm search network scale |
| * @param [out] mode_pref net_work pref mode: |
| * enum prefer_mode |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_get_mode_preference(int32_t *mode_pref); |
| |
| /** |
| * @brief set network mode preference of mdm search network scale |
| * @param [in] mode_pref net_work pref mode: |
| * enum prefer_mode |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_set_mode_preference(int32_t mode_pref); |
| |
| /** |
| * @brief get signal csq value |
| * @param [out] csq_value csq of signalstrengh 0 - 31, 99 invalid |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_get_sig_info(int32_t *csq_value); |
| |
| /** |
| * @brief set nework power mode, for tcam enter standby or exit standby |
| * @param [in] mode TRUE(1) when enter standby, FALSE(0) after wake up |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_network_set_power_mode(int8_t mode); |
| |
| /** |
| * @brief convert rsrp rscp rssi to csq value. |
| * @param [in] netType signal radio tech 2 means 2G 3 mens 3G,4 is 4G,5 is 5G |
| * @param [in] sigvalue input signal_strength for different nettype |
| * rsrp for 4G/5G, rscp for 3G, rssi for 2G |
| |
| * @retval csq |
| * @retval other: fail |
| */ |
| int gsw_sigInfo_to_csq(int32_t netType, int32_t sigValue); |
| |
| /* |
| * @brief get PLMNs from the FPLMN list |
| * @param [inout] plmn_list: |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_get_forbidden_networks(gsw_nw_plmn_list_t *plmn_list); |
| |
| /* |
| * @brief add PLMNs from the plmn_list to the FPLMN list |
| * @param [in] plmn_list: |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_add_forbidden_networks(gsw_nw_plmn_list_t *plmn_list); |
| |
| /* |
| * @brief Remove PLMNs from the plmn_list from the FPLMN list |
| * @param [in] plmn_list: |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_remove_forbidden_networks(gsw_nw_plmn_list_t *plmn_list); |
| |
| /* |
| * @brief clear FPLMN list |
| * @param |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_clear_forbidden_networks(void); |
| |
| |
| |
| /* |
| * @brief get mobile operator name |
| @param [out] nw_operator_name_infos get the long and short operator name info |
| @retval 0: success |
| @retval 0: other: fail |
| */ |
| int gsw_get_mobile_operator_name(gsw_mobile_operator_name *nw_operator_name_infos); |
| |
| |
| |
| /* |
| * @brief set modem status event callback |
| @param [in] handle_ptr callback function address |
| @retval 0: success |
| @retval 0: other: fail |
| */ |
| int gsw_reg_set_modem_status_event_callback(GSW_NW_ModemStateHandlePtr handle_ptr); |
| |
| |
| /* |
| * @brief get current serving cell info |
| * @param cell_info: [out] struct for current cell info |
| * include earfcn mcc mnc pci psc tac lac etc. |
| * @return int: 0 is success, other failed |
| */ |
| int gsw_get_cell_info(GSW_NW_CELL_INFO *cell_info); |
| |
| /** |
| * @brief datacall sdk init |
| * @param [in] evt_cb callback function for data connection state change event |
| * call back; |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_data_call_init(gsw_data_call_evt_cb_t evt_cb); |
| |
| |
| /** |
| * @brief data_call sdk deinit |
| * @param |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_data_call_deinit(void); |
| |
| /** |
| * @brief set apn parameters for data call |
| * @param [in/out] LinkInf apn info for pub or private datacall |
| * inlcude apn name mcc mnc, passwork apnid type cid etc |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_data_call_set_apn(Link_Info_s *LinkInf); |
| |
| |
| /** |
| * @brief set apn parameters for data call |
| * @param [in] linkid data connetion link number |
| * @param [in/out] LinkInf link info req: apn info for pub or private datacall |
| * inlcude apn name mcc mnc, passwork apnid etc |
| * resp: data call link state ipaddress type etc |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_data_call_connect(int linkid, Link_Info_s *LinkInf); |
| |
| |
| /** |
| * @brief set apn parameters for data call |
| * @param [in] linkid |
| * @param [in/out] LinkInf link info req: apn info for pub or private datacall |
| * inlcude apn name mcc mnc, passwork apnid etc |
| * resp: data call link state ipaddress type etc |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_data_call_disconnect(int linkid, Link_Info_s *LinkInf); |
| |
| |
| |
| /* |
| * @brief get mobile operator name |
| @param [in] linkid apn id |
| @param [out] data_pkt obtian actual data call network card data traffic |
| @retval 0: success |
| @retval 0: other: fail |
| */ |
| int gsw_get_data_call_pkt_stats(int linkid, gsw_data_pkt_stats *data_pkt); |
| |
| |
| /** |
| * @brief sim sdk init |
| * @param [in] token usr id define by who use |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_sim_sdk_init(int32_t token); |
| |
| |
| /** |
| * @brief sim sdk deinit |
| * @param |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_sim_sdk_deinit(void); |
| |
| /** |
| * @brief get sim state |
| * @param [out] sim_state sim status as sim_status_e_type |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_get_sim_status(int32_t *sim_state); |
| |
| /** |
| * @brief get iccid function |
| * @param [in] len iccid length,max is 20 |
| * @param [out] iccid return iccid from this func |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_get_sim_iccid(int32_t len, int8_t *iccid); |
| |
| /** |
| * @brief get imsi function |
| * @param [in] len imsi length,max is 20 |
| * @param [out] iccid return imsi from this func |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_get_sim_imsi(int32_t len, int8_t *imsi); |
| |
| /** |
| * @brief get sim msisdn function |
| * @param [in] len msisdn length,max is 20 |
| * @param [out] msisdn msisdn length,max is 20 |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_get_sim_msisdn(int32_t len, int8_t *msisdn); |
| |
| /** |
| * @brief get imei function |
| * @param [in] len imei length,max is 20 |
| * @param [out] imei return imei from this func |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_get_imei(int32_t len, int8_t *imei); |
| |
| /** |
| * @brief set sim power down |
| * @param |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_set_sim_power_down(void); |
| |
| /** |
| * @brief set sim power up |
| * @param |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_set_sim_power_up(void); |
| |
| /** |
| * @brief reset modem stack only, notice: after use this method, all ril sdk |
| * need restart by app, means network, sim, sms, data need deinit then init! |
| * @param |
| * @retval 0: success |
| * @retval other: fail |
| */ |
| int gsw_reset_modem(void); |
| |
| |
| |