blob: b3e0326e2fdb345d2a992a88e5d20a856a465ff5 [file] [log] [blame]
/**
* @file : gsw_nw_interface.h
* @brief : sim and apn
* @date :
* @author : wind
* @version : v1.0
* @copyright
*/
#ifndef GSW_NWINFO_INTERFACE_H
#define GSW_NWINFO_INTERFACE_H
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include "gsw_hal_errcode.h"
#if defined(__cplusplus)
extern "C" {
#endif
#define GSWOL_5G_SDK
#define GSW_NW_OPERATION_NAME_LEN (32)
#define GSW_NW_PLMN_LEN (6)
#define GSW_NW_MCC_LEN (3)
#define GSW_NW_MNC_LEN (3)
#define GSW_NW_SUCCESS GSW_HAL_SUCCESS
#define GSW_NW_FAIL GSW_HAL_NORMAL_FAIL
#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 (32)
#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 DATA_TOKEN (2022)
#define MAX_CELL_EXT_INFO (5)
#ifndef uint8_t
typedef unsigned char uint8_t;
#endif
typedef enum roaming_status
{
WAN_ROAM_STATUS_UNKOWN = 0, /**< init value */
WAN_ROAM_STATUS_HOME = 1, /**< china home */
WAN_ROAM_STATUS_INTERNAL = 2, /**< china roaming */
WAN_ROAM_STATUS_INTERNATIONA = 3, /**< other country roaming */
} roaming_status_e_type;
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 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 data_conn_status
{
DIAL_STATUS_MIN_ENUM_VAL = -1, /**< default value*/
DIAL_STATUS_CONNECTING = 0, /**< data connecting*/
DIAL_STATUS_CONNECTED = 1, /**< data conneted*/
DIAL_STATUS_DISCONNECTING = 2, /**< data disconnecting*/
DIAL_STATUS_DISCONNECTED = 3, /**< data disconnected*/
DIAL_STATUS_MAX_ENUM_VAL, /**< default max value*/
} data_conn_status_e_type;
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;
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 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*/
uint8_t mcc_valid;
char mcc[5];
uint8_t mnc_valid;
char mnc[5];
uint8_t cell_id_valid;
unsigned int cell_id; /**< cell id*/
uint8_t pci_valid;
int pci; /**<physical cell id*/
uint8_t psc_valid;
int psc; /**<wcdma primary scramble code*/
uint8_t narfcn_valid;
int narfcn; /**<nr cell freq*/
uint8_t earfcn_valid;
int earfcn; /**<lte cell freq*/
uint8_t uarfcn_valid;
int uarfcn; /**<wcdma cell freq*/
uint8_t arfcn_valid;
int arfcn; /**<gsw cell freq*/
uint8_t tac_valid;
unsigned int tac; /**< cell tac*/
uint8_t lac_valid;
unsigned int lac; /**< cell lac*/
uint8_t sid_valid;
int sid; /**< cell sid cdma*/
uint8_t nid_valid;
int nid; /**< cell nid cdma*/
uint8_t lteMode_valid;
int lteMode; /**<tdd 0, fdd 1*/
uint8_t rssi_valid;
int rssi; /**< Valid values are (0-31, 99) as defined in TS 27.007 8.5 */
uint8_t 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 */
uint8_t 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.*/
uint8_t 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 */
uint8_t 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 */
uint8_t 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 */
uint8_t band_valid;
int band;
uint8_t bler_valid;
int bler; /**<bit error rate*/
int ext_info_len; /**<ext_info len*/
GSW_NW_CELL_EXT_INFO ext_info[MAX_CELL_EXT_INFO];
} GSW_NW_CELL_INFO;
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
{
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 enum
{
SMS_FORMAT_GSM_7BIT = 0, /**< 7bit econde*/
SMS_FORMAT_BINARY_DATA = 1, /**< 8bit binary encode*/
SMS_FORMAT_UCS2 = 2, /**< ucs2 encode*/
}gsw_sms_format_e;
typedef struct
{
unsigned char year[5]; /**< year of date*/
unsigned char month[3]; /**< month of date*/
unsigned char day[3]; /**< day of date*/
unsigned char hour[3]; /**< hour of time*/
unsigned char minutes[3]; /**< minute of time*/
unsigned char seconds[3]; /**< second of time*/
unsigned char timezone[4]; /**< timezone*/
}gsw_sms_date_t;
#define GSW_SMS_SEND_NUM_MAX 5 /**< dest num max count */
#define GSW_SMS_ADDRESS_LEN 32 /**< one dest number max length*/
#define GSW_SMS_CONCAT_SMS_COUNT_MAX 160 /**< one page max bytes*/
#define GSW_SMS_MSG_CONTENT_LEN_MAX 3 /**< sms page max count*/
#define GSW_SMS_CONTENT_LEN_MAX 3 /**< newmsg recv one page*/
#define GSW_SMS_SEND_CONT_MAX (GSW_SMS_MSG_CONTENT_LEN_MAX*GSW_SMS_CONCAT_SMS_COUNT_MAX*2) /**< sms send max len*/
#define GSW_SMS_RECV_CONT_MAX 1440 /**< sms receive max len*/
typedef struct
{
char src_num[GSW_SMS_ADDRESS_LEN+1]; /**< sms phone num send msg*/
char dest_num[GSW_SMS_ADDRESS_LEN + 1]; /**< sms phone num recv msg*/
gsw_sms_format_e content_encode; /**< sms content is 7bit or 8bit or Ucs2 encode*/
unsigned int content_len; /**< sms content size*/
char content[GSW_SMS_RECV_CONT_MAX + 1]; /**< sms content*/
gsw_sms_date_t date; /**< message time*/
}gsw_sms_msg_type_t;
typedef struct
{
gsw_sms_format_e content_encode; /**< content encode*/
int content_len; /**< content len*/
char content[GSW_SMS_RECV_CONT_MAX + 1]; /**< sms content*/
gsw_sms_date_t date; /**< sms date */
} gsw_sms_content_t;
typedef enum
{
GSW_SMS_FULL_FLG, /**< sms full flag*/
GSW_SMS_RECEIVED_FLG, /**<recv new sms flag*/
}gsw_sms_state_e;
/*--------------------------------------------------------------------------------------------------------------------*/
/* Data call adaptation layer struct */
/*--------------------------------------------------------------------------------------------------------------------*/
#define LINK0 (0) /**< public use APN2 or APN3 */
#define LINK1 (1) /**< private use APN1 */
#define LINK2 (2) /**< public use APN2 or APN3 */
#define MAX_LINKS (3)
#define INACTIVED (0)
#define ACTIVED (2)
#define TYPE_IPV4 (0)
#define TYPE_IPV6 (1)
#define TYPE_IPV4V6 (2)
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 {
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{
int gw_sig_valid; /**< 1 valid,1 invalid*/
int rssi; /**< Valid values are (0-31, 99) as defined in TS 27.007 8.5 */
int wcdma_sig_valid;/**< 1 valid,0 invalid*/
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 */
int 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.*/
int lte_sig_valid;/**< 1 valid,0 invalid*/
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 */
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 */
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 */
int nr_sig_valid;/**<1 valid,0 invalid*/
int ssRsrp; /**< SS(Synchronization Signal) reference signal received power, multipled by -1.
* Reference: 3GPP TS 38.215.
* Range [44, 140], INT_MAX means invalid/unreported.*/
int ssRsrq; /**< SS reference signal received quality, multipled by -1.
* Reference: 3GPP TS 38.215.
* Range [3, 20], INT_MAX means invalid/unreported.*/
int 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.*/
int csiRsrp; /**< CSI reference signal received power, multipled by -1.
* Reference: 3GPP TS 38.215.
* Range [44, 140], INT_MAX means invalid/unreported.*/
int csiRsrq; /**< CSI reference signal received quality, multipled by -1.
* Reference: 3GPP TS 38.215.
* Range [3, 20], INT_MAX means invalid/unreported.*/
int 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
{
int regState; /**< voice or data reg service state */
char CID[128]; /**< gsm/wcdma cid */
char LAC[128]; /**< cell lac */
int netType; /**< radio tech */
int radioTechFam; /**< 1-3GPP; 2-3GPP2 */
int netRejectedCode; /**< denied code */
} lynq_nw_reg_status_t;
typedef enum mode_state_type
{
GSW_MODEM_STATE_UNKNOWN = 0, /**< modem unknow */
GSW_MODEM_STATE_ONLINE, /**< modem work online */
GSW_MODEM_STATE_OFFLINE, /**< modem offline */
}gsw_mode_state_e;
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;
#define GSW_MCC_MAX_LEN (16)
#define GSW_MNC_MAX_LEN (16)
#define GSW_PLMN_LIST_MAX_LEN (85)
typedef struct {
char mcc[GSW_MCC_MAX_LEN]; /**< Mobile country code*/
char mnc[GSW_MNC_MAX_LEN]; /**< Mobile network code*/
} 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 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 struct {
char apn_name[GSW_APN_MAX_LEN];
char apn_accont[GSW_USR_MAX_LEN];
char apn_password[GSW_PWD_MAX_LEN];
uint8_t auth_type;
} gsw_apn_param_t;
/* Callback function registered to QL_SMS_AddRxMsgHandler, msgRef contains the detail msg infor */
typedef void (* GSW_SMS_Callback_fun)(gsw_sms_state_e state, gsw_sms_msg_type_t *report_info);
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)(int airplane_mode);
typedef void (* GSW_NW_ModemStateHandlePtr)(gsw_mode_state_e state);
/**
* @brief SDK interface to call back serving info
* @param [in] GSW_NW_ServingInfoHandlePtr:
* @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
* report: event + cycle(5s) 事件+周期上报
* 如果底层(modem 上报)有信号上报,就执行回调函数进行上报
* 如果底层(modem 上报)超过 5s 没有上报,服务层就自己获取一次信号,做一次补充上报
* @param [in] GSW_NW_SigInfoHandlePtr:
* @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] GSW_NW_RejectCauseHandlePtr:
* @retval 0: success
* @retval other: fail
*/
int gsw_reg_rej_cause_callback(GSW_NW_RejectCauseHandlePtr handle_ptr);
/**
* @brief SDK interface to call back airplane mode
* @param [in] GSW_NW_AirplaneModeHandlePtr:
* @retval 0: success
* @retval other: fail
*/
int gsw_reg_operating_mode_callback(GSW_NW_AirplaneModeHandlePtr handle_ptr);
/**
* @brief SDK interface to call back sms messages
* @param [in] GSW_SMS_Callback_fun:
* @retval 0: success
* @retval other: fail
*/
int gsw_sms_reg_callback(GSW_SMS_Callback_fun handle_ptr);
/**
* @brief mdm sdk service init before all other sdk init
* @param
* @retval 0: success
* @retval other: fail
*/
int gsw_sdk_init(void);
/**
* @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 sim sdk init
* @param [in] token usr id define by who use
* @retval 0: success
* @retval other: fail
*/
int gsw_sim_sdk_init(int token);
/**
* @brief sim sdk deinit
* @param
* @retval 0: success
* @retval other: fail
*/
int gsw_sim_sdk_deinit(void);
/**
* @brief sms sdk init
* @param [in] token
* @retval 0: success
* @retval other: fail
*/
int gsw_sms_sdk_init(int token);
/**
* @brief sms sdk deinit
* @param
* @retval 0: success
* @retval other: fail
*/
int gsw_sms_sdk_deinit(void);
/**
* @brief get current network reg info
* @param [out] GSW_NW_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(int *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(int op_mode);
/**
* @brief get network mode preference of mdm search network scale
* @param [out] mode_pref net_work pref mode:
* 32 - all mode 2G/3G/4G/5G;
* 9 - 2G/3G/4G;
* 3 - 2G/3G;
* 1 - 2G only
* @retval 0: success
* @retval other: fail
*/
int gsw_get_mode_preference(int *mode_pref);
/**
* @brief set network mode preference of mdm search network scale
* @param [in] mode_pref net_work pref mode:
* 32 - all mode 2G/3G/4G/5G;
* 9 - 2G/3G/4G;
* 3 - 2G/3G;
* 1 - 2G only
* @retval 0: success
* @retval other: fail
*/
int gsw_set_mode_preference(int mode_pref);
/**
* @brief get signal csq value
* @param [out] csq_value csq of signalstrengh 0 - 31
* @retval 0: success
* @retval other: fail
*/
int gsw_get_sig_info(int *csq_value);
/**
* @brief get current serving cell info
* @param [out] GSW_NW_CELL_INFO: 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 get mobile operator name
* @param [out] gsw_mobile_operator_name: 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 get PLMNs from the FPLMN list
* @param [inout] gsw_nw_plmn_list_t:
* @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] gsw_nw_plmn_list_t:
* @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] gsw_nw_plmn_list_t:
* @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 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(char mode);
/**
* @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(int *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(int len, char *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(int len, char *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(int len, char *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(int len, char *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,
* @details notice: after use this method, all ril sdk
* need restart, means network, sim, sms, data need deinit then init!
*
* @param
* @retval 0: success
* @retval other: fail
*/
int gsw_reset_modem(void);
/**
* @brief send sms fuction
* @param [in] phone_num dest phone num send sms
* @param [in] char_set encode format for sms 0-7bit; 1-binary; 2-usc2
* @param [in] msg sms content
* @param [in] msg_len send sms length,max is 1024
* @retval 0: success
* @retval other: fail
*/
int gsw_send_sms(char *phone_num, int char_set, char *msg, int msg_len);
/**
* @brief get smsc fuction
* @param [in] len input buf len for smsc,max is 32
* @param [out] smsc address for smsc get from this func *
* @retval 0: success
* @retval other: fail
*/
int gsw_get_smsc_address(int len, char *smsc);
/**
* @brief set smsc fuction
* @param [out] smsc string value for smsc,max length is 32
* @retval 0: success
* @retval other: fail
*/
int gsw_set_smsc_address(const char *smsc);
/**
* @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 0: success
* @retval other: fail
*/
int gsw_sigInfo_to_csq(int netType, int sigValue);
/**
* @brief data call event sdk callback function define
* @param [out] Wan_State_ind_s: data connection state and params indication struct
* include datacall state , ipv4 ipv6 address, dns address and ifname
* @retval void
*/
typedef void (*gsw_data_call_evt_cb_t)(Wan_State_ind_s *linkState);
/**
* @brief use this api to wait data call event ind call back
* @param [out] arg
* @retval void
*/
void *gsw_onUnsolicited(void *arg);
/**
* @brief datacall sdk init
* @param [in] gsw_data_call_evt_cb_t: 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 get apn info
* @param [in/out] gsw_apn_param_t:apn info for pub or private apn
* inlcude apn name mcc mnc, passwork apnid authtype iptype etc
* @return int : 0 is success , other failed
*/
void gsw_get_apn_info(int linkid, gsw_apn_param_t *apn_para);
/**
* @brief set apn parameters for data call
* @param [in/out] Link_Info_s: 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
* 接口超时时间:120s
* 如接口返回失败,不要给apn回调:gsw_data_call_evt_cb_t
* 如接口返回成功,从接口调用开始计时,到收到apn回调:gsw_data_call_evt_cb_t,不能超过120s
* @param [in] linkid data connetion link number
* @param [in/out] Link_Info_s: 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] Link_Info_s: 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 the data traffic infos
@param [in] linkid apn id
@param [out] gsw_data_pkt_stats 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 clear data call if needed when receive apn down event
* @param [in] linkid
* @param [in/out] Link_Info_s: 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_clear_session(int linkid, Link_Info_s *LinkInf);
/**
* @brief Set apn binding to specify interface id
* @details This interface supports a total of 8 reserved id information
* and the reserved id value ranges from 0-7
*
* @param [in] reserved_id: -1 unset reserved id,0-7 set reserved id
* @param [in] apn APN name
* @retval 0: success
* @retval other: fail
*/
int gsw_set_apn_reserved_id(int reserved_id, const char *apn);
/**
* @brief Get the apn name bound to the specified interface id
* @param [in] reserved_id Network reserved interface id
* @param [out] apn_str APN name
* @param [in] apn_str_size APN name size
* @retval 0-7: success
* @retval -1: unbind reserved id
*/
int gsw_get_apn_reserved_name(int reserved_id, char *apn_str, int apn_str_size);
/**
* @brief Get apn binding to specify interface id
* @param [in] apn
* @retval 0: success
* @retval 0-7: success
* @retval -1: unbind reserved id
*/
int gsw_get_apn_reserved_id(const char *apn);
/**
* @brief Get get modem state
* @param
* @retval 0: ok
* @retval other: error
*/
int gsw_get_modem_state_exp(void);
/**
* @brief set modem status event callback
* @param [in] GSW_NW_ModemStateHandlePtr
* @retval 0 : success
* @retval other: fail
*/
int gsw_reg_set_modem_status_event_callback(GSW_NW_ModemStateHandlePtr handle_ptr);
/**
* @brief get tcamid function
* @param [in] len tcamid length
* @param [out] iccid return tcamid from this func
* @retval 0 : success
* @retval other: fail
*/
int gsw_get_tcamid(int len, char *tcamid);
/**
* @brief Module log disk drop, used when restarting or hibernating
* @param [in]void
* @retval void
*/
void gsw_modem_log_sync(void);
#if defined(__cplusplus)
extern "C" }
#endif
#endif /*GSW_NWINFO_INTERFACE_H*/