[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit
Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/ap/lib/libvsim/Makefile b/ap/lib/libvsim/Makefile
new file mode 100755
index 0000000..dce8bd2
--- /dev/null
+++ b/ap/lib/libvsim/Makefile
@@ -0,0 +1,31 @@
+#*******************************************************************************
+# include ZTE library makefile
+#*******************************************************************************
+include $(COMMON_MK)
+
+LIB_STATIC = libght_vsim.a
+LIB_SHARED = libght_vsim.so
+
+OBJS = $(patsubst %.c,%.o,$(wildcard *.c))
+
+#定义宏和头文件目录,要用+=,不要用=,否则会覆盖COMMON_MK里的值
+CFLAGS += -g
+CFLAGS += -I$(APP_DIR)/include
+
+#下面不要修改
+CFLAGS += -fPIC
+LDFLAGS += -shared
+
+all: $(LIB_STATIC) $(LIB_SHARED)
+
+$(LIB_STATIC) : $(OBJS)
+ $(AR) rcs $(LIB_STATIC) $(OBJS)
+
+$(LIB_SHARED): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^
+
+romfs:
+ $(ROMFSINST) $(LIB_SHARED) /lib/$(LIB_SHARED)
+
+clean:
+ -@rm *.a *.o *.so $(LIB_SHARED) $(LIB_STATIC) $(OBJS)
diff --git a/ap/lib/libvsim/ght_error.h b/ap/lib/libvsim/ght_error.h
new file mode 100755
index 0000000..8c5cc4a
--- /dev/null
+++ b/ap/lib/libvsim/ght_error.h
@@ -0,0 +1,88 @@
+/*********************************************************************************
+** Copyright @ Fibocom Technologies Co., Ltd. 2023-2030. All rights reserved.
+** File name: fibo_error.h
+** Author: GaoZeng
+** Version: V1.0.0
+** Date: 2023.02.14
+** Description: This file provides the definitions for error code.
+** Others:
+** History:
+***********************************************************************************/
+#ifndef __FIBO_ERROR_H__
+#define __FIBO_ERROR_H__
+
+/****************************************************************************
+ * Error Code Definition
+ ***************************************************************************/
+
+typedef enum {
+ E_FIBO_NO_ERR = 0,
+ E_FIBO_ERR_GENERIC = -1, /*Generic error. */
+ E_FIBO_ERR_NOT_SUPPORT = -2,
+ E_FIBO_ERR_IO_ERROR = -3,
+ E_FIBO_ERR_NOT_IMPLEMENTED = -4,
+ E_FIBO_ERR_IP_INVALID = -5,
+ E_FIBO_ERR_OS_INVALID = -6,
+ E_FIBO_ERR_LOG_INIT_FIAL = -7,
+ E_FIBO_ERR_OS_TIMEOUT = -8,
+ E_FIBO_ERR_OS_ERROR = -9,
+ E_FIBO_ERR_PARAM_INVALID = -10, /*Parameter is invalid.*/
+ E_FIBO_ERR_CALLBACK_EXIST = -11,
+ E_FIBO_ERR_SERVER_FD_PARAM_INVALID = -12,
+ E_FIBO_ERR_DATA_CREATE_FIAL = -13,
+ E_FIBO_ERR_DATA_INVALID_TECH_PREF = -14, /*Invalid technical preference. */
+ E_FIBO_ERR_DATA_INVALID_APN_TYPE = -15,
+ E_FIBO_ERR_DATA_INVALID_AUTH_TYPE = -16,
+ E_FIBO_ERR_DATA_INVALID_IP_FAMILY_PREF = -17,
+ E_FIBO_ERR_DATA_INVALID_CDMA_PROFILE_PREF = -18,
+ E_FIBO_ERR_DATA_INVALID_UMTS_PROFILE_PREF = -19,
+ E_FIBO_ERR_DATA_INVALID_USERNAM_PREF = -20,
+ E_FIBO_ERR_DATA_INVALID_PASSWORD_PREF = -21,
+ E_FIBO_ERR_DATA_CALL_FAILED = -22,
+ E_FIBO_ERR_DATA_GET_IP_FAIL = -23,
+ E_FIBO_ERR_DATA_GET_NAME_FAIL = -24,
+ E_FIBO_ERR_DATA_GET_NO_IP = -25,
+ E_FIBO_ERR_DATA_CALL_EXIST = -26,
+ E_FIBO_ERR_RADIO_RESET = -27, /*SSR happen, device not in proper state. */
+ E_FIBO_ERR_INSUFFICIENT_RESOURCES = -28, /*Insufficient resources. */
+ E_FIBO_ERR_DATA_APN_BE_USED = -29,
+ E_FIBO_ERR_DATA_EXIST_SAME_PROFILE = -30,
+ E_FIBO_ERR_DATA_PROFILE_USED_CALLED = -31,
+
+}e_error_code_t;
+
+#define FIBO_NO_ERR E_FIBO_NO_ERR
+#define FIBO_ERR_GENERIC E_FIBO_ERR_GENERIC
+#define FIBO_ERR_NOT_SUPPORT E_FIBO_ERR_NOT_SUPPORT
+#define FIBO_ERR_IO_ERROR E_FIBO_ERR_IO_ERROR
+#define FIBO_ERR_NOT_IMPLEMENTED E_FIBO_ERR_NOT_IMPLEMENTED
+#define FIBO_ERR_IP_INVALID E_FIBO_ERR_IP_INVALID
+#define FIBO_ERR_OS_INVALID E_FIBO_ERR_OS_INVALID
+#define FIBO_ERR_LOG_INIT_FIAL E_FIBO_ERR_LOG_INIT_FIAL
+#define FIBO_ERR_OS_TIMEOUT E_FIBO_ERR_OS_TIMEOUT
+#define FIBO_ERR_OS_ERROR E_FIBO_ERR_OS_ERROR
+#define FIBO_ERR_PARAM_INVALID E_FIBO_ERR_PARAM_INVALID
+#define FIBO_ERR_CALLBACK_EXIST E_FIBO_ERR_CALLBACK_EXIST
+#define FIBO_ERR_SERVER_FD_PARAM_INVALID E_FIBO_ERR_SERVER_FD_PARAM_INVALID
+#define FIBO_ERR_DATA_CREATE_FIAL E_FIBO_ERR_DATA_CREATE_FIAL
+#define FIBO_ERR_DATA_INVALID_TECH_PREF E_FIBO_ERR_DATA_INVALID_TECH_PREF
+#define FIBO_ERR_DATA_INVALID_APN_TYPE E_FIBO_ERR_DATA_INVALID_APN_TYPE
+#define FIBO_ERR_DATA_INVALID_AUTH_TYPE E_FIBO_ERR_DATA_INVALID_AUTH_TYPE
+#define FIBO_ERR_DATA_INVALID_IP_FAMILY_PREF E_FIBO_ERR_DATA_INVALID_IP_FAMILY_PREF
+#define FIBO_ERR_DATA_INVALID_CDMA_PROFILE_PREF E_FIBO_ERR_DATA_INVALID_CDMA_PROFILE_PREF
+#define FIBO_ERR_DATA_INVALID_UMTS_PROFILE_PREF E_FIBO_ERR_DATA_INVALID_UMTS_PROFILE_PREF
+#define FIBO_ERR_DATA_INVALID_USERNAM_PREF E_FIBO_ERR_DATA_INVALID_USERNAM_PREF
+#define FIBO_ERR_DATA_INVALID_PASSWORD_PREF E_FIBO_ERR_DATA_INVALID_PASSWORD_PREF
+#define FIBO_ERR_DATA_CALL_FAILED E_FIBO_ERR_DATA_CALL_FAILED
+#define FIBO_ERR_DATA_GET_IP_FAIL E_FIBO_ERR_DATA_GET_IP_FAIL
+#define FIBO_ERR_DATA_GET_NAME_FAIL E_FIBO_ERR_DATA_GET_NAME_FAIL
+#define FIBO_ERR_DATA_GET_NO_IP E_FIBO_ERR_DATA_GET_NO_IP
+#define FIBO_ERR_DATA_CALL_EXIST E_FIBO_ERR_DATA_CALL_EXIST
+#define FIBO_ERR_RADIO_RESET E_FIBO_ERR_RADIO_RESET
+#define FIBO_ERR_INSUFFICIENT_RESOURCES E_FIBO_ERR_INSUFFICIENT_RESOURCES
+#define FIBO_ERR_DATA_APN_BE_USED E_FIBO_ERR_DATA_APN_BE_USED
+#define FIBO_ERR_DATA_EXIST_SAME_PROFILE E_FIBO_ERR_DATA_EXIST_SAME_PROFILE
+#define FIBO_ERR_DATA_PROFILE_USED_CALLED E_FIBO_ERR_DATA_PROFILE_USED_CALLED
+
+
+#endif //#ifndef __FIBO_ERROR_H__
\ No newline at end of file
diff --git a/ap/lib/libvsim/ght_vsim_api.c b/ap/lib/libvsim/ght_vsim_api.c
new file mode 100755
index 0000000..5d2647f
--- /dev/null
+++ b/ap/lib/libvsim/ght_vsim_api.c
@@ -0,0 +1,411 @@
+#include "ght_vsim_api.h"
+
+//********2023-01-13***********//
+
+//================================================
+
+typedef int32_t (*zte_mdm_event_ind_callback)(E_MODEM_EVENT_ID event_id, void *ind_data, uint32_t ind_data_len);
+/**********************ZTE funcation Declartion here************
+*/
+extern int32_t zte_mdm_event_regist(zte_mdm_event_ind_callback ind_cb);
+
+extern int32_t zte_atVsimInit(VSIM_COMMAND vsim_apdu_process_fn, uint8_t nSimID);
+
+extern int32_t zte_atVsimClose(VSIM_COMMAND vsim_apdu_process_fn, uint8_t nSimID);
+
+extern int32_t zte_atVsimReset(void);
+
+//extern int16_t zte_SetSimWorkMode(SimTypeInSlot_t SimType, uint8_t nSoltID);
+
+//extern int16_t zte_GetSimWorkMode(SimTypeInSlot_t *SimType, uint8_t nSoltID);
+
+extern int32_t zte_SetGTDUALSIM(uint8_t nSimID);
+
+extern int32_t zte_GetGTDUALSIM(uint8_t *nSimID);
+
+extern int32_t zte_SetGTDATASIM(uint8_t nSimID);
+
+extern int32_t zte_GetGTDATASIM(uint8_t *nSimID);
+
+extern int32_t zte_SetCfunMode(uint8_t mode);
+
+extern int32_t zte_GetCfunMode(uint8_t *mode);
+
+extern int32_t zte_SetIMEIbySimId(uint8_t *imei, uint8_t imei_len, uint8_t nSimID);
+
+extern int32_t zte_GetIMEIbySimId(uint8_t *imei, uint8_t imei_len, uint8_t nSimID);
+
+extern int32_t zte_GetCCIDbySimId(uint8_t *ccid, uint8_t ccid_len, uint8_t nSimID);
+
+extern int32_t zte_GetMCCMNCbySimId(char *mcc, char *mnc, uint8_t nSimID);
+
+extern int32_t zte_SwitchSimHandle(uint8_t mode);
+
+extern int32_t zte_GetCSQbySimId(int32_t *rssi, int32_t *ber, uint8_t nSimID);
+
+extern int32_t zte_GetRegInfobySimid(RegInfo_t *reg_info, uint8_t nSimID);
+
+extern int32_t zte_GetCellInfobySimId(CellInfo_t *pcellinfo, uint8_t nSimID);
+
+extern int32_t zte_GetNetInfobySimId(NetInfo_t *pNetInfo, uint8_t nSimID);
+
+extern int32_t zte_SetAPNbySimID(Data_call_config_info_t *data_call, uint8_t nSimID);
+
+extern int32_t zte_StartDataCallbySimId(Data_call_config_info_t *data_call, uint8_t nSimID);
+
+extern int32_t zte_StopDataCallbySimId(uint8_t profile_id, uint8_t nSimID);
+
+extern int32_t zte_GetDataAddrbySimID(uint8_t profile_id, Data_call_addr_info_list_t *addr_list, uint8_t nSimID);
+
+extern int32_t zte_GetSimStatusbySimId(E_SIM_STATUS *sim_status, uint8_t nSimID);
+
+extern int32_t zte_SendATbySimId(char *req_at, char *info_fmt, void **pval, uint8_t nSimID);
+
+/*
+*************************ZTE API Declartion end*************************/
+
+FIBO_MODEM_EVENT g_ind_cb;
+
+int32_t fibo_mdm_event_ind_cb(E_MODEM_EVENT_ID event_id, void *ind_data, uint32_t ind_data_len)
+{
+ if(g_ind_cb)
+ g_ind_cb(event_id, ind_data, ind_data_len);
+
+ return 0;
+}
+
+
+/***********************The Fibo Public APIs Defination area*********************
+*/
+int32_t fibo_mdm_event_regist(FIBO_MODEM_EVENT ind_cb)
+{
+ g_ind_cb = ind_cb;
+ return 0;
+}
+
+/**********************************************************
+** Function Name: fibo_vsim_init
+** Description:
+** VSIM³õʼ»¯£¬ÐèÒª½«APDU»Øµ÷º¯Êý×÷ΪÈë²Î´«Èë¸ø modem;
+**
+***********************************************************/
+
+void fibo_vsim_init(VSIM_COMMAND vsim_apdu_process, uint8_t nSimID)
+{
+ printf("[VSIM] fibo_vsim_init,%d", nSimID);
+ zte_mdm_event_regist(fibo_mdm_event_ind_cb);
+ zte_atVsimInit(vsim_apdu_process, nSimID);
+}
+
+/**********************************************************
+** Function Name: fibo_vsim_close
+** Description:
+** ¹Ø±ÕVSIM;
+**
+***********************************************************/
+
+void fibo_vsim_close(VSIM_COMMAND vsim_apdu_process, uint8_t nSimID)
+{
+ printf("[VSIM] fibo_vsim_close,%d", nSimID);
+ zte_atVsimClose(vsim_apdu_process, nSimID);
+}
+
+/**************************************************************
+** Function Name: fibo_set_sim_workmode
+** Description:
+** Õë¶ÔË«¿¨Ä£×飬ÉèÖÃË«¿¨²ÛÖеĿ¨ÀàÐÍ£¬½ø¶øÄܹ»ÊÊÅäÏàÓ¦Ó¦ÓóÌÐò¹¦ÄÜ;
+**
+***************************************************************/
+
+int16_t fibo_set_sim_workmode(SimTypeInSlot_t SimType, uint8_t nSoltID)
+{
+ return 0;
+}
+
+/**************************************************************
+** Function Name: fibo_get_sim_workmode
+** Description:
+** Õë¶ÔË«¿¨Ä£×飬ÉèÖÃË«¿¨²ÛÖеĿ¨ÀàÐÍ£¬½ø¶øÄܹ»ÊÊÅäÏàÓ¦Ó¦ÓóÌÐò¹¦ÄÜ;
+**
+***************************************************************/
+
+int16_t fibo_get_sim_workmode(SimTypeInSlot_t *SimType, uint8_t nSoltID)
+{
+ return 0;
+}
+
+/**************************************************************
+** Function Name: fibo_set_dualsim
+** Description:
+** Ë«¿¨Çл»ÅäÖýӿڣ¬¸ù¾ÝÈë²ÎSimIDÇл»µ½¶ÔÓ¦µÄ¹¤×÷¿¨£¬SIMÏà¹ØATÒ²ÓëÖ®Çл»;
+**
+***************************************************************/
+
+int32_t fibo_set_dualsim(uint8_t nSimID)
+{
+ return zte_SetGTDUALSIM(nSimID);
+}
+
+
+/**************************************************************
+** Function Name: fibo_set_dualsim
+** Description:
+** Ë«¿¨Çл»»ñÈ¡½Ó¿Ú£¬»ñÈ¡µ±Ç°¹¤×÷µÄSIM ID;
+**
+***************************************************************/
+
+int32_t fibo_get_dualsim(uint8_t *nSimID)
+{
+ return zte_GetGTDUALSIM(nSimID);
+}
+
+/**************************************************************
+** Function Name: fibo_set_dualsim
+** Description:
+** ÅäÖÃÊý¾Ý¿¨ÎªnSimIDÖ¸ÏòµÄ¿¨;
+**
+***************************************************************/
+
+int32_t fibo_set_datasim(uint8_t nSimID)
+{
+ return zte_SetGTDATASIM(nSimID);
+}
+
+/**************************************************************
+** Function Name: fibo_get_datasim
+** Description:
+** »ñÈ¡µ±Ç°ÅäÖõÄÊý¾Ý¿¨ID;
+**
+***************************************************************/
+
+int32_t fibo_get_datasim(uint8_t *nSimID)
+{
+ return zte_GetGTDATASIM(nSimID);
+}
+
+
+/**********************************************************
+** Function Name: fibo_set_IMEI_by_simid
+** Description:
+** ÉèÖÃVSIM¶ÔÓ¦µÄIMEI;
+**
+** Note: É豸IMEI£¬µôµç²»±£´æ£¬ÔÚvsim_initÖ®ºó;
+***********************************************************/
+
+int32_t fibo_set_IMEI_by_simid(uint8_t *imei, uint8_t imei_len, uint8_t nSimID)
+{
+ printf("[VSIM] fibo_set_imei,%d", nSimID);
+ return zte_SetIMEIbySimId(imei, imei_len, nSimID);
+}
+
+/**********************************************************
+** Function Name: fibo_set_IMEI_by_simid
+** Description:
+** »ñÈ¡VSIM¶ÔÓ¦µÄIMEI;
+**
+** Note: É豸IMEI£¬µôµç²»±£´æ£¬ÔÚvsim_initÖ®ºó;
+***********************************************************/
+
+int32_t fibo_get_IMEI_by_simid(uint8_t *imei, uint8_t imei_len, uint8_t nSimID)
+{
+ printf("[VSIM] fibo_get_imei,%d", nSimID);
+ return zte_GetIMEIbySimId(imei, imei_len, nSimID);
+}
+
+
+/**********************************************************
+** Function Name: fibo_get_CCID_by_simid
+** Description:
+** »ñȡָ¶¨SIMµÄICCID;
+**
+***********************************************************/
+
+int32_t fibo_get_CCID_by_simid(uint8_t *ccid, uint8_t ccid_len, uint8_t nSimID)
+{
+ printf("[VSIM]fibo_get_CCID_by_simid %d", nSimID);
+ return zte_GetCCIDbySimId(ccid, ccid_len, nSimID);
+}
+
+/**********************************************************
+** Function Name: fibo_xiaoshui_get_mcc_mnc
+** Description:
+** ¿Í»§¶¨ÖÆÐèÇó½Ó¿Ú£¬»ñÈ¡·þÎñÍøÂçMCCºÍMNC;
+**
+***********************************************************/
+
+int32_t fibo_get_MCC_MNC_by_simid(char *mcc, char *mnc, uint8_t nSimID)
+{
+ return zte_GetMCCMNCbySimId(mcc, mnc, nSimID);
+}
+
+/**********************************************************
+** Function Name: fibo_switch_sim_handle
+** Description:
+** µ÷ÓøýӿڽøÐÐVSIMÇл»£¬Í¬Ê±Íê³ÉPDPÁ¬½Ó;
+** mode: 0¹Ø±ÕVSIM, 1¿ªÆôVSIM;
+** Note: ÈôÊǵ÷ÓÃfibo_switch_sim_handle(1)£¬Ö®ºó´æÔÚµ÷ÓÃfibo_set_dualsim(0)
+** µÄÇé¿ö£¬´Ëʱfibo_set_dualsim(0)½öÓÃÓÚÁÙʱÇп¨µ½ÊµÌ忨
+***********************************************************/
+
+int32_t fibo_switch_sim_handle(uint8_t mode)
+{
+ return zte_SwitchSimHandle(mode);
+}
+
+/**********************************************************
+** Function Name: fibo_set_cfun_mode
+** Description:
+** ÉèÖÃCFUN²ÎÊý;
+**
+***********************************************************/
+
+int32_t fibo_set_cfun_mode(uint8_t mode)
+{
+ return zte_SetCfunMode(mode);
+ //¹ãºÍͨͬ²½Æä¶þ´Î¿ª·¢³ÌÐò²ÎÊý
+}
+
+/**********************************************************
+** Function Name: fibo_get_cfun_mode
+** Description:
+** »ñÈ¡CFUN²ÎÊý;
+**
+***********************************************************/
+
+int32_t fibo_get_cfun_mode(uint8_t *mode)
+{
+ return zte_GetCfunMode(mode);
+ //¹ãºÍͨͬ²½Æä¶þ´Î¿ª·¢³ÌÐò²ÎÊý
+}
+
+
+/**********************************************************
+** Function Name: fibo_set_SysReset
+** Description:
+** ÖØÆôÉ豸;
+**
+***********************************************************/
+
+int32_t fibo_set_SysReset()
+{
+ zte_atVsimReset();
+ //modem cfun=0¹Ø»ú+ϵͳµ÷Óùػú
+ //ϵͳµ÷Óùػú
+ //ÆäËû¹ãºÍͨʵÏÖ
+ return 0;
+}
+
+/**********************************************************
+** Function Name: fibo_get_csq_by_simid
+** Description:
+** »ñÈ¡ÓëSIM IDÏà¹ØµÄCSQ;
+**
+***********************************************************/
+
+int32_t fibo_get_CSQ_by_simid(int32_t *rssi, int32_t *ber, uint8_t nSimID)
+{
+ return zte_GetCSQbySimId(rssi, ber, nSimID);
+}
+
+/**********************************************************
+** Function Name: fibo_getRegInfo
+** Description:
+** »ñÈ¡ÓëSIM IDÏà¹ØµÄRegInfo;
+**
+***********************************************************/
+
+int32_t fibo_get_RegInfo_by_simid(RegInfo_t *reg_info, uint8_t nSimID)
+{
+ return zte_GetRegInfobySimid(reg_info, nSimID);
+}
+
+
+/**********************************************************
+** Function Name: fibo_getCellInfo
+** Description:
+** »ñÈ¡ÓëSIM IDÏà¹ØµÄCellInfo;
+**
+***********************************************************/
+
+int32_t fibo_get_CellInfo_by_simid(CellInfo_t *pcellinfo, uint8_t nSimID)
+{
+ return zte_GetCellInfobySimId(pcellinfo, nSimID);
+}
+
+
+/**********************************************************
+** Function Name: fibo_get_NetInfo_by_simid
+** Description:
+** »ñÈ¡ÓëSIM IDÏà¹ØµÄ<´ýÈ·ÈÏ>;
+**
+***********************************************************/
+
+int32_t fibo_get_NetInfo_by_simid(NetInfo_t *pNetInfo, uint8_t nSimID)
+{
+ return zte_GetNetInfobySimId(pNetInfo, nSimID);;
+}
+
+/**********************************************************
+** Function Name: fibo_set_APN_by_simid
+** Description:
+** ÅäÖÃÓÃÓÚPDP¼¤»îµÄprofileÐÅÏ¢;
+**
+***********************************************************/
+
+int32_t fibo_set_APN_by_simid(Data_call_config_info_t *data_call, uint8_t nSimID)
+{
+ return zte_SetAPNbySimID(data_call, nSimID);
+}
+
+/**********************************************************
+** Function Name: fibo_start_Data_Call_by_simid
+** Description:
+** ¼¤»îÖ¸¶¨profile PDPÁ¬½Ó;
+**
+***********************************************************/
+
+int32_t fibo_start_Data_Call_by_simid(Data_call_config_info_t *data_call, uint8_t rndis_flag, uint8_t nSimID)
+{
+ return zte_StartDataCallbySimId(data_call, nSimID);
+}
+
+/**********************************************************
+** Function Name: fibo_stop_Data_Call_by_simid
+** Description:
+** È¥¼¤»îÖ¸¶¨profile PDPÁ¬½Ó;
+**
+***********************************************************/
+
+int32_t fibo_stop_Data_Call_by_simid(uint8_t profile_id, uint8_t rndis_flag, uint8_t nSimID)
+{
+ return zte_StopDataCallbySimId(profile_id, nSimID);
+}
+
+/**********************************************************
+** Function Name: fibo_get_Data_Addr_by_simid
+** Description:
+** »ñȡָ¶¨profileµÄµØÖ·ÐÅÏ¢;
+**
+***********************************************************/
+
+int32_t fibo_get_Data_Addr_by_simid(uint8_t profile_id, Data_call_addr_info_list_t *addr_list, uint8_t nSimID)
+{
+ return zte_GetDataAddrbySimID(profile_id, addr_list, nSimID);
+}
+
+
+int32_t fibo_get_SIM_Status_by_simid(E_SIM_STATUS *sim_status, uint8_t nSimID)
+{
+ return zte_GetSimStatusbySimId(sim_status, nSimID);
+}
+
+int32_t fibo_send_AT_by_simid(char *req_at, char *info_fmt, void **pval, uint8_t nSimID)
+{
+ return zte_SendATbySimId(req_at, info_fmt, pval, nSimID);
+}
+
+
+/*
+**********************The Public APIs Defination area end**********************/
+
+
diff --git a/ap/lib/libvsim/ght_vsim_api.h b/ap/lib/libvsim/ght_vsim_api.h
new file mode 100755
index 0000000..685794d
--- /dev/null
+++ b/ap/lib/libvsim/ght_vsim_api.h
@@ -0,0 +1,574 @@
+/*********************************************************************************
+** Copyright @ Fibocom Technologies Co., Ltd. 2023-2030. All rights reserved.
+** File name: fibo_vsim_api.h
+** Author: GaoZeng
+** Version: V1.0.0
+** Date: 2023.02.14
+** Description: This file provides the declaration Vsim-related APIs and structs.
+** Others:
+***********************************************************************************/
+#ifndef __GHT_VSIM_API_H__
+#define __GHT_VSIM_API_H__
+
+#include "stdio.h"
+#include "stdint.h"
+#include "stdlib.h"
+#include "string.h"
+#include "ght_error.h"
+#include "softap_api.h"
+#include <sys/socket.h>
+
+#define SIM_IMSI_LEN_MAX 16 /** Maximum length of IMSI data. */
+#define SIM_ICCID_LEN_MAX 21 /** Maximum length of ICCID data. */
+#define DATA_MAX_APN_LEN 57 /** Maximum length of the APN. */
+#define DATA_MAX_USERNAME_LEN 127 /** Maximum length of the profile user name. */
+#define DATA_MAX_PASSWORD_LEN 127 /** Maximum length of the profile password. */
+#define DATA_INTERFACE_NAME_LEN 16 /** Interface name length. */
+#define DATA_MAX_ADDR_COUNT 2 /** Maximum number of IP addresses. */
+
+//**************GHT VSIM Struct*********************//
+
+typedef enum {
+ E_SIM_TYPE_USIM, //ʵÌ忨
+ E_SIM_TYPE_VSIM, //ÔÆ¿¨
+ E_SIM_TYPE_SSIM, //Soft SIM
+}SimTypeInSlot_t;
+
+
+typedef enum {
+ E_NW_RADIO_IF_NO_SRV = 0,
+ E_NW_RADIO_IF_GSM = 1,
+ E_NW_RADIO_IF_WCDMA = 2,
+ E_NW_RADIO_IF_LTE = 3,
+ E_NW_RADIO_IF_TDSCDMA = 4,
+ E_NW_RADIO_IF_CDMA = 5,
+ E_NW_RADIO_IF_CDMA2000 = 6,
+}e_nw_rat_type_t; //RAT value
+
+
+typedef enum {
+ E_NW_STATUS_SRV_NONE = 0,
+ E_NW_STATUS_CURRENT_SERVING = 1,
+ E_NW_STATUS_SRV_LIMITED = 2,
+ E_NW_STATUS_SRV_AVAILABLE = 3,
+ E_NW_STATUS_SRV_FORBIDDEN = 4,
+}e_nw_srv_status_t;
+
+
+typedef struct
+{
+ uint32_t tac;
+ uint32_t cell_id;
+}lte_scell_info_t;
+
+typedef struct
+{
+ uint32_t lac;
+ uint32_t cell_id;
+}gsm_w_scell_info_t;
+
+
+
+typedef struct
+{
+ e_nw_rat_type_t curr_rat;
+ e_nw_srv_status_t nStatus;
+ lte_scell_info_t lte_scell_info; //¸³Öµ¿ÉÑ¡£¬Óû§¸ù¾ÝratÖ¸Ê¾ÍøÂçÀàÐÍȡֵ
+ gsm_w_scell_info_t gsm_w_scell_info; //¸³Öµ¿ÉÑ¡£¬Óû§¸ù¾ÝratÖ¸Ê¾ÍøÂçÀàÐÍȡֵ
+}RegInfo_t;
+
+typedef struct{
+ uint16_t mcc;
+ uint16_t mnc;
+ uint32_t tac;
+ uint32_t cell_id;
+ uint16_t bandwidth;
+ int16_t rxlev;
+ uint32_t arfcn;
+ uint16_t pcid;
+}base_cell_info_t;//Hex format
+
+
+typedef struct
+{
+ uint8_t roamingFlag; ///< 1:roaming,0:non roaming
+ int16_t rsrp;
+ int16_t rsrq;
+ uint16_t SINR;
+ uint16_t netMode; //0--tdd 1--fdd
+ uint16_t band;
+ base_cell_info_t base_Scell_info;
+} lte_Scell_t;
+
+typedef struct
+{
+ int16_t rsrp;
+ int16_t rsrq;
+ uint16_t netMode; //0--tdd 1--fdd
+ base_cell_info_t base_Ncell_info;
+}lte_Ncell_t;
+
+typedef struct
+{
+ uint16_t bsic; //only in GSM
+ uint16_t band;
+ uint16_t rscp; //only in W
+ base_cell_info_t base_Ncell_info;
+}gsm_W_Scell_t;
+
+
+typedef struct
+{
+ uint16_t bsic; //only GSM
+ uint16_t band;
+ uint16_t rscp; //only in W
+ base_cell_info_t base_Ncell_info;
+}gsm_W_Ncell_t;
+
+typedef struct
+{
+ lte_Scell_t lteScell;
+ uint16_t lteNcellNum;
+ lte_Ncell_t lteNcell[6];
+}lte_cellinfo_t;
+
+typedef struct{
+ gsm_W_Scell_t scell_info;
+ uint16_t gsm_W_NcellNum;
+ gsm_W_Ncell_t gsm_W_ncell[6];
+}gsm_W_cellifo_t;
+
+typedef struct{
+ e_nw_rat_type_t curr_rat;
+ e_nw_srv_status_t service_status; //0x00: in service; 0x01: not in
+ lte_cellinfo_t lte_cellinfo;
+ gsm_W_cellifo_t gsm_cellinfo;
+}CellInfo_t;
+
+
+typedef struct{
+ uint32_t lwip_ul;
+ uint32_t lwip_dl;
+ uint32_t ppp_ul;
+ uint32_t ppp_dl;
+ uint32_t rndis_ul;
+ uint32_t rndis_dl;
+}NetInfo_t; /**< µ¥Î»: bit*/
+
+typedef enum
+{
+ E_DATA_IP_FAMILY_UNKNOWN = 0x00, /**< unknown */
+ E_DATA_IP_FAMILY_IPV4 = 0x04, /**< IPv4 */
+ E_DATA_IP_FAMILY_IPV6 = 0x06, /**< IPv6 */
+ E_DATA_IP_FAMILY_IPV4V6 = 0x0A /**< IPv4|IPv6 */
+}e_data_ip_family_t;
+
+typedef enum
+{
+ E_DATA_TECH_PREF_UNKNOWN = 0x00, /**< unknown */
+ E_DATA_TECH_PREF_UMTS = 0x01, /**< UMTS */
+ E_DATA_TECH_PREF_CDMA = 0x02, /**< CDMA */
+ E_DATA_TECH_PREF_LTE = 0x03, /**< LTE */
+ E_DATA_TECH_PREF_AUTO = 0x04 /**< AUTO */
+}e_data_tech_pref_t;
+
+typedef enum
+{
+ E_AUTH_PREF_PAP_CHAP_NOT_ALLOWED = 0x00,
+ E_AUTH_PREF_PAP_ONLY_ALLOWED = 0x01,
+ E_AUTH_PREF_CHAP_ONLY_ALLOWED = 0x02,
+ E_AUTH_PREF_PAP_CHAP_BOTH_ALLOWED = 0x03
+}e_data_auth_pref_t;
+
+
+typedef struct
+{
+ uint8_t profile_valid; /**< Must be set to TRUE if umts_profile is being passed. */
+ uint8_t profile_id; /**< profile ID. as well as called cid*/
+ uint8_t ip_family_valid; /**< Must be set to TRUE if ip_family is being passed. */
+ e_data_ip_family_t ip_family; /**< Data IP Family */
+ uint8_t apn_name_valid; /**< Must be set to TRUE if apn_name is being passed. */
+ char apn_name[DATA_MAX_APN_LEN+1]; /**< Data APN Name. A character string that identifies a PDN*/
+ uint8_t user_name_valid; /**< Must be set to TRUE if user_name is being passed. */
+ char user_name[DATA_MAX_USERNAME_LEN+1]; /**< Username for the APN. */
+ uint8_t password_valid; /**< Must be set to TRUE if password is being passed. */
+ char password[DATA_MAX_PASSWORD_LEN+1]; /**< Password for the APN. */
+ uint8_t auth_pref_valid; /**< Must be set to TRUE if tech_pref is being passed. */
+ e_data_auth_pref_t auth_pref; /**< Data auth Preference */
+ uint8_t tech_pref_valid; /**< Must be set to TRUE if tech_pref is being passed. */
+ e_data_tech_pref_t tech_pref; /**< Data Tech Preference */
+}Data_call_config_info_t;
+
+
+typedef struct
+{
+ char addr_valid; /**< Indicates whether a valid address is available. */
+ struct sockaddr_storage addr; /**< Stores the IP address. defined in kernel socket.h*/
+}data_call_addr_t;
+
+typedef struct
+{
+ data_call_addr_t iface_addr_s; /**< Network interface address. */
+ uint32_t iface_mask; /**< Subnet mask. */
+ data_call_addr_t gtwy_addr_s; /**< Gateway server address. */
+ uint32_t gtwy_mask; /**< Gateway mask. */
+ data_call_addr_t dnsp_addr_s; /**< Primary DNS server address. */
+ data_call_addr_t dnss_addr_s; /**< Secondary DNS server address. */
+}data_call_addr_info_t;
+
+typedef struct
+{
+ char iface_name[DATA_INTERFACE_NAME_LEN + 1]; /**< Network interface name. */
+ uint8_t addr_info_len; /**< Must be set to the number of elements in addr_info. */
+ data_call_addr_info_t addr_info[DATA_MAX_ADDR_COUNT]; /**< Data device address list. */
+}Data_call_addr_info_list_t;
+
+typedef enum{
+ E_RF_RESOURCE_CALLBACK_EVENT = 0x00, /**< É䯵×ÊÔ´Çл». */
+ E_NW_ATTACH_COMMPLETE_EVENT = 0x32, /**< ×¢ÍøÍê³É. */
+ E_DATA_PDN_ACT_SUCC_EVENT = 0x64, /**< PDN¼¤»îÍê³É ,ind_dataÖÐЯ´øZGIPDNS:µØÖ·ÐÅÏ¢ */
+}E_MODEM_EVENT_ID;
+
+typedef enum
+{
+ E_SIM_STAT_NOT_INSERTED = 0x00,
+ E_SIM_STAT_READY = 0x01,
+ E_SIM_STAT_PIN = 0x02,
+ E_SIM_STAT_PUK = 0x03,
+ E_SIM_STAT_BUSY = 0x04,
+ E_SIM_STAT_UNKNOWN = 0x05,
+}E_SIM_STATUS;
+
+
+/*********************************************************************
+** Ãû³Æ£º VSIM_COMMAND
+** ÃèÊö£º VSIMÓ¦ÓúÍModemͨÐŵĻص÷º¯Êý½á¹¹Ìå
+**
+*********************************************************************/
+
+typedef int (*VSIM_COMMAND)(uint8_t *apdu_req, uint16_t apdu_req_len,uint8_t *apdu_rsp, uint16_t *apdu_rsp_len, uint8_t slot);
+
+
+/*********************************************************************
+** Ãû³Æ£º FIBO_MODEM_EVENT
+** ÃèÊö£º ÏûϢʼþ֪ͨº¯ÊýµÄ½á¹¹¶¨Òå
+** ind_dataÖÐÆ½Ì¨×Ô¶¨ÒåÌí¼ÓÃèÊö
+** ±ÈÈçRF×ÊÔ´»ØÊÕÔÒò£º1. For SIM1 TAU; 2. For SIM1 Regist Network;3. NULL;
+**
+*********************************************************************/
+
+typedef int32_t (*FIBO_MODEM_EVENT)(E_MODEM_EVENT_ID event_id, void *ind_data, uint32_t ind_data_len);
+
+/*********************************************************************
+** Ãû³Æ£º fibo_mdm_event_regist
+** ÃèÊö£º
+** ÏûϢʼþ֪ͨº¯Êý×¢²áÈë¿Ú£¬Ìṩ¸ø¿Í»§×¢²áÏûÏ¢º¯Êý;
+** modem²à²úÉúʼþ£¬»áµ÷ÓÃind_cb֪ͨ¿Í»§£»
+** IN:
+** ind_cb: func pointer;
+*********************************************************************/
+
+extern int32_t fibo_mdm_event_regist(FIBO_MODEM_EVENT ind_cb);
+
+/************************************************************************
+** Function Name: fibo_vsim_init
+** Description:
+** VSIM³õʼ»¯£¬ÐèÒª½«APDU»Øµ÷º¯Êý×÷ΪÈë²Î´«Èë¸ø modem;
+** VSIM¿ªÊ¼¹¤×÷ʱµ÷Óã¬ModemÊÕµ½ºó·¢Æð×¢²á£¬¿Í»§µÈ´ýʼþÉϱ¨½Ó¿Ú
+** Éϱ¨E_NW_ATTACH_COMMPLETE_EVENT
+** IN:
+** vsim_apdu_process: func pointer;
+** nSimID: value in range of [0,1];
+**************************************************************************/
+
+extern void fibo_vsim_init(VSIM_COMMAND vsim_apdu_process, uint8_t nSimID);
+
+/**********************************************************
+** Function Name: fibo_vsim_close
+** Description:
+** ¹Ø±ÕVSIM, modem²àÍê³ÉdetachºÍ¹Ø¿¨µÈ²Ù×÷;
+** IN:
+** vsim_apdu_process: function pointer;
+** nSimID: value in range of [0,1];
+***********************************************************/
+
+extern void fibo_vsim_close(VSIM_COMMAND vsim_apdu_process, uint8_t nSimID);
+
+/**************************************************************
+** Function Name: fibo_set_dualsim
+** Description:
+** Ë«¿¨Çл»ÅäÖýӿڣ¬¸ù¾ÝÈë²ÎSimIDÇл»µ½¶ÔÓ¦µÄ¹¤×÷¿¨£¬
+** SIMÏà¹ØATÒ²ÓëÖ®Çл»;
+** IN:
+** nSimID: value in range of [0,1];
+***************************************************************/
+
+extern int32_t fibo_set_dualsim(uint8_t nSimID);
+
+/**************************************************************
+** Function Name: fibo_set_dualsim
+** Description:
+** Ë«¿¨Çл»»ñÈ¡½Ó¿Ú£¬»ñÈ¡µ±Ç°ÓëATÏà¹ØµÄSIM ID;
+** OUT:
+** nSimID: pointer to memery restored current SIM ID;
+***************************************************************/
+
+extern int32_t fibo_get_dualsim(uint8_t *nSimID);
+
+/**************************************************************
+** Function Name: fibo_set_dualsim
+** Description:
+** ÅäÖÃÊý¾Ý¿¨ÎªnSimIDÖ¸ÏòµÄ¿¨;
+** ¸Ã½Ó¿Ú½öÇл»Óû§²àÊý¾ÝËùʹÓõÄSIM£¬
+** ²»Ó°ÏìSIM0ºÍSIM1µÄÍøÂç²àPDNÁ¬½Óͬʱ±£»î£¬
+** Çл»Ê±²»»áÒýÆðǰһÕÅ¿¨ÉϵÄPDNÁ¬½Ó¶Ï¿ª£¬ÈôÓеϰ;
+** IN:
+** nSimID: value in range of [0,1];
+***************************************************************/
+
+extern int32_t fibo_set_datasim(uint8_t nSimID);
+
+/**************************************************************
+** Function Name: fibo_get_datasim
+** Description:
+** »ñÈ¡µ±Ç°ÅäÖõÄÊý¾Ý¿¨ID;
+** OUT:
+** nSimID: pointer to memery restored current SIM ID;
+***************************************************************/
+
+extern int32_t fibo_get_datasim(uint8_t *nSimID);
+
+/**********************************************************
+** Function Name: fibo_set_IMEI_by_simid
+** Description:
+** ÉèÖÃVSIM¶ÔÓ¦µÄIMEI;
+** Note: ÉèÖÃIMEI£¬µôµç²»±£´æ£¬ËæÏµÍ³¿ª»úÓ¦ÓóÌÐòÀÆðʱµ÷ÓÃ;
+** IMEIºÍSIM0×¢Íøºó´ÓvSIM·þÎñ¶ËÏÂÔØµÄ¿¨°üÓйأ¬Ë濨°ü±ä»¯£»
+** IN:
+** imei: pointer to memery restored the IMEI to set;
+** imei_len: size of the memery pointed by "imei";
+** nSimID: value in range of [0,1];
+***********************************************************/
+
+extern int32_t fibo_set_IMEI_by_simid(uint8_t *imei, uint8_t imei_len, uint8_t nSimID);
+
+/**********************************************************
+** Function Name: fibo_set_IMEI_by_simid
+** Description:
+** »ñÈ¡VSIM¶ÔÓ¦µÄIMEI;
+** Note: É豸IMEI£¬µôµç²»±£´æ£¬ÔÚvsim_initÖ®ºó;
+** IN:
+** nSimID: value in range of [0,1];
+** imei_len: size of the memery pointed by "imei";
+** OUT:
+** imei: pointer to memery to restore the IMEI to get;
+***********************************************************/
+
+extern int32_t fibo_get_IMEI_by_simid(uint8_t *imei, uint8_t imei_len, uint8_t nSimID);
+
+/**********************************************************
+** Function Name: fibo_get_CCID_by_simid
+** Description:
+** »ñȡָ¶¨SIMµÄICCID;
+** IN:
+** nSimID: value in range of [0,1];
+** ccid_len: size of the memery pointed by "ccid";
+** OUT:
+** ccid: pointer to memery to restore the ICCID to get;
+***********************************************************/
+
+extern int32_t fibo_get_CCID_by_simid(uint8_t *ccid, uint8_t ccid_len, uint8_t nSimID);
+
+/**********************************************************
+** Function Name: fibo_get_MCC_MNC_by_simid
+** Description:
+** ¿Í»§¶¨ÖÆÐèÇó½Ó¿Ú£¬»ñÈ¡·þÎñÍøÂçMCCºÍMNC;
+** IN:
+** nSimID: value in range of [0,1];
+** OUT:
+** mcc: pointer to memery to restore the mcc to get;
+** mnc: pointer to memery to restore the mnc to get;
+** Note:
+* please deliver a buffer of which size is range in [2,3];
+***********************************************************/
+
+extern int32_t fibo_get_MCC_MNC_by_simid(char *mcc, char *mnc, uint8_t nSimID);
+
+/**********************************************************
+** Function Name: fibo_set_cfun_mode
+** Description:
+** ÉèÖÃCFUN²ÎÊý;
+** IN:
+** mode: value in [0,1,4];
+** 0: close modem stack(MS);
+** 1: open MS or out of Airplane;
+** 4: into Airplane and close RF TRX channel;
+***********************************************************/
+
+extern int32_t fibo_set_cfun_mode(uint8_t mode);
+
+/**********************************************************
+** Function Name: fibo_get_cfun_mode
+** Description:
+** »ñÈ¡CFUN²ÎÊý;
+** OUT:
+** mode: value in [0,1,4];
+** 0: close modem stack(MS);
+** 1: open MS or out of Airplane;
+** 4: into Airplane and close RF TRX channel;
+***********************************************************/
+
+extern int32_t fibo_get_cfun_mode(uint8_t *mode);
+
+/**********************************************************
+** Function Name: fibo_set_SysReset
+** Description:
+** ÖØÆôÉ豸;
+**
+***********************************************************/
+
+extern int32_t fibo_set_SysReset();
+
+/**********************************************************
+** Function Name: fibo_get_CSQ_by_simid
+** Description:
+** »ñÈ¡ÓëSIM IDÏà¹ØµÄCSQ;
+** OUT:
+** rssi: -110dbm~-51dbm in GSM;
+** ´ú±írscp: -115dbm~-25dbm;´ú±írsrp: -140dbm~-44dbm in LTE;
+** ber: Only in GSM
+** 0 BER < 0.2 %
+** 1 0.2 % < BER < 0.4 %
+** 2 0.4 % < BER < 0.8 %
+** 3 0.8 % < BER < 1.6 %
+** 4 1.6 % < BER < 3.2 %
+** 5 3.2 % < BER < 6.4 %
+** 6 6.4 % < BER < 12.8 %
+** 7 12.8 % < BER
+** 99 δ֪»ò²»¿É²â
+** IN:
+** nSimID: value in range of [0,1];
+***********************************************************/
+
+extern int32_t fibo_get_CSQ_by_simid(int32_t *rssi, int32_t *ber, uint8_t nSimID);
+
+/**********************************************************
+** Function Name: fibo_getRegInfo
+** Description:
+** »ñÈ¡ÓëSIM IDÏà¹ØµÄRegInfo;
+**
+***********************************************************/
+
+extern int32_t fibo_get_RegInfo_by_simid(RegInfo_t *reg_info, uint8_t nSimID);
+
+/**********************************************************
+** Function Name: fibo_get_CellInfo_by_simid
+** Description:
+** »ñÈ¡ÓëSIM IDÏà¹ØµÄCellInfo;
+**
+***********************************************************/
+
+extern int32_t fibo_get_CellInfo_by_simid(CellInfo_t *pcellinfo, uint8_t nSimID);
+
+/**********************************************************
+** Function Name: fibo_get_NetInfo_by_simid
+** Description:
+** »ñÈ¡ÓëSIM IDÏà¹ØµÄÁ÷Á¿ÐÅÏ¢;
+** OUT:
+** pNetInfo: ´æ´¢»ñÈ¡µÄÁ÷Á¿ÐÅÏ¢;µ¥Î»: /bit
+***********************************************************/
+
+extern int32_t fibo_get_NetInfo_by_simid(NetInfo_t *pNetInfo, uint8_t nSimID);
+
+/**********************************************************
+** Function Name: fibo_set_APN_by_simid
+** Description:
+** ÅäÖÃÓÃÓÚPDP¼¤»îµÄprofileÐÅÏ¢;
+** IN:
+** profile_id: ָʾȥ¼¤»îµÄcid;
+** rndis_flag: 0x00: ÄÚÖò¦ºÅ; 0x01:ÍâÖò¦ºÅ;
+***********************************************************/
+
+extern int32_t fibo_set_APN_by_simid(Data_call_config_info_t *data_call, uint8_t nSimID);
+
+/******************************************************************************
+** Function Name: fibo_start_Data_Call_by_simid
+** Description:
+** ¼¤»îÖ¸¶¨profile PDPÁ¬½Ó£¬ZGACTºÍCGACT¾ùÏ·¢µÄÍâÖò¦ºÅ;
+** IN:
+** nSimID: value in range of [0,1];
+** data_call: pointer to memery restore apn profile;
+** rndis_flag: 0x00: ÄÚÖò¦ºÅ; 0x01:ÍâÖò¦ºÅ;
+******************************************************************************/
+
+extern int32_t fibo_start_Data_Call_by_simid(Data_call_config_info_t *data_call, uint8_t rndis_flag, uint8_t nSimID);
+
+/**********************************************************
+** Function Name: fibo_stop_Data_Call_by_simid
+** Description:
+** È¥¼¤»îÖ¸¶¨profile PDPÁ¬½Ó£¬ZGACTºÍCGACT¾ùÏ·¢µÄÍâÖò¦ºÅ;
+** IN:
+** profile_id: ָʾȥ¼¤»îµÄcid;
+** rndis_flag: 0x00: ÄÚÖò¦ºÅ; 0x01:ÍâÖò¦ºÅ;
+***********************************************************/
+
+extern int32_t fibo_stop_Data_Call_by_simid(uint8_t profile_id, uint8_t rndis_flag, uint8_t nSimID);
+
+/**********************************************************
+** Function Name: fibo_get_Data_Addr_by_simid
+** Description:
+** »ñȡָ¶¨profileµÄµØÖ·ÐÅÏ¢;
+** IN:
+** profile_id: ָʾ»ñÈ¡ÄÄһ·cidÐÅÏ¢;
+** OUT:
+** addr_list: ÓÃÓÚ´æ´¢»ñÈ¡µÄµØÖ·ÐÅÏ¢
+***********************************************************/
+
+extern int32_t fibo_get_Data_Addr_by_simid(uint8_t profile_id, Data_call_addr_info_list_t *addr_list, uint8_t nSimID);
+
+/**********************************************************
+** Function Name: fibo_get_SIM_Status_by_simid
+** Description:
+** »ñȡָ¶¨SIM ״̬ÐÅÏ¢;
+** IN:
+** nSimID: value in range of [0,1];
+** OUT:
+** sim_status: ÓÃÓÚ´æ´¢»ñÈ¡µÄSIM״̬ÐÅÏ¢
+***********************************************************/
+
+extern int32_t fibo_get_SIM_Status_by_simid(E_SIM_STATUS *sim_status, uint8_t nSimID);
+
+
+/**********************************************************
+** Function Name: fibo_send_AT_by_simid
+** Description:
+** »ñȡָ¶¨SIM Ïà¹ØATÖ¸ÁîºÍ·µ»Ø½á¹û;
+** IN:
+** nSimID: value in range of [0,1];
+** req_at: ÓÃÓÚ´æ´¢·¢Ë͵ÄATÖ¸Áî;
+** info_fmt: ATÏìÓ¦µÄ¸ñʽ»¯·½Ê½;
+** pval: ¸ñʽ»¯ºóµÄATÏìÓ¦;
+** OUT:
+** return 0±íʾ·µ»ØOK³É¹¦£¬ÆäËûÖµ±íʾʧ°Ü´íÎóÂë;
+ʾÀý:
+int ret = 0;
+ret = get_modem_info("AT+CFUN=1\r", NULL, NULL);
+//·µ»Ø0¼´±íʾִÐгɹ¦
+
+char *pstr = malloc(50);
+memset(pstr,0,50);
+ret = get_modem_info("AT+CIMI\r", "%s", (void**)&pstr);
+//+CIMI: 111111111111111·µ»Øºópstr==111111111111111
+
+int n1 = 0;
+int n2 = 0;
+int n3 = 0;
+void *p2[] = {&n1,&n2,&n3};
+ret = get_modem_info("AT+CCIOTOPT?\r", "%d,%d,%d", (void**)p2);
+//+CCIOTOPT: 1,2,3½âÎöºón1==1 n2==2 n3==3
+***********************************************************/
+
+extern int32_t fibo_send_AT_by_simid(char *req_at, char *info_fmt, void **pval, uint8_t nSimID);
+
+
+#endif //#ifndef __GHT_VSIM_API_H__
diff --git a/ap/lib/libvsim/libvsim.c b/ap/lib/libvsim/libvsim.c
new file mode 100755
index 0000000..22067cd
--- /dev/null
+++ b/ap/lib/libvsim/libvsim.c
@@ -0,0 +1,722 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <asm/unistd.h>
+#include "softap_api.h"
+#include "zte_vsim_api.h"
+
+#define VSIM_MAX_MSG_LEN 1024
+#define vsim_debug_printf printf
+
+enum{
+ MSG_CMD_VSIM_GET_SWITCH = 1,//ATÔÚÄÄÒ»´ý·¢
+ MSG_CMD_VSIM_SET_SWITCH,
+ MSG_CMD_VSIM_GET_STANDBY,//¿Í»§ÉèÖôý»ú²à,¿ÉÄܲ»Êǵ±Ç°µ±Ç°´ý»ú²à,±ÈÈçTAU
+ MSG_CMD_VSIM_SET_STANDBY,
+ MSG_CMD_VSIM_GET_TAUING,//ÕýÔÚ×öTAU,ÓÃÓÚ¼øÈ¨Á÷³ÌÇлØÊµÌ忨ÅжÏ
+ MSG_CMD_VSIM_SET_TAUING,
+ MSG_CMD_VSIM_GET_AUTHING,//ÕýÔÚ×ö¼øÈ¨,´Ëʱ½ûÖ¹TAU
+ MSG_CMD_VSIM_SET_AUTHING,
+ MSG_CMD_VSIM_GET_CARD_STAT,//»ñÈ¡µ±Ç°µ×²ãʵ¼Ê´ý»ú²à
+ MSG_CMD_VSIM_APDU,
+ MSG_CMD_VSIM_GET_FLOW_STATISTIC,//»ñÈ¡µ±Ç°Á÷Á¿Í³¼Æ
+ MSG_CMD_VSIM_RESET_FLOW_STATISTIC,//ÖØÖõ±Ç°Á÷Á¿Í³¼Æ
+ MSG_CMD_VSIM_MAX,
+};
+
+typedef struct {
+ unsigned short usMsgCmd; /* ÏûÏ¢ÀàÐÍ */
+ unsigned short usDataLen; /* ÏûÏ¢³¤¶È£¬°üÀ¨Í·²¿ */
+ unsigned char aucDataBuf[VSIM_MAX_MSG_LEN]; /* ÏûÏ¢ÕýÎÄ */
+} VSIM_MSG_BUF;
+
+pthread_t read_thread_tid;
+pthread_t msg_thread_tid;
+int g_read_thread_state = -1;
+int g_msg_thread_state = -1;
+VSIM_COMMAND g_vsim_apdu_process_cb;
+zte_mdm_event_ind_callback g_vsim_event_ind_cb;
+
+int32_t zte_mdm_event_ind_cb(E_MODEM_EVENT_ID event_id, void *ind_data, uint32_t ind_data_len)
+{
+ return 0;
+}
+int zte_vsim_ind_cb(uint8_t *apdu_req, uint16_t apdu_req_len,uint8_t *apdu_rsp, uint16_t *apdu_rsp_len, uint8_t slot)
+{
+ char addr[64] = {0};
+ char cmd[128] = {0};
+
+ sc_cfg_get("vsim_debug_ip",addr,sizeof(addr));
+ if(strlen(addr)){
+ snprintf(cmd, sizeof(cmd), "ping %s -w 5", addr);
+ system(cmd);
+ }else
+ system("ping 192.168.30.110 -w 5");
+ return 0;
+}
+
+static int vsim_card_switch_req(unsigned char sim)
+{
+ int ret = 0;
+ if(sim)
+ ret = get_modem_info("AT+ZCARDSWITCHREQ=0,1\r\n", NULL, NULL);
+ else
+ ret = get_modem_info("AT+ZCARDSWITCHREQ=1,0\r\n", NULL, NULL);
+ if(ret != 0){
+ printf("##vsim## [%s] sim=%d ret=%d err\n", __FUNCTION__, sim, ret);
+ }
+ vsim_debug_printf("##vsim## [%s] sim=%d ret=%d\n", __FUNCTION__, sim, ret);
+ return ret;
+}
+
+static int vsim_set(unsigned short msg, unsigned char param)
+{
+ VSIM_MSG_BUF msg_in = {0};
+ VSIM_MSG_BUF msg_out = {0};
+ int ret = 0;
+
+ msg_in.usMsgCmd = msg;
+ msg_in.aucDataBuf[0] = param;
+ vsim_debug_printf("##vsim## [%s] msg=%d param=%d start\n", __FUNCTION__, msg, param);
+ ret = syscall(__NR_vsim_proc,(unsigned char *)&msg_in, (unsigned char *)&msg_out);
+ if(ret == 0){
+ printf("##vsim## [%s] msg=%d param=%d err\n", __FUNCTION__, msg, param);
+ }
+ return ret;
+}
+
+static unsigned char vsim_get(unsigned short msg)
+{
+ VSIM_MSG_BUF msg_in = {0};
+ VSIM_MSG_BUF msg_out = {0};
+ int ret = 0;
+
+ msg_in.usMsgCmd = msg;
+ vsim_debug_printf("##vsim## [%s] msg=%d start\n", __FUNCTION__, msg);
+ ret = syscall(__NR_vsim_proc,(unsigned char *)&msg_in, (unsigned char *)&msg_out);
+ if(ret == 0){
+ printf("##vsim## [%s] msg=%d err\n", __FUNCTION__, msg);
+ }
+ return msg_out.aucDataBuf[0];
+}
+
+static int vsim_get_cardstat_fromps(void)
+{
+ VSIM_MSG_BUF msg_in = {0};
+ VSIM_MSG_BUF msg_out = {0};
+ int ret = 0;
+
+ msg_in.usMsgCmd = MSG_CMD_VSIM_GET_CARD_STAT;
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ ret = syscall(__NR_vsim_proc,(unsigned char *)&msg_in, (unsigned char *)&msg_out);
+ if(ret == 0 || msg_out.aucDataBuf[0] == msg_out.aucDataBuf[1] || msg_out.aucDataBuf[2]){
+ printf("##vsim## [%s] err ret=%d sim1=%d sim2=%d busy=%d\n", __FUNCTION__, ret, msg_out.aucDataBuf[0], msg_out.aucDataBuf[1], msg_out.aucDataBuf[2]);
+ return -1;
+ }
+ if(msg_out.aucDataBuf[0])
+ return 0;
+ if(msg_out.aucDataBuf[1])
+ return 1;
+ return -1;
+}
+
+static void read_thread_entry(void *arg)
+{
+ prctl(PR_SET_NAME, "vsim_read", 0, 0, 0);
+ while(g_vsim_apdu_process_cb)
+ {
+ VSIM_MSG_BUF msg_in = {0};
+ VSIM_MSG_BUF msg_out = {0};
+ int ret = 0;
+ int is_auth = 0;
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ ret = syscall(__NR_vsim_read,(unsigned char *)&msg_out);
+ if(ret == 0){
+ printf("##vsim## read fail\n");
+ }
+ vsim_debug_printf("##vsim## read msg=%d\n", msg_out.usMsgCmd);
+ if(msg_out.usMsgCmd != MSG_CMD_VSIM_APDU || ret == 0){
+ printf("##vsim## read msg=%d ret=%d err\n", msg_out.usMsgCmd, ret);
+ }
+ is_auth = msg_out.aucDataBuf[1];
+ //ÇÐʵÌ忨
+ if(is_auth){
+ printf("##vsim## vsim_apdu_auth standby=%d\n", vsim_get(MSG_CMD_VSIM_GET_STANDBY));
+ vsim_set(MSG_CMD_VSIM_SET_AUTHING,1);
+ usleep(20000);//±£»¤´ëÊ©,ÑÓ³Ù20ºÁÃëÔÙÏ·¢Çп¨£¬±£Ö¤¼øÈ¨ÇëÇóµÄrlc ack»Ø¸´¸øÍø²à
+ vsim_card_switch_req(0);//´ËʱʵÌ忨¿ÉÄÜ´æÔÚÍøÂçÁ´½Ó£¬ÏÈÇÐÍøÔÙÇÐÊý¾Ý
+ vsim_set(MSG_CMD_VSIM_SET_STANDBY,0);
+ }
+ msg_in.usDataLen = sizeof(msg_in.aucDataBuf);
+ ret = g_vsim_apdu_process_cb(&msg_out.aucDataBuf[2], msg_out.usDataLen, msg_in.aucDataBuf,
+ &msg_in.usDataLen, msg_out.aucDataBuf[0]);
+ vsim_debug_printf("##vsim## g_vsim_apdu_process_cb ret=0x%x len=%d\n", ret, msg_in.usDataLen);
+ //ÇÐÐéÄ⿨
+ if(is_auth){
+ vsim_set(MSG_CMD_VSIM_SET_STANDBY,1);//´ËÊ±ÔÆ¿¨Ó¦¸Ãδ½¨ÍøÂçÁ´½Ó£¬ÏÈÇÐÊý¾ÝÔÙÇÐÍø
+ vsim_card_switch_req(1);
+ vsim_set(MSG_CMD_VSIM_SET_AUTHING,0);
+ }
+ //msg_in.usDataLen = ret;·µ»Ø²»Êdz¤¶ÈÊÇ״̬×Ö
+ msg_in.usMsgCmd = MSG_CMD_VSIM_APDU;
+ ret = syscall(__NR_vsim_write,(unsigned char *)&msg_in);
+ if(ret == 0){
+ printf("##vsim## write fail\n");
+ }
+ }
+ printf("##vsim## read_thread quit\n");
+ g_read_thread_state = -1;
+ pthread_exit(0);
+}
+
+static void msg_thread_entry(void *arg)
+{
+ int iMsgHandle = msgget(MODULE_ID_VSIM, IPC_CREAT|0600);
+ LONG msgSize = sizeof(MSG_BUF)-sizeof(LONG);
+ unsigned char SwitchStat;
+
+ prctl(PR_SET_NAME, "vsim_msg", 0, 0, 0);
+ while(g_vsim_event_ind_cb)
+ {
+ MSG_BUF stMsg = {0};
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ if (msgrcv(iMsgHandle, &stMsg, msgSize, 0, 0) >= 0)
+ {
+ switch (stMsg.usMsgCmd)
+ {
+ case MSG_CMD_ZCARDSWITCHIND_IND:
+ //callback todo
+ SwitchStat = stMsg.aucDataBuf[1];
+ if(vsim_get(MSG_CMD_VSIM_GET_AUTHING)){
+ printf("##vsim## ZCARDSWITCHIND AUTHING abort\n");
+ if(SwitchStat)
+ vsim_set(MSG_CMD_VSIM_SET_TAUING,0);
+ break;
+ }
+ if(SwitchStat == 0){
+ vsim_set(MSG_CMD_VSIM_SET_TAUING,1);
+ vsim_card_switch_req(stMsg.aucDataBuf[0]);
+ }else{
+ if(vsim_get(MSG_CMD_VSIM_GET_STANDBY) == stMsg.aucDataBuf[0])
+ vsim_card_switch_req(stMsg.aucDataBuf[0]);
+ vsim_set(MSG_CMD_VSIM_SET_TAUING,0);
+ }
+ break;
+ case MSG_CMD_CREG_IND:
+ if(vsim_get(MSG_CMD_VSIM_GET_STANDBY) == 1){
+ //callback todo
+ }
+ break;
+ case MSG_CMD_VSIMDEBUG_IND:
+ if(stMsg.aucDataBuf[0] == 1){
+ char imei[]="862769025435956";
+ fibo_set_IMEI_by_simid(imei,sizeof(imei),1);
+ fibo_mdm_event_regist(zte_mdm_event_ind_cb);
+ fibo_vsim_init(zte_vsim_ind_cb,1);
+ }
+ if(stMsg.aucDataBuf[0] == 2){
+ fibo_vsim_close(zte_vsim_ind_cb,1);
+ }
+ if(stMsg.aucDataBuf[0] == 10){
+ zte_SetGTDATASIM(0);
+ }
+ if(stMsg.aucDataBuf[0] == 11){
+ zte_SetGTDATASIM(1);
+ }
+ if(stMsg.aucDataBuf[0] == 20){
+ zte_SetGTDUALSIM(0);
+ }
+ if(stMsg.aucDataBuf[0] == 21){
+ zte_SetGTDUALSIM(1);
+ }
+ break;
+ default:
+ printf("##vsim## rcv_msg err msgid 0x%x\n",stMsg.usMsgCmd);
+ break;
+ }
+ }
+ vsim_debug_printf("##vsim## rcv_msg msgid 0x%x param=%d end\n",stMsg.usMsgCmd, stMsg.aucDataBuf[0]);
+ }
+ printf("##vsim## msg_thread quit\n");
+ g_msg_thread_state = -1;
+ pthread_exit(0);
+}
+
+int32_t zte_atVsimInit(VSIM_COMMAND vsim_apdu_process_fn, uint8_t nSimID)
+{
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ if(vsim_apdu_process_fn == NULL || nSimID != 1){
+ printf("##vsim## init param err fn=0x%x sim=%d\n", vsim_apdu_process_fn, nSimID);
+ return -1;
+ }
+ g_vsim_apdu_process_cb = vsim_apdu_process_fn;
+ if(g_read_thread_state != 0)
+ g_read_thread_state = pthread_create(&read_thread_tid, NULL, (void *)read_thread_entry, NULL);
+ if(g_msg_thread_state != 0)
+ g_msg_thread_state = pthread_create(&msg_thread_tid, NULL, (void *)msg_thread_entry, NULL);
+ if(g_read_thread_state != 0 || g_msg_thread_state != 0){
+ printf("##vsim## init fail read=%d msg=%d\n", g_read_thread_state, g_msg_thread_state);
+ return -1;
+ }
+ vsim_set(MSG_CMD_VSIM_SET_STANDBY,1);//´ËÊ±ÔÆ¿¨Î´½¨ÍøÂçÁ´½Ó£¬ÏÈÇÐÊý¾ÝÔÙÇÐÍø
+ vsim_card_switch_req(1);
+ vsim_set(MSG_CMD_VSIM_SET_SWITCH,1);
+ get_modem_info("AT+CFUN=1\r\n", NULL, NULL);
+ return 0;
+}
+
+int32_t zte_atVsimClose(VSIM_COMMAND vsim_apdu_process_fn, uint8_t nSimID)
+{
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ zte_SetGTDATASIM(1);
+ get_modem_info("AT+CFUN=0\r\n", NULL, NULL);
+ vsim_card_switch_req(0);
+ zte_SetGTDUALSIM(0);
+ return 0;
+}
+
+int32_t zte_SetGTDATASIM(uint8_t nSimID)
+{
+ int ret = 0;
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ if(vsim_get(MSG_CMD_VSIM_GET_AUTHING)){
+ printf("##vsim## [%s]->%d fail AUTHING\n", __FUNCTION__, nSimID);
+ return -1;
+ }
+ vsim_set(MSG_CMD_VSIM_SET_STANDBY,nSimID);
+ ret = vsim_get_cardstat_fromps();
+ if(ret >= 0){
+ if(nSimID != ret){
+ //Èç¹ûÉèÖú͵±Ç°µ×²ã´ý»ú²à²»Ò»Ö²ÅÇÐ,forTAUING
+ vsim_card_switch_req(nSimID);
+ }
+ }else
+ vsim_card_switch_req(nSimID);
+ vsim_set(MSG_CMD_VSIM_SET_SWITCH, nSimID);
+ printf("##vsim## [%s] cardstat=%d sim=%d\n", __FUNCTION__, ret, nSimID);
+ return 0;
+}
+
+int32_t zte_GetGTDATASIM(uint8_t *nSimID)
+{
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ *nSimID = vsim_get(MSG_CMD_VSIM_GET_STANDBY);
+ return 0;
+}
+
+int32_t zte_SetGTDUALSIM(uint8_t nSimID)
+{
+ int ret = 0;
+ unsigned char standby = vsim_get(MSG_CMD_VSIM_GET_STANDBY);
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ ret = vsim_set(MSG_CMD_VSIM_SET_SWITCH,nSimID);
+ if(ret == 0){
+ printf("##vsim## [%s] err sim=%d\n", __FUNCTION__, nSimID);
+ return -1;
+ }
+ //ATÒѾÇкã¬ÏÂÃæÊÇÅжÏÊÇ·ñÒªÇп¨
+ if(vsim_get(MSG_CMD_VSIM_GET_TAUING)){//TAUµÄ¹ý³ÌÖÐ,²»Çп¨
+ printf("##vsim## [%s] TAUING\n", __FUNCTION__);
+ return 0;
+ }
+ ret = vsim_get_cardstat_fromps();
+ if(ret >= 0 && standby != ret && standby == nSimID){
+ //µ±Çл»ATµÄÄ¿±ê´ý»ú²àºÍÉϲã֮ǰÉ趨µÄ´ý»ú²àÏàͬ,ÇҺ͵ײãʵ¼ÊµÄ´ý»ú²à²»Í¬,ÓÖ²»ÊÇTAUµÄ¹ý³ÌÖÐ,¾Í´¥·¢Çп¨
+ vsim_card_switch_req(nSimID);
+ }
+ printf("##vsim## [%s] cardstat=%d standby=%d sim=%d\n", __FUNCTION__, ret, standby, nSimID);
+ return 0;
+}
+
+int32_t zte_GetGTDUALSIM(uint8_t *nSimID)
+{
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ *nSimID = vsim_get(MSG_CMD_VSIM_GET_SWITCH);
+ return 0;
+}
+
+int32_t zte_mdm_event_regist(zte_mdm_event_ind_callback ind_cb)
+{
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ g_vsim_event_ind_cb = ind_cb;
+ return 0;
+}
+
+void zte_vsim_debug(void)
+{
+ g_vsim_event_ind_cb = zte_mdm_event_ind_cb;
+ g_vsim_apdu_process_cb = zte_vsim_ind_cb;
+ if(g_read_thread_state != 0)
+ g_read_thread_state = pthread_create(&read_thread_tid, NULL, (void *)read_thread_entry, NULL);
+ if(g_msg_thread_state != 0)
+ g_msg_thread_state = pthread_create(&msg_thread_tid, NULL, (void *)msg_thread_entry, NULL);
+ if(g_read_thread_state != 0 || g_msg_thread_state != 0){
+ printf("##vsim## debug fail read=%d msg=%d\n", g_read_thread_state, g_msg_thread_state);
+ }
+}
+
+int32_t zte_atVsimReset(void)
+{
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ return restart_request(MODULE_ID_VSIM);
+}
+
+int32_t zte_SetCfunMode(uint8_t mode)
+{
+ char at_cmd[64] = {0};
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ snprintf(at_cmd,sizeof(at_cmd),"AT+CFUN=%d\r\n", mode);
+ return get_modem_info(at_cmd, NULL, NULL);
+}
+
+int32_t zte_GetCfunMode(uint8_t *mode)
+{
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ if(mode)
+ return get_modem_info("AT+CFUN?\r\n", "%1d", (void**)&mode);
+ return -1;
+}
+
+int32_t zte_SetIMEIbySimId(uint8_t *imei, uint8_t imei_len, uint8_t nSimID)
+{
+ int ret = -1;
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ if(imei){
+ char at_cmd[64] = {0};
+ uint8_t sim = 0;
+ zte_GetGTDUALSIM(&sim);
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(nSimID);
+ snprintf(at_cmd,sizeof(at_cmd),"AT+CGSN=%s\r\n",imei);
+ ret = get_modem_info(at_cmd, NULL, NULL);
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(sim);
+ }
+ return ret;
+}
+
+int32_t zte_GetIMEIbySimId(uint8_t *imei, uint8_t imei_len, uint8_t nSimID)
+{
+ int ret = -1;
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ if(imei){
+ uint8_t sim = 0;
+ zte_GetGTDUALSIM(&sim);
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(nSimID);
+ ret = get_modem_info("AT+CGSN\r\n", "%s", (void**)&imei);
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(sim);
+ }
+ return ret;
+}
+
+
+int32_t zte_GetCCIDbySimId(uint8_t *ccid, uint8_t ccid_len, uint8_t nSimID)
+{
+ int ret = -1;
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ if(ccid){
+ uint8_t sim = 0;
+ zte_GetGTDUALSIM(&sim);
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(nSimID);
+ ret = get_modem_info("AT+ZICCID?\r\n", "%s", (void**)&ccid);
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(sim);
+ }
+ return ret;
+}
+
+int32_t zte_GetMCCMNCbySimId(char *mcc, char *mnc, uint8_t nSimID)
+{
+ int ret = -1;
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ if(mcc && mnc){
+#if 0
+ int sw1=0;
+ int sw2=-1;
+ char response[513] = {0};//³¤¶È·¶Î§0-256×Ö½Ú£¬7F205F70±íʾ4¸ö×Ö½Ú³¤¶È
+ void *p[] = {&sw1,&sw2,response};
+ uint8_t sim = 0;
+ zte_GetGTDUALSIM(&sim);
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(nSimID);
+ get_modem_info("AT+CRSM=176,28589,0,0,4\r\n", "%d,%d,%s", (void**)p);
+ if(sw1 == 144 && sw2 == 0){
+ char imsi[64] = {0};
+ char strPlmnLast[10] = {0};
+ void *p1[] = {imsi};
+
+ get_modem_info("AT+CIMI\r\n", "%s", (void**)p1);
+ strncpy(strPlmnLast, &response[strlen(response)-2], 2);
+ memset(mcc, 0, 4);
+ memset(mnc, 0, 4);
+ memcpy(mcc, imsi, 3);
+ if(0 == strcmp("03", strPlmnLast))
+ memcpy(mnc, imsi+3, 3);
+ else
+ memcpy(mnc, imsi+3, 2);
+ }
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(sim);
+ return !(sw1 == 144 && sw2 == 0);
+#else
+ int i1,i2,i3,i4,i5;
+ char plmn[8] = {0};
+ void *p[] = {&i1,&i2,&i3,&i4,&i5,plmn};
+ uint8_t sim = 0;
+ zte_GetGTDUALSIM(&sim);
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(nSimID);
+ ret = get_modem_info("AT+ZEMSCIQ=1\r\n", "%d,%d,%d,%d,%d,%s", (void**)p);
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(sim);
+ memset(mcc, 0, 4);
+ memset(mnc, 0, 4);
+ memcpy(mcc, plmn, 3);
+ memcpy(mnc, plmn+3, 3);
+#endif
+ }
+ return ret;
+}
+
+int32_t zte_SwitchSimHandle(uint8_t mode)
+{
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ return 0;
+}
+
+int32_t zte_GetCSQbySimId(int32_t *rssi, int32_t *ber, uint8_t nSimID)
+{
+ int ret = -1;
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ if(rssi && ber){
+ void *p[] = {rssi,ber};
+ uint8_t sim = 0;
+ zte_GetGTDUALSIM(&sim);
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(nSimID);
+ ret = get_modem_info("AT+CSQ\r\n", "%d,%d", (void**)p);
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(sim);
+ }
+ return ret;
+}
+
+int32_t zte_GetRegInfobySimid(RegInfo_t *reg_info, uint8_t nSimID)
+{
+ int ret = -1;
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ if(reg_info){
+ int i,act,rac;
+ void *p[] = {&i,&act,®_info->lte_scell_info.cell_id,&rac,®_info->lte_scell_info.tac};
+ void *p1[] = {®_info->nStatus};
+ uint8_t sim = 0;
+ zte_GetGTDUALSIM(&sim);
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(nSimID);
+ reg_info->nStatus = 0;
+ get_modem_info("AT^SYSINFO\r\n", "%d", (void**)p1);
+ ret = get_modem_info("AT+ZEMSCIQ=1\r\n", "%d,%d,%d,%d,%d", (void**)p);
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(sim);
+ if(ret || reg_info->nStatus != 2)
+ return -1;
+ if(act == 16){
+ reg_info->curr_rat = E_NW_RADIO_IF_LTE;
+ } else {
+ if(act == 1)
+ reg_info->curr_rat = E_NW_RADIO_IF_TDSCDMA;
+ else if(act == 2)
+ reg_info->curr_rat = E_NW_RADIO_IF_WCDMA;
+ else if(act == 4)
+ reg_info->curr_rat = E_NW_RADIO_IF_GSM;
+ else
+ printf("##vsim## [%s] act=%d ???\n", __FUNCTION__, act);
+ }
+ }
+ return ret;
+}
+
+int32_t zte_GetCellInfobySimId(CellInfo_t *pcellinfo, uint8_t nSimID)
+{
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ return 0;
+}
+
+int32_t zte_GetNetInfobySimId(NetInfo_t *pNetInfo, uint8_t nSimID)
+{
+ VSIM_MSG_BUF msg_in = {0};
+ VSIM_MSG_BUF msg_out = {0};
+ int ret = -1;
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ if(pNetInfo && nSimID < 2){
+ msg_in.usMsgCmd = MSG_CMD_VSIM_GET_FLOW_STATISTIC;
+ msg_in.aucDataBuf[0] = nSimID;
+ ret = syscall(__NR_vsim_proc,(unsigned char *)&msg_in, (unsigned char *)&msg_out);
+ if(ret == 0){
+ printf("##vsim## [%s] vsim_proc err\n", __FUNCTION__);
+ }
+ if(sizeof(NetInfo_t) > msg_out.usDataLen)
+ memcpy(pNetInfo, msg_out.aucDataBuf, msg_out.usDataLen);
+ else
+ memcpy(pNetInfo, msg_out.aucDataBuf, sizeof(NetInfo_t));
+ }
+ return ret;
+}
+
+int32_t zte_SetAPNbySimID(Data_call_config_info_t *data_call, uint8_t nSimID)
+{
+ return 0;
+}
+
+int32_t zte_StartDataCallbySimId(Data_call_config_info_t *data_call, uint8_t nSimID)
+{
+ int ret = -1;
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ if(data_call){
+ uint8_t sim = 0;
+ char at_cmd[128] = {0};
+ void *p[] = {&data_call->profile_id};
+ char reservecid[30] = {0};
+ unsigned char cid_reserved = 0;
+ unsigned char cid_reserved_vsim = 0;
+
+ zte_GetGTDATASIM(&sim);
+ if(sim != nSimID){
+ printf("##vsim## [%s] nSimID=%d standby=%d err\n", __FUNCTION__, nSimID, sim);
+ return ret;
+ }
+ if(nSimID){
+ sc_cfg_get("cid_reserved",reservecid,sizeof(reservecid));
+ if(strlen(reservecid))
+ cid_reserved = atoi(reservecid);
+ cid_reserved_vsim = cid_reserved|15;
+ snprintf(at_cmd,sizeof(at_cmd),"AT+CIDRESERVED=%d\r\n", cid_reserved_vsim);
+ get_modem_info(at_cmd, NULL, NULL);
+ }
+ if(data_call->ip_family == E_DATA_IP_FAMILY_IPV4)
+ snprintf(at_cmd,sizeof(at_cmd),"AT+ZPDPACT=0,\"IP\",\"%s\",,,,%d,\"%s\",\"%s\"\r\n", data_call->apn_name, data_call->auth_pref, data_call->user_name, data_call->password);
+ else if(data_call->ip_family == E_DATA_IP_FAMILY_IPV6)
+ snprintf(at_cmd,sizeof(at_cmd),"AT+ZPDPACT=0,\"IPV6\",\"%s\",,,,%d,\"%s\",\"%s\"\r\n", data_call->apn_name, data_call->auth_pref, data_call->user_name, data_call->password);
+ else if(data_call->ip_family == E_DATA_IP_FAMILY_IPV4V6)
+ snprintf(at_cmd,sizeof(at_cmd),"AT+ZPDPACT=0,\"IPV4V6\",\"%s\",,,,%d,\"%s\",\"%s\"\r\n", data_call->apn_name, data_call->auth_pref, data_call->user_name, data_call->password);
+ else {
+ printf("##vsim## [%s] ip_family=%d ???\n", __FUNCTION__, data_call->ip_family);
+ snprintf(at_cmd,sizeof(at_cmd),"AT+ZPDPACT=0,\"IP\",\"%s\",,,,%d,\"%s\",\"%s\"\r\n", data_call->apn_name, data_call->auth_pref, data_call->user_name, data_call->password);
+ }
+ zte_GetGTDUALSIM(&sim);
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(nSimID);
+ ret = get_modem_info(at_cmd, "%d", (void**)p);
+ vsim_debug_printf("##vsim## [%s] ret=%d cid=%d\n", __FUNCTION__, ret, data_call->profile_id);
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(sim);
+ if(nSimID){
+ snprintf(at_cmd,sizeof(at_cmd),"AT+CIDRESERVED=%d\r\n", cid_reserved);
+ get_modem_info(at_cmd, NULL, NULL);
+ }
+ }
+ return ret;
+}
+
+int32_t zte_StopDataCallbySimId(uint8_t profile_id, uint8_t nSimID)
+{
+ int ret = -1;
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ if(profile_id > 0 && profile_id < 9){
+ uint8_t sim = 0;
+ char at_cmd[64] = {0};
+
+ snprintf(at_cmd,sizeof(at_cmd),"AT+ZPDPDEACT=%d\r\n", profile_id);
+ zte_GetGTDUALSIM(&sim);
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(nSimID);
+ ret = get_modem_info(at_cmd, NULL, NULL);
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(sim);
+ }
+ return ret;
+}
+
+int32_t zte_GetDataAddrbySimID(uint8_t profile_id, Data_call_addr_info_list_t *addr_list, uint8_t nSimID)
+{
+ int ret = -1;
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ if(profile_id > 0 && profile_id < 9 && addr_list){
+ uint8_t sim = 0;
+ char at_cmd[64] = {0};
+ int cid = 0;
+ void *p[] = {&cid, addr_list};
+
+ snprintf(at_cmd,sizeof(at_cmd),"AT+CGPADDR=%d\r\n", profile_id);
+ zte_GetGTDUALSIM(&sim);
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(nSimID);
+ ret = get_modem_info(at_cmd, "%d,%17s", (void**)p);
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(sim);
+ }
+ return ret;
+}
+
+int32_t zte_GetSimStatusbySimId(E_SIM_STATUS *sim_status, uint8_t nSimID)
+{
+ int ret = -1;
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ if(sim_status){
+ uint8_t sim = 0;
+ char at_paras[64] = {0};
+ void *p[] = {at_paras};
+ zte_GetGTDUALSIM(&sim);
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(nSimID);
+ ret = get_modem_info("AT+CPIN?\r\n", "%s", (void**)p);
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(sim);
+ if(ret == 0){
+ if (strncmp("READY", at_paras, strlen("READY")) == 0)
+ {
+ *sim_status = E_SIM_STAT_READY;
+ }
+ /*Èç¹ûµ±Ç°ÃÜÂëÊäÈëÇëÇóΪPIN»òPIN2£¬ÔòÊäÈë+CPIN=<pin>½øÐÐУÑé*/
+ else if(strncmp("SIM PIN",at_paras, strlen("SIM PIN")) == 0)
+ {
+ *sim_status = E_SIM_STAT_PIN;
+ }
+ /*Èç¹ûµ±Ç°ÃÜÂëÊäÈëÇëÇóΪPUK»òPUK2£¬ÔòÊäÈë+CPIN=<pin>,<newpin>½øÐнâËø*/
+ else if(strncmp("SIM PUK",at_paras, strlen("SIM PUK")) == 0)
+ {
+ *sim_status = E_SIM_STAT_PUK;
+ }
+ } else if(ret == 10){
+ *sim_status = E_SIM_STAT_NOT_INSERTED;
+ } else if(ret == 14){
+ *sim_status = E_SIM_STAT_BUSY;
+ } else {
+ *sim_status = E_SIM_STAT_UNKNOWN;
+ }
+ return 0;
+ }
+ return -1;
+}
+
+int32_t zte_SendATbySimId(char *req_at, char *info_fmt, void **pval, uint8_t nSimID)
+{
+ int ret = -1;
+ uint8_t sim = 0;
+ vsim_debug_printf("##vsim## [%s] start\n", __FUNCTION__);
+ zte_GetGTDUALSIM(&sim);
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(nSimID);
+ printf("##vsim## [%s] nSimID=%d sw=%d at=%s\n", __FUNCTION__, nSimID, sim, req_at);
+ ret = get_modem_info(req_at, info_fmt, pval);
+ if(sim != nSimID)
+ zte_SetGTDUALSIM(sim);
+ return ret;
+}
+
+
diff --git a/ap/lib/libvsim/zte_vsim_api.h b/ap/lib/libvsim/zte_vsim_api.h
new file mode 100755
index 0000000..1552449
--- /dev/null
+++ b/ap/lib/libvsim/zte_vsim_api.h
@@ -0,0 +1,316 @@
+#ifndef __ZTE_VSIM_API_H_
+#define __ZTE_VSIM_API_H_
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <sys/socket.h>
+//********2023-01-13***********//
+
+#define SIM_IMSI_LEN_MAX 16 /** Maximum length of IMSI data. */
+#define SIM_ICCID_LEN_MAX 21 /** Maximum length of ICCID data. */
+#define DATA_MAX_APN_LEN 57 /** Maximum length of the APN. */
+#define DATA_MAX_USERNAME_LEN 127 /** Maximum length of the profile user name. */
+#define DATA_MAX_PASSWORD_LEN 127 /** Maximum length of the profile password. */
+#define DATA_INTERFACE_NAME_LEN 16 /** Interface name length. */
+#define DATA_MAX_ADDR_COUNT 2 /** Maximum number of IP addresses. */
+
+//**************GHT VSIM Struct*********************//
+
+typedef enum {
+ E_SIM_TYPE_USIM, //ʵÌ忨
+ E_SIM_TYPE_VSIM, //ÔÆ¿¨
+ E_SIM_TYPE_SSIM, //Soft SIM
+}SimTypeInSlot_t;
+
+
+typedef enum {
+ E_NW_RADIO_IF_NO_SRV = 0,
+ E_NW_RADIO_IF_GSM = 1,
+ E_NW_RADIO_IF_WCDMA = 2,
+ E_NW_RADIO_IF_LTE = 3,
+ E_NW_RADIO_IF_TDSCDMA = 4,
+ E_NW_RADIO_IF_CDMA = 5,
+ E_NW_RADIO_IF_CDMA2000 = 6,
+}e_nw_rat_type_t; //RAT value
+
+
+typedef enum {
+ E_NW_STATUS_SRV_NONE = 0,
+ E_NW_STATUS_CURRENT_SERVING = 1,
+ E_NW_STATUS_SRV_LIMITED = 2,
+ E_NW_STATUS_SRV_AVAILABLE = 3,
+ E_NW_STATUS_SRV_FORBIDDEN = 4,
+}e_nw_srv_status_t;
+
+
+typedef struct
+{
+ uint32_t tac;
+ uint32_t cell_id;
+}lte_scell_info_t;
+
+typedef struct
+{
+ uint32_t lac;
+ uint32_t cell_id;
+}gsm_w_scell_info_t;
+
+
+
+typedef struct
+{
+ e_nw_rat_type_t curr_rat;
+ e_nw_srv_status_t nStatus;
+ lte_scell_info_t lte_scell_info; //¸³Öµ¿ÉÑ¡£¬Óû§¸ù¾ÝratÖ¸Ê¾ÍøÂçÀàÐÍȡֵ
+ gsm_w_scell_info_t gsm_w_scell_info; //¸³Öµ¿ÉÑ¡£¬Óû§¸ù¾ÝratÖ¸Ê¾ÍøÂçÀàÐÍȡֵ
+}RegInfo_t;
+
+typedef struct{
+ uint16_t mcc;
+ uint16_t mnc;
+ uint32_t tac;
+ uint32_t cell_id;
+ uint16_t bandwidth;
+ int16_t rxlev;
+ uint32_t arfcn;
+ uint16_t pcid;
+}base_cell_info_t;//Hex format
+
+
+typedef struct
+{
+ uint8_t roamingFlag; ///< 1:roaming,0:non roaming
+ int16_t rsrp;
+ int16_t rsrq;
+ uint16_t SINR;
+ uint16_t netMode; //0--tdd 1--fdd
+ uint16_t band;
+ base_cell_info_t base_Scell_info;
+} lte_Scell_t;
+
+typedef struct
+{
+ int16_t rsrp;
+ int16_t rsrq;
+ uint16_t netMode; //0--tdd 1--fdd
+ base_cell_info_t base_Ncell_info;
+}lte_Ncell_t;
+
+typedef struct
+{
+ uint16_t bsic; //only in GSM
+ uint16_t band;
+ uint16_t rscp; //only in W
+ base_cell_info_t base_Ncell_info;
+}gsm_W_Scell_t;
+
+
+typedef struct
+{
+ uint16_t bsic; //only GSM
+ uint16_t band;
+ uint16_t rscp; //only in W
+ base_cell_info_t base_Ncell_info;
+}gsm_W_Ncell_t;
+
+typedef struct
+{
+ lte_Scell_t lteScell;
+ uint16_t lteNcellNum;
+ lte_Ncell_t lteNcell[6];
+}lte_cellinfo_t;
+
+typedef struct{
+ gsm_W_Scell_t scell_info;
+ uint16_t gsm_W_NcellNum;
+ gsm_W_Ncell_t gsm_W_ncell[6];
+}gsm_W_cellifo_t;
+
+typedef struct{
+ e_nw_rat_type_t curr_rat;
+ e_nw_srv_status_t service_status; //0x00: in service; 0x01: not in
+ lte_cellinfo_t lte_cellinfo;
+ gsm_W_cellifo_t gsm_cellinfo;
+}CellInfo_t;
+
+
+typedef struct{
+ uint32_t lwip_ul;
+ uint32_t lwip_dl;
+ uint32_t ppp_ul;
+ uint32_t ppp_dl;
+ uint32_t rndis_ul;
+ uint32_t rndis_dl;
+}NetInfo_t; /**< µ¥Î»: bit*/
+
+typedef enum
+{
+ E_DATA_IP_FAMILY_UNKNOWN = 0x00, /**< unknown */
+ E_DATA_IP_FAMILY_IPV4 = 0x04, /**< IPv4 */
+ E_DATA_IP_FAMILY_IPV6 = 0x06, /**< IPv6 */
+ E_DATA_IP_FAMILY_IPV4V6 = 0x0A /**< IPv4|IPv6 */
+}e_data_ip_family_t;
+
+typedef enum
+{
+ E_DATA_TECH_PREF_UNKNOWN = 0x00, /**< unknown */
+ E_DATA_TECH_PREF_UMTS = 0x01, /**< UMTS */
+ E_DATA_TECH_PREF_CDMA = 0x02, /**< CDMA */
+ E_DATA_TECH_PREF_LTE = 0x03, /**< LTE */
+ E_DATA_TECH_PREF_AUTO = 0x04 /**< AUTO */
+}e_data_tech_pref_t;
+
+typedef enum
+{
+ E_AUTH_PREF_PAP_CHAP_NOT_ALLOWED = 0x00,
+ E_AUTH_PREF_PAP_ONLY_ALLOWED = 0x01,
+ E_AUTH_PREF_CHAP_ONLY_ALLOWED = 0x02,
+ E_AUTH_PREF_PAP_CHAP_BOTH_ALLOWED = 0x03
+}e_data_auth_pref_t;
+
+
+typedef struct
+{
+ uint8_t profile_valid; /**< Must be set to TRUE if umts_profile is being passed. */
+ uint8_t profile_id; /**< profile ID. as well as called cid*/
+ uint8_t ip_family_valid; /**< Must be set to TRUE if ip_family is being passed. */
+ e_data_ip_family_t ip_family; /**< Data IP Family */
+ uint8_t apn_name_valid; /**< Must be set to TRUE if apn_name is being passed. */
+ char apn_name[DATA_MAX_APN_LEN+1]; /**< Data APN Name. A character string that identifies a PDN*/
+ uint8_t user_name_valid; /**< Must be set to TRUE if user_name is being passed. */
+ char user_name[DATA_MAX_USERNAME_LEN+1]; /**< Username for the APN. */
+ uint8_t password_valid; /**< Must be set to TRUE if password is being passed. */
+ char password[DATA_MAX_PASSWORD_LEN+1]; /**< Password for the APN. */
+ uint8_t auth_pref_valid; /**< Must be set to TRUE if tech_pref is being passed. */
+ e_data_auth_pref_t auth_pref; /**< Data auth Preference */
+ uint8_t tech_pref_valid; /**< Must be set to TRUE if tech_pref is being passed. */
+ e_data_tech_pref_t tech_pref; /**< Data Tech Preference */
+}Data_call_config_info_t;
+
+
+typedef struct
+{
+ char addr_valid; /**< Indicates whether a valid address is available. */
+ struct sockaddr_storage addr; /**< Stores the IP address. defined in kernel socket.h*/
+}data_call_addr_t;
+
+typedef struct
+{
+ data_call_addr_t iface_addr_s; /**< Network interface address. */
+ uint32_t iface_mask; /**< Subnet mask. */
+ data_call_addr_t gtwy_addr_s; /**< Gateway server address. */
+ uint32_t gtwy_mask; /**< Gateway mask. */
+ data_call_addr_t dnsp_addr_s; /**< Primary DNS server address. */
+ data_call_addr_t dnss_addr_s; /**< Secondary DNS server address. */
+}data_call_addr_info_t;
+
+typedef struct
+{
+ char iface_name[DATA_INTERFACE_NAME_LEN + 1]; /**< Network interface name. */
+ uint8_t addr_info_len; /**< Must be set to the number of elements in addr_info. */
+ data_call_addr_info_t addr_info[DATA_MAX_ADDR_COUNT]; /**< Data device address list. */
+}Data_call_addr_info_list_t;
+
+typedef enum{
+ E_RF_RESOURCE_CALLBACK_EVENT = 0x00, /**< É䯵×ÊÔ´Çл». */
+ E_NW_ATTACH_COMMPLETE_EVENT = 0x32, /**< ×¢ÍøÍê³É. */
+ E_DATA_PDN_ACT_SUCC_EVENT = 0x64, /**< PDN¼¤»îÍê³É ,ind_dataÖÐЯ´øZGIPDNS:µØÖ·ÐÅÏ¢ */
+}E_MODEM_EVENT_ID;
+
+typedef enum
+{
+ E_SIM_STAT_NOT_INSERTED = 0x00,
+ E_SIM_STAT_READY = 0x01,
+ E_SIM_STAT_PIN = 0x02,
+ E_SIM_STAT_PUK = 0x03,
+ E_SIM_STAT_BUSY = 0x04,
+ E_SIM_STAT_UNKNOWN = 0x05,
+}E_SIM_STATUS;
+
+
+/*********************************************************************
+** Ãû³Æ£º VSIM_COMMAND
+** ÃèÊö£º ModemºÍVSIMµÄAPDUͨÐŽӿں¯ÊýµÄ½á¹¹¶¨Ò壻
+** ¸ÃÀàÐͶ¨ÒåµÄº¯ÊýÐèҪͨ¹ýzte_atVsimInit½Ó¿ÚÍê³É×¢²á
+**
+*********************************************************************/
+
+typedef int (*VSIM_COMMAND)(uint8_t *apdu_req, uint16_t apdu_req_len,uint8_t *apdu_rsp, uint16_t *apdu_rsp_len, uint8_t slot);
+
+/*********************************************************************
+** Ãû³Æ£º zte_mdm_event_ind_callback
+** ÃèÊö£º ÏûϢʼþ֪ͨº¯ÊýµÄ½á¹¹¶¨Òå
+** ind_dataÖÐÆ½Ì¨×Ô¶¨ÒåÌí¼ÓÃèÊö
+** ±ÈÈçRF×ÊÔ´»ØÊÕÔÒò£º1. For SIM1 TAU; 2. For SIM1 Regist Network;3. NULL;
+**
+*********************************************************************/
+
+typedef int32_t (*zte_mdm_event_ind_callback)(E_MODEM_EVENT_ID event_id, void *ind_data, uint32_t ind_data_len);
+
+/*********************************************************************
+** Ãû³Æ£º zte_mdm_event_regist
+** ÃèÊö£º
+** ÏûϢʼþ֪ͨº¯Êý×¢²áÈë¿Ú£¬Ìṩ¸ø¿Í»§×¢²áÏûÏ¢º¯Êý;
+** modem²à²úÉúʼþ£¬»áµ÷ÓÃind_cb֪ͨ¿Í»§£»
+*********************************************************************/
+extern int32_t zte_mdm_event_regist(zte_mdm_event_ind_callback ind_cb);
+
+
+/*********************ZTE VSIM API***************************/
+
+extern int32_t zte_atVsimInit(VSIM_COMMAND vsim_apdu_process_fn, uint8_t nSimID);
+
+extern int32_t zte_atVsimClose(VSIM_COMMAND vsim_apdu_process_fn, uint8_t nSimID);
+
+extern int32_t zte_atVsimReset(void);
+
+//extern int16_t zte_SetSimWorkMode(SimTypeInSlot_t SimType, uint8_t nSoltID);
+
+//extern int16_t zte_GetSimWorkMode(SimTypeInSlot_t *SimType, uint8_t nSoltID);
+
+extern int32_t zte_SetGTDUALSIM(uint8_t nSimID);
+
+extern int32_t zte_GetGTDUALSIM(uint8_t *nSimID);
+
+extern int32_t zte_SetGTDATASIM(uint8_t nSimID);
+
+extern int32_t zte_GetGTDATASIM(uint8_t *nSimID);
+
+extern int32_t zte_SetCfunMode(uint8_t mode);
+
+extern int32_t zte_GetCfunMode(uint8_t *mode);
+
+extern int32_t zte_SetIMEIbySimId(uint8_t *imei, uint8_t imei_len, uint8_t nSimID);
+
+extern int32_t zte_GetIMEIbySimId(uint8_t *imei, uint8_t imei_len, uint8_t nSimID);
+
+extern int32_t zte_GetCCIDbySimId(uint8_t *ccid, uint8_t ccid_len, uint8_t nSimID);
+
+extern int32_t zte_GetMCCMNCbySimId(char *mcc, char *mnc, uint8_t nSimID);
+
+extern int32_t zte_SwitchSimHandle(uint8_t mode);
+
+extern int32_t zte_GetCSQbySimId(int32_t *rssi, int32_t *ber, uint8_t nSimID);
+
+extern int32_t zte_GetRegInfobySimid(RegInfo_t *reg_info, uint8_t nSimID);
+
+extern int32_t zte_GetCellInfobySimId(CellInfo_t *pcellinfo, uint8_t nSimID);
+
+extern int32_t zte_GetNetInfobySimId(NetInfo_t *pNetInfo, uint8_t nSimID);
+
+extern int32_t zte_SetAPNbySimID(Data_call_config_info_t *data_call, uint8_t nSimID);
+
+extern int32_t zte_StartDataCallbySimId(Data_call_config_info_t *data_call, uint8_t nSimID);
+
+extern int32_t zte_StopDataCallbySimId(uint8_t profile_id, uint8_t nSimID);
+
+extern int32_t zte_GetDataAddrbySimID(uint8_t profile_id, Data_call_addr_info_list_t *addr_list, uint8_t nSimID);
+
+extern int32_t zte_GetSimStatusbySimId(E_SIM_STATUS *sim_status, uint8_t nSimID);
+
+extern int32_t zte_SendATbySimId(char *req_at, char *info_fmt, void **pval, uint8_t nSimID);
+/********************ZTE VSIM API END****************************/
+
+
+#endif //#ifndef __ZTE_VSIM_API_H_
+