blob: 155244913efd2afd826bbeea9ebe2f49539ffdac [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#ifndef __ZTE_VSIM_API_H_
2#define __ZTE_VSIM_API_H_
3#include <stdio.h>
4#include <stdlib.h>
5#include <stdint.h>
6#include <sys/socket.h>
7//********2023-01-13***********//
8
9#define SIM_IMSI_LEN_MAX 16 /** Maximum length of IMSI data. */
10#define SIM_ICCID_LEN_MAX 21 /** Maximum length of ICCID data. */
11#define DATA_MAX_APN_LEN 57 /** Maximum length of the APN. */
12#define DATA_MAX_USERNAME_LEN 127 /** Maximum length of the profile user name. */
13#define DATA_MAX_PASSWORD_LEN 127 /** Maximum length of the profile password. */
14#define DATA_INTERFACE_NAME_LEN 16 /** Interface name length. */
15#define DATA_MAX_ADDR_COUNT 2 /** Maximum number of IP addresses. */
16
17//**************GHT VSIM Struct*********************//
18
19typedef enum {
20 E_SIM_TYPE_USIM, //ʵÌ忨
21 E_SIM_TYPE_VSIM, //ÔÆ¿¨
22 E_SIM_TYPE_SSIM, //Soft SIM
23}SimTypeInSlot_t;
24
25
26typedef enum {
27 E_NW_RADIO_IF_NO_SRV = 0,
28 E_NW_RADIO_IF_GSM = 1,
29 E_NW_RADIO_IF_WCDMA = 2,
30 E_NW_RADIO_IF_LTE = 3,
31 E_NW_RADIO_IF_TDSCDMA = 4,
32 E_NW_RADIO_IF_CDMA = 5,
33 E_NW_RADIO_IF_CDMA2000 = 6,
34}e_nw_rat_type_t; //RAT value
35
36
37typedef enum {
38 E_NW_STATUS_SRV_NONE = 0,
39 E_NW_STATUS_CURRENT_SERVING = 1,
40 E_NW_STATUS_SRV_LIMITED = 2,
41 E_NW_STATUS_SRV_AVAILABLE = 3,
42 E_NW_STATUS_SRV_FORBIDDEN = 4,
43}e_nw_srv_status_t;
44
45
46typedef struct
47{
48 uint32_t tac;
49 uint32_t cell_id;
50}lte_scell_info_t;
51
52typedef struct
53{
54 uint32_t lac;
55 uint32_t cell_id;
56}gsm_w_scell_info_t;
57
58
59
60typedef struct
61{
62 e_nw_rat_type_t curr_rat;
63 e_nw_srv_status_t nStatus;
64 lte_scell_info_t lte_scell_info; //¸³Öµ¿ÉÑ¡£¬Óû§¸ù¾ÝratÖ¸Ê¾ÍøÂçÀàÐÍȡֵ
65 gsm_w_scell_info_t gsm_w_scell_info; //¸³Öµ¿ÉÑ¡£¬Óû§¸ù¾ÝratÖ¸Ê¾ÍøÂçÀàÐÍȡֵ
66}RegInfo_t;
67
68typedef struct{
69 uint16_t mcc;
70 uint16_t mnc;
71 uint32_t tac;
72 uint32_t cell_id;
73 uint16_t bandwidth;
74 int16_t rxlev;
75 uint32_t arfcn;
76 uint16_t pcid;
77}base_cell_info_t;//Hex format
78
79
80typedef struct
81{
82 uint8_t roamingFlag; ///< 1:roaming,0:non roaming
83 int16_t rsrp;
84 int16_t rsrq;
85 uint16_t SINR;
86 uint16_t netMode; //0--tdd 1--fdd
87 uint16_t band;
88 base_cell_info_t base_Scell_info;
89} lte_Scell_t;
90
91typedef struct
92{
93 int16_t rsrp;
94 int16_t rsrq;
95 uint16_t netMode; //0--tdd 1--fdd
96 base_cell_info_t base_Ncell_info;
97}lte_Ncell_t;
98
99typedef struct
100{
101 uint16_t bsic; //only in GSM
102 uint16_t band;
103 uint16_t rscp; //only in W
104 base_cell_info_t base_Ncell_info;
105}gsm_W_Scell_t;
106
107
108typedef struct
109{
110 uint16_t bsic; //only GSM
111 uint16_t band;
112 uint16_t rscp; //only in W
113 base_cell_info_t base_Ncell_info;
114}gsm_W_Ncell_t;
115
116typedef struct
117{
118 lte_Scell_t lteScell;
119 uint16_t lteNcellNum;
120 lte_Ncell_t lteNcell[6];
121}lte_cellinfo_t;
122
123typedef struct{
124 gsm_W_Scell_t scell_info;
125 uint16_t gsm_W_NcellNum;
126 gsm_W_Ncell_t gsm_W_ncell[6];
127}gsm_W_cellifo_t;
128
129typedef struct{
130 e_nw_rat_type_t curr_rat;
131 e_nw_srv_status_t service_status; //0x00: in service; 0x01: not in
132 lte_cellinfo_t lte_cellinfo;
133 gsm_W_cellifo_t gsm_cellinfo;
134}CellInfo_t;
135
136
137typedef struct{
138 uint32_t lwip_ul;
139 uint32_t lwip_dl;
140 uint32_t ppp_ul;
141 uint32_t ppp_dl;
142 uint32_t rndis_ul;
143 uint32_t rndis_dl;
144}NetInfo_t; /**< µ¥Î»: bit*/
145
146typedef enum
147{
148 E_DATA_IP_FAMILY_UNKNOWN = 0x00, /**< unknown */
149 E_DATA_IP_FAMILY_IPV4 = 0x04, /**< IPv4 */
150 E_DATA_IP_FAMILY_IPV6 = 0x06, /**< IPv6 */
151 E_DATA_IP_FAMILY_IPV4V6 = 0x0A /**< IPv4|IPv6 */
152}e_data_ip_family_t;
153
154typedef enum
155{
156 E_DATA_TECH_PREF_UNKNOWN = 0x00, /**< unknown */
157 E_DATA_TECH_PREF_UMTS = 0x01, /**< UMTS */
158 E_DATA_TECH_PREF_CDMA = 0x02, /**< CDMA */
159 E_DATA_TECH_PREF_LTE = 0x03, /**< LTE */
160 E_DATA_TECH_PREF_AUTO = 0x04 /**< AUTO */
161}e_data_tech_pref_t;
162
163typedef enum
164{
165 E_AUTH_PREF_PAP_CHAP_NOT_ALLOWED = 0x00,
166 E_AUTH_PREF_PAP_ONLY_ALLOWED = 0x01,
167 E_AUTH_PREF_CHAP_ONLY_ALLOWED = 0x02,
168 E_AUTH_PREF_PAP_CHAP_BOTH_ALLOWED = 0x03
169}e_data_auth_pref_t;
170
171
172typedef struct
173{
174 uint8_t profile_valid; /**< Must be set to TRUE if umts_profile is being passed. */
175 uint8_t profile_id; /**< profile ID. as well as called cid*/
176 uint8_t ip_family_valid; /**< Must be set to TRUE if ip_family is being passed. */
177 e_data_ip_family_t ip_family; /**< Data IP Family */
178 uint8_t apn_name_valid; /**< Must be set to TRUE if apn_name is being passed. */
179 char apn_name[DATA_MAX_APN_LEN+1]; /**< Data APN Name. A character string that identifies a PDN*/
180 uint8_t user_name_valid; /**< Must be set to TRUE if user_name is being passed. */
181 char user_name[DATA_MAX_USERNAME_LEN+1]; /**< Username for the APN. */
182 uint8_t password_valid; /**< Must be set to TRUE if password is being passed. */
183 char password[DATA_MAX_PASSWORD_LEN+1]; /**< Password for the APN. */
184 uint8_t auth_pref_valid; /**< Must be set to TRUE if tech_pref is being passed. */
185 e_data_auth_pref_t auth_pref; /**< Data auth Preference */
186 uint8_t tech_pref_valid; /**< Must be set to TRUE if tech_pref is being passed. */
187 e_data_tech_pref_t tech_pref; /**< Data Tech Preference */
188}Data_call_config_info_t;
189
190
191typedef struct
192{
193 char addr_valid; /**< Indicates whether a valid address is available. */
194 struct sockaddr_storage addr; /**< Stores the IP address. defined in kernel socket.h*/
195}data_call_addr_t;
196
197typedef struct
198{
199 data_call_addr_t iface_addr_s; /**< Network interface address. */
200 uint32_t iface_mask; /**< Subnet mask. */
201 data_call_addr_t gtwy_addr_s; /**< Gateway server address. */
202 uint32_t gtwy_mask; /**< Gateway mask. */
203 data_call_addr_t dnsp_addr_s; /**< Primary DNS server address. */
204 data_call_addr_t dnss_addr_s; /**< Secondary DNS server address. */
205}data_call_addr_info_t;
206
207typedef struct
208{
209 char iface_name[DATA_INTERFACE_NAME_LEN + 1]; /**< Network interface name. */
210 uint8_t addr_info_len; /**< Must be set to the number of elements in addr_info. */
211 data_call_addr_info_t addr_info[DATA_MAX_ADDR_COUNT]; /**< Data device address list. */
212}Data_call_addr_info_list_t;
213
214typedef enum{
215 E_RF_RESOURCE_CALLBACK_EVENT = 0x00, /**< É䯵×ÊÔ´Çл». */
216 E_NW_ATTACH_COMMPLETE_EVENT = 0x32, /**< ×¢ÍøÍê³É. */
217 E_DATA_PDN_ACT_SUCC_EVENT = 0x64, /**< PDN¼¤»îÍê³É ,ind_dataÖÐЯ´øZGIPDNS:µØÖ·ÐÅÏ¢ */
218}E_MODEM_EVENT_ID;
219
220typedef enum
221{
222 E_SIM_STAT_NOT_INSERTED = 0x00,
223 E_SIM_STAT_READY = 0x01,
224 E_SIM_STAT_PIN = 0x02,
225 E_SIM_STAT_PUK = 0x03,
226 E_SIM_STAT_BUSY = 0x04,
227 E_SIM_STAT_UNKNOWN = 0x05,
228}E_SIM_STATUS;
229
230
231/*********************************************************************
232** Ãû³Æ£º VSIM_COMMAND
233** ÃèÊö£º ModemºÍVSIMµÄAPDUͨÐŽӿں¯ÊýµÄ½á¹¹¶¨Ò壻
234** ¸ÃÀàÐͶ¨ÒåµÄº¯ÊýÐèҪͨ¹ýzte_atVsimInit½Ó¿ÚÍê³É×¢²á
235**
236*********************************************************************/
237
238typedef int (*VSIM_COMMAND)(uint8_t *apdu_req, uint16_t apdu_req_len,uint8_t *apdu_rsp, uint16_t *apdu_rsp_len, uint8_t slot);
239
240/*********************************************************************
241** Ãû³Æ£º zte_mdm_event_ind_callback
242** ÃèÊö£º ÏûϢʼþ֪ͨº¯ÊýµÄ½á¹¹¶¨Òå
243** ind_dataÖÐÆ½Ì¨×Ô¶¨ÒåÌí¼ÓÃèÊö
244** ±ÈÈçRF×ÊÔ´»ØÊÕÔ­Òò£º1. For SIM1 TAU; 2. For SIM1 Regist Network;3. NULL;
245**
246*********************************************************************/
247
248typedef int32_t (*zte_mdm_event_ind_callback)(E_MODEM_EVENT_ID event_id, void *ind_data, uint32_t ind_data_len);
249
250/*********************************************************************
251** Ãû³Æ£º zte_mdm_event_regist
252** ÃèÊö£º
253** ÏûϢʼþ֪ͨº¯Êý×¢²áÈë¿Ú£¬Ìṩ¸ø¿Í»§×¢²áÏûÏ¢º¯Êý;
254** modem²à²úÉúʼþ£¬»áµ÷ÓÃind_cb֪ͨ¿Í»§£»
255*********************************************************************/
256extern int32_t zte_mdm_event_regist(zte_mdm_event_ind_callback ind_cb);
257
258
259/*********************ZTE VSIM API***************************/
260
261extern int32_t zte_atVsimInit(VSIM_COMMAND vsim_apdu_process_fn, uint8_t nSimID);
262
263extern int32_t zte_atVsimClose(VSIM_COMMAND vsim_apdu_process_fn, uint8_t nSimID);
264
265extern int32_t zte_atVsimReset(void);
266
267//extern int16_t zte_SetSimWorkMode(SimTypeInSlot_t SimType, uint8_t nSoltID);
268
269//extern int16_t zte_GetSimWorkMode(SimTypeInSlot_t *SimType, uint8_t nSoltID);
270
271extern int32_t zte_SetGTDUALSIM(uint8_t nSimID);
272
273extern int32_t zte_GetGTDUALSIM(uint8_t *nSimID);
274
275extern int32_t zte_SetGTDATASIM(uint8_t nSimID);
276
277extern int32_t zte_GetGTDATASIM(uint8_t *nSimID);
278
279extern int32_t zte_SetCfunMode(uint8_t mode);
280
281extern int32_t zte_GetCfunMode(uint8_t *mode);
282
283extern int32_t zte_SetIMEIbySimId(uint8_t *imei, uint8_t imei_len, uint8_t nSimID);
284
285extern int32_t zte_GetIMEIbySimId(uint8_t *imei, uint8_t imei_len, uint8_t nSimID);
286
287extern int32_t zte_GetCCIDbySimId(uint8_t *ccid, uint8_t ccid_len, uint8_t nSimID);
288
289extern int32_t zte_GetMCCMNCbySimId(char *mcc, char *mnc, uint8_t nSimID);
290
291extern int32_t zte_SwitchSimHandle(uint8_t mode);
292
293extern int32_t zte_GetCSQbySimId(int32_t *rssi, int32_t *ber, uint8_t nSimID);
294
295extern int32_t zte_GetRegInfobySimid(RegInfo_t *reg_info, uint8_t nSimID);
296
297extern int32_t zte_GetCellInfobySimId(CellInfo_t *pcellinfo, uint8_t nSimID);
298
299extern int32_t zte_GetNetInfobySimId(NetInfo_t *pNetInfo, uint8_t nSimID);
300
301extern int32_t zte_SetAPNbySimID(Data_call_config_info_t *data_call, uint8_t nSimID);
302
303extern int32_t zte_StartDataCallbySimId(Data_call_config_info_t *data_call, uint8_t nSimID);
304
305extern int32_t zte_StopDataCallbySimId(uint8_t profile_id, uint8_t nSimID);
306
307extern int32_t zte_GetDataAddrbySimID(uint8_t profile_id, Data_call_addr_info_list_t *addr_list, uint8_t nSimID);
308
309extern int32_t zte_GetSimStatusbySimId(E_SIM_STATUS *sim_status, uint8_t nSimID);
310
311extern int32_t zte_SendATbySimId(char *req_at, char *info_fmt, void **pval, uint8_t nSimID);
312/********************ZTE VSIM API END****************************/
313
314
315#endif //#ifndef __ZTE_VSIM_API_H_
316