Fix mbtk from v1265 GSW

Change-Id: I5d8d395616f284bc74c8b9448cfa347164b5a668
diff --git a/mbtk/test/libgsw_lib/Makefile b/mbtk/test/libgsw_lib/Makefile
new file mode 100755
index 0000000..93c4517
--- /dev/null
+++ b/mbtk/test/libgsw_lib/Makefile
@@ -0,0 +1,36 @@
+BUILD_ROOT = $(shell pwd)/../..
+include $(BUILD_ROOT)/Make.defines
+INSTALL_DIR = $(BUILD_ROOT)/rootfs/bin
+
+INC_DIR +=
+
+LIB_DIR +=
+
+LIBS += -lmbtk_lib -lgsw_lib -ldl
+
+CFLAGS += $(CFLAGS_TEST)
+
+DEFINE +=
+
+LOCAL_SRC_FILES = $(wildcard *.c) $(wildcard *.cpp)
+
+$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+
+OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LOCAL_SRC_FILES)))
+BINS = $(patsubst %.o,%,$(OBJS))
+
+all: $(BINS)
+
+$(BINS):$(OBJS)
+	@echo "  BIN     $@"
+	$(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $@.o -o $(OUT_DIR)/bin/$@
+	cp $(OUT_DIR)/bin/$@ $(INSTALL_DIR)/
+
+%.o:%.c
+	$(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cpp
+	$(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+clean:
+	rm -f $(OBJS)
diff --git a/mbtk/test/libgsw_lib/gsw_at_test.c b/mbtk/test/libgsw_lib/gsw_at_test.c
new file mode 100755
index 0000000..6c06efb
--- /dev/null
+++ b/mbtk/test/libgsw_lib/gsw_at_test.c
@@ -0,0 +1,56 @@
+#include <stdio.h>

+#include <string.h>

+#include <stdlib.h>

+#include <dlfcn.h>

+#include <stdint.h>

+

+typedef void(*AT_CALLBACK)(char input[],char output[],int out_max_size);

+int32_t (*gsw_reg_atcmd)(const char *atcmd,AT_CALLBACK);

+void *dlHandle_at;

+char *lynqLib_at = "/lib/libgsw_lib.so";

+

+void lynq_test_example(char input[], char output[], int out_max_size)

+{

+    if(!strcmp(input, "AT+TEST1"))

+    {

+        memcpy(output, input, strlen(input));

+    }

+    else if(!strcmp(input, "AT+TEST2"))

+    {

+        memcpy(output, input, strlen(input));

+    }

+    else if(!strcmp(input, "AT+TEST3"))

+    {

+        memcpy(output, input, strlen(input));

+    }

+    else if(!strcmp(input, "AT+TEST4"))

+    {

+        memcpy(output, input, strlen(input));

+    }

+    else if(!strcmp(input, "AT+TEST5"))

+    {

+        memcpy(output, input, strlen(input));

+    }

+    return;

+}

+

+

+int main(void)

+{

+    int ret;

+    dlHandle_at = dlopen(lynqLib_at, RTLD_NOW);

+    gsw_reg_atcmd=(int32_t(*)(const char *atcmd,AT_CALLBACK))dlsym(dlHandle_at, "gsw_reg_atcmd");

+    ret = gsw_reg_atcmd("AT+TEST1;AT+TEST2;AT+TEST3;AT+TEST4;AT+TEST5",lynq_test_example);

+    if (ret == 0)

+        printf("at add ok\n");

+    else 

+        printf("at add fail\n");

+    while (1)

+    {

+       getchar();

+    }

+    dlclose(dlHandle_at);

+    dlHandle_at = NULL;

+    return 0;

+

+}
\ No newline at end of file
diff --git a/mbtk/test/libgsw_lib/gsw_data_test.c b/mbtk/test/libgsw_lib/gsw_data_test.c
new file mode 100755
index 0000000..6efa383
--- /dev/null
+++ b/mbtk/test/libgsw_lib/gsw_data_test.c
@@ -0,0 +1,365 @@
+#include <stdint.h>
+#include <string.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <dlfcn.h>
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+//gsw include
+
+
+#define GSW_HAL_SUCCESS 0
+#define GSW_HAL_FAIL -1
+#define GSW_HAL_MEM_INVAILD -2
+#define GSW_NW_OPERATION_NAME_LEN 128
+#define GSW_NW_PLMN_LEN 6
+#define GSW_NW_MCC_LEN 3
+#define GSW_NW_MNC_LEN 3
+#define GSW_NW_PARA_MAX_LEN 128
+#define GSW_MCC_MAX_LEN 16
+#define GSW_MNC_MAX_LEN 16
+#define GSW_APN_CHANNEL_MAX 10
+#define GSW_POXY_ADDR_MAX_LEN 64
+#define GSW_PDP_TYPE_MAX_LEN 16
+#define GSW_APN_MAX_LEN 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
+
+typedef struct {
+    int handle;   /**< data connection handle*/
+    int cid;   /**< data connection cid*/
+    int state;   /**< data connection state*/
+    int fail_cause;   /**< data connection fail cause*/
+    char *type;   /**< data connection type*/
+    char *ifname;   /**< ifname*/
+
+    char *v4_ip;   /**< ipv4 address*/
+    char *v4_pdns;   /**< ipv4 pdns address*/
+    char *v4_sdns;   /**< ipv4 sdns address*/
+    char *v4_gw;   /**< ipv4 gateway  address*/
+
+    char *v6_ip;   /**< ipv6 address*/
+    char *v6_pdns;   /**< ipv6 gateway  address*/
+    char *v6_sdns;   /**< ipv6 gateway  address*/
+}Wan_State_ind_s;
+
+typedef struct {
+    char ip[GSW_PDP_ADDR_MAX_LEN];   /**< ip address */
+    char pdns[GSW_DNS_ADDR_MAX_LEN];   /**< pdns address*/
+    char sdns[GSW_DNS_ADDR_MAX_LEN];   /**< sdns address*/
+    char gw[GSW_GETWAYS_ADDR_MAX_LEN];   /**< gate way address*/
+}V4_Addr_s;
+
+typedef struct {
+    char ip[GSW_PDP_ADDR_MAX_LEN];   /**< ip address*/
+    char pdns[GSW_DNS_ADDR_MAX_LEN];   /**< pdns address*/
+    char sdns[GSW_DNS_ADDR_MAX_LEN];   /**< sdns address*/
+}V6_Addr_s;
+
+typedef struct {
+    int handle;        /**< data connection handle*/
+
+    /* req info */
+    char mcc[GSW_MCC_MAX_LEN];   /**< apn mcc value*/
+    char mnc[GSW_MNC_MAX_LEN];   /**< apn mnc value*/
+    char apnid[GSW_APN_ID_MAX_LEN];   /**< apn id*/
+    char apn[GSW_APN_MAX_LEN];   /**< apn name*/
+    char apnType[GSW_APN_TYPE_MAX_LEN];   /**< apn type ipv4 ipv4v6 ipv6*/
+    char usr[GSW_USR_MAX_LEN];   /**< apn usr name*/
+    char pwd[GSW_PWD_MAX_LEN];   /**< apn password*/
+    char authType[GSW_AUTH_TYPE_MAX_LEN];   /**< apn auth type*/
+    char normalProtocol[GSW_PROTOCO_MAX_LEN];   /**< apn auth protoco*/
+    char roamingProtocol[GSW_PROTOCO_MAX_LEN];   /**< apn auth protoco roaming*/
+    char carrier[GSW_CARRIER_ID_MAX_LEN];   /**< carrier id*/
+
+    /* rsp */
+    int cid;   /**< data connection cid for mdm sdk*/
+    int active;   /**< pdn context active state: 2,actived; other,not active */
+    char ifname[GSW_IFACE_NAME_MAX_LEN];   /**< if name of current datalink */
+    int type;   /**< data connection type*/
+    V4_Addr_s v4;   /**< ipv4 addr*/
+    V6_Addr_s v6;   /**< ipv6 addr*/
+    int mtu;   /**< mtu value*/
+
+    char out[GSW_RSP_MAX_LEN];   /**< sdk return value*/
+}Link_Info_s;
+
+typedef struct
+{
+       uint64_t  tx_pkts;     /*  the number of packet sent*/
+       uint64_t  tx_bytes;     /*  the number of packet sent bytes */
+       uint64_t  tx_dropped_pkts;     /*  the number of packet  dropped by sent*/
+       uint64_t  rx_pkts;     /*  the number of packet received*/
+       uint64_t  rx_bytes;     /*  the number of packet receivedbytes */
+       uint64_t  rx_dropped_pkts;     /*  the number of packet  dropped by received*/
+}gsw_data_pkt_stats;
+
+
+typedef void (*gsw_data_call_evt_cb_t)(Wan_State_ind_s *linkState);
+
+int (*gsw_data_call_init)(gsw_data_call_evt_cb_t evt_cb);
+int (*gsw_data_call_deinit)(void);
+int (*gsw_data_call_set_apn)(Link_Info_s *LinkInf);
+int (*gsw_data_call_connect)(int linkid, Link_Info_s *LinkInf);
+int (*gsw_data_call_disconnect)(int linkid, Link_Info_s *LinkInf);
+int (*gsw_get_data_call_pkt_stats)(int linkid, gsw_data_pkt_stats *data_pkt);
+
+#define lib_gsw_data_path "/lib/libgsw_lib.so"
+static void *dlHandle_data = NULL;
+
+
+static int gsw_data_api_import()
+{
+    dlHandle_data = dlopen(lib_gsw_data_path, RTLD_NOW);
+    if (dlHandle_data == NULL) {
+        printf("error: %s\n", dlerror());
+        return -1;
+    }
+
+    gsw_data_call_init = (int (*) (gsw_data_call_evt_cb_t evt_cb))dlsym(dlHandle_data, "gsw_data_call_init");
+    if (gsw_data_call_init == NULL) {
+        printf("gsw_data_call_init dlsym failed\n");
+        return -1;
+    }
+
+    gsw_data_call_deinit = (int (*) (void))dlsym(dlHandle_data, "gsw_data_call_deinit");
+    if (gsw_data_call_deinit == NULL) {
+        printf("gsw_data_call_deinit dlsym failed\n");
+        return -1;
+    }
+
+    gsw_data_call_set_apn = (int (*)(Link_Info_s *LinkInf))dlsym(dlHandle_data, "gsw_data_call_set_apn");
+    if (gsw_data_call_set_apn == NULL) {
+        printf("gsw_data_call_set_apn dlsym failed\n");
+        return -1;
+    }
+
+    gsw_data_call_connect = (int (*)(int linkid, Link_Info_s *LinkInf))dlsym(dlHandle_data, "gsw_data_call_connect");
+    if (gsw_data_call_connect == NULL) {
+        printf("gsw_data_call_connect dlsym failed\n");
+        return -1;
+    }
+
+    gsw_data_call_disconnect = (int (*)(int linkid, Link_Info_s *LinkInf))dlsym(dlHandle_data, "gsw_data_call_disconnect");
+    if (gsw_data_call_disconnect == NULL) {
+        printf("gsw_data_call_disconnect dlsym failed\n");
+        return -1;
+    }
+
+    gsw_get_data_call_pkt_stats = (int (*)(int linkid, gsw_data_pkt_stats *data_pkt))dlsym(dlHandle_data, "gsw_get_data_call_pkt_stats");
+    if (gsw_get_data_call_pkt_stats == NULL) {
+        printf("gsw_get_data_call_pkt_stats dlsym failed\n");
+        return -1;
+    }
+
+    return 0;
+}
+
+void gsw_data_call_back(Wan_State_ind_s *linkState)
+{
+    printf("gsw_data_call_back, handle = %d\n", linkState->handle);
+    printf("gsw_data_call_back, cid = %d\n", linkState->cid);
+    printf("gsw_data_call_back, state = %d\n", linkState->state);
+    printf("gsw_data_call_back, fail_cause = %d\n", linkState->fail_cause);
+    printf("gsw_data_call_back, type = %s\n", linkState->type);
+    printf("gsw_data_call_back, ifname = %s\n", linkState->ifname);
+    printf("gsw_data_call_back, v4_ip = %s\n", linkState->v4_ip);
+    printf("gsw_data_call_back, v4_pdns = %s\n", linkState->v4_pdns);
+    printf("gsw_data_call_back, v4_sdns = %s\n", linkState->v4_sdns);
+    printf("gsw_data_call_back, v4_gw = %s\n", linkState->v4_gw);
+    printf("gsw_data_call_back, v6_ip = %s\n", linkState->v6_ip);
+    printf("gsw_data_call_back, v6_pdns = %s\n", linkState->v6_pdns);
+    printf("gsw_data_call_back, v6_sdns = %s\n", linkState->v6_sdns);
+}
+
+
+void dump_items()
+{
+
+    printf("\n");
+    printf("The current module is: data \n");
+
+    printf("-------------------------------------------------------------------------\n");
+    printf("|  index | function name                                              |\n");
+    printf("|  0       exit\n");
+    printf("   1       gsw_data_call_init\n");
+    printf("   2       gsw_data_call_deinit\n");
+    printf("   3       gsw_data_call_set_apn\n");
+    printf("   4       gsw_data_call_connect\n");
+    printf("   5       gsw_data_call_disconnect\n");
+    printf("   6       gsw_get_data_call_pkt_stats\n");
+    printf("-------------------------------------------------------------------------\n");
+}
+
+int main()
+{
+    int ret;
+    char operator[10];
+    int opt;
+
+    Link_Info_s* pub_LinkInf = (Link_Info_s*)malloc(sizeof(Link_Info_s));
+    memset(pub_LinkInf, 0x0, sizeof(Link_Info_s));
+
+    Link_Info_s* pri_LinkInf = (Link_Info_s*)malloc(sizeof(Link_Info_s));
+    memset(pri_LinkInf, 0x0, sizeof(Link_Info_s));
+
+    pub_LinkInf->handle = 0;
+    strcpy(pub_LinkInf->mcc,"460");
+    strcpy(pub_LinkInf->mnc,"11");
+    strcpy(pub_LinkInf->apn,"pub_apn");
+    strcpy(pub_LinkInf->apnid,"pub_apnid");
+    strcpy(pub_LinkInf->apnType,"default");
+    strcpy(pub_LinkInf->usr,"");
+    strcpy(pub_LinkInf->pwd,"");
+    strcpy(pub_LinkInf->authType,"0");
+    strcpy(pub_LinkInf->normalProtocol,"IPV4V6");
+    strcpy(pub_LinkInf->roamingProtocol,"IPV4V6");
+    strcpy(pub_LinkInf->carrier,"CHINA TELECOM");
+
+    pri_LinkInf->handle = 1;
+    strcpy(pri_LinkInf->mcc,"460");
+    strcpy(pri_LinkInf->mnc,"11");
+    strcpy(pri_LinkInf->apn,"pri_apn");
+    strcpy(pri_LinkInf->apnid,"pri_apnid");
+    strcpy(pri_LinkInf->apnType,"mms");
+    strcpy(pri_LinkInf->usr,"");
+    strcpy(pri_LinkInf->pwd,"");
+    strcpy(pri_LinkInf->authType,"0");
+    strcpy(pri_LinkInf->normalProtocol,"IPV4V6");
+    strcpy(pri_LinkInf->roamingProtocol,"IPV4V6");
+    strcpy(pri_LinkInf->carrier,"CHINA TELECOM");
+
+
+    ret = gsw_data_api_import();
+    if (ret != 0) {
+        printf("gsw_data_api_import failed \n");
+        free(pub_LinkInf);
+        free(pri_LinkInf);
+        return -1;
+    }
+    
+
+    while(1)
+    {
+        dump_items();
+        printf("input the index of module: ");
+        opt = -1;
+        printf("%s/n",fgets(operator, sizeof(operator), stdin));
+        fflush(stdin);
+
+        opt = atoi(operator);
+        switch (opt) {
+            case 0:
+            {
+                printf("exit\n");
+                free(pub_LinkInf);
+                free(pri_LinkInf);
+                return 0;
+            }
+            
+            case 1:
+            {
+                printf("gsw_data_call_init start\n");
+                ret = gsw_data_call_init(gsw_data_call_back);
+                if (ret != 0) {
+                    printf("gsw_data_call_init failed,ret = %d\n",ret);
+                    continue;
+                }
+                printf("gsw_data_call_init success\n");
+                break;
+            }
+
+            case 2:
+            {
+                printf("gsw_data_call_deinit start\n");
+                ret = gsw_data_call_deinit();
+                if (ret != 0) {
+                    printf("gsw_data_call_deinit failed,ret = %d\n",ret);
+                    continue;
+                }
+                printf("gsw_data_call_deinit success\n");
+                break;
+            }
+            case 3:
+            {
+                printf("gsw_data_call_set_apn start\n");
+                ret = gsw_data_call_set_apn(pub_LinkInf);
+                if (ret != 0) {
+                    printf("gsw_data_call_set_apn failed,ret = %d\n",ret);
+                    continue;
+                }
+                printf("gsw_data_call_set_apn success\n");
+                break;
+            }
+
+            case 4:
+            {
+                printf("gsw_data_call_connect start\n");
+                ret = gsw_data_call_connect(pub_LinkInf->handle, pub_LinkInf);
+                if (ret != 0) {
+                    printf("gsw_data_call_connect failed, ret = %d\n",ret);
+                    continue;
+                }
+                printf("gsw_data_call_connect success\n");
+                break;
+            }
+
+            case 5:
+            {
+                printf("gsw_data_call_disconnect start\n");
+                ret = gsw_data_call_disconnect(pub_LinkInf->handle, pub_LinkInf);
+                if (ret != 0) {
+                    printf("gsw_data_call_disconnect failed,ret = %d\n",ret);
+                    continue;
+                }
+                printf("gsw_data_call_disconnect success\n");
+                break;
+            }
+
+            case 6:
+            {
+                printf("gsw_get_data_call_pkt_stats start\n");
+                gsw_data_pkt_stats* data_pkt = (gsw_data_pkt_stats*)malloc(sizeof(gsw_data_pkt_stats));
+                memset(data_pkt, 0x0, sizeof(gsw_data_pkt_stats));
+                ret = gsw_get_data_call_pkt_stats(pub_LinkInf->handle, data_pkt);
+                if (ret != 0) {
+                    printf("gsw_get_data_call_pkt_stats failed,ret = %d\n",ret);
+                    continue;
+                }
+                else
+                {
+                    printf("gsw_get_data_call_pkt_stats success \n");
+                    printf("txPkts = %llu\n", data_pkt->tx_pkts);
+                    printf("txbytes = %llu\n", data_pkt->tx_bytes);
+                    printf("tx_dropped_pkts = %llu\n", data_pkt->tx_dropped_pkts);
+                    printf("rxPkts = %llu\n", data_pkt->rx_pkts);
+                    printf("rxbytes = %llu\n", data_pkt->rx_bytes);
+                    printf("rx_dropped_pkts = %llu\n", data_pkt->rx_dropped_pkts);
+                    free(data_pkt);
+                }
+                printf("gsw_get_data_call_pkt_stats success\n");
+                break;
+            }
+
+            default:
+            {
+                continue;
+            }
+        }
+    }
+}
+
+
diff --git a/mbtk/test/libgsw_lib/gsw_ecall_test.c b/mbtk/test/libgsw_lib/gsw_ecall_test.c
new file mode 100755
index 0000000..682d9e2
--- /dev/null
+++ b/mbtk/test/libgsw_lib/gsw_ecall_test.c
@@ -0,0 +1,566 @@
+#include <stdlib.h>

+#include <stdio.h>

+#include <string.h>

+#include <stdint.h>

+#include <signal.h>

+#include <pthread.h>

+#include <stdbool.h>

+#include <dlfcn.h>

+

+

+static void *ecall_handle = NULL;

+typedef struct

+{

+    int cmdIdx;

+    char *funcName;

+}st_api_test_case;

+

+#define GSW_EU_ECALL_MAX_MSD          140

+#define GSW_EU_ECALL_MAX_PHONE_NUMBER 82

+

+typedef enum

+{

+    GSW_EU_ECALL_TYPE_TEST      = 1,

+    GSW_EU_ECALL_TYPE_EMERGENCY = 2,

+    GSW_EU_ECALL_TYPE_RECONFIG  = 3,

+} gsw_eu_ecall_type_e;

+

+typedef struct

+{

+    uint32_t            msd_len;

+    uint8_t             msd[GSW_EU_ECALL_MAX_MSD];

+    gsw_eu_ecall_type_e type;

+    int32_t             auto_trigger;

+    char        ecall_number[GSW_EU_ECALL_MAX_PHONE_NUMBER];

+} gsw_eu_ecall_info_t;

+

+

+

+typedef enum {

+    GSW_EU_ECALL_STATE_NONE                 = -1,

+    GSW_EU_ECALL_STATE_INACTIVE             =  0,

+    GSW_EU_ECALL_STATE_ORIGINATING_CALL     =  1,

+    GSW_EU_ECALL_STATE_IN_CALL_TRANSMITTING =  2,

+    GSW_EU_ECALL_STATE_WAITING_FOR_AL_ACK   =  3,

+    GSW_EU_ECALL_STATE_IN_CALL              =  4,

+    GSW_EU_ECALL_STATE_IDLE_ALLOW_MT_ECALL  =  5,

+} gsw_eu_ecall_state_e;

+

+typedef enum {

+    GSW_EU_ECALL_MODE_NORMAL  = 0,

+    GSW_EU_ECALL_MODE_ONLY    = 1,

+    GSW_EU_ECALL_MODE_DEFAULT = 2,

+} gsw_eu_ecall_mode_e;

+

+

+typedef struct

+{

+    uint8_t  enable;

+    uint8_t  voice_mute;

+    gsw_eu_ecall_mode_e mode;

+    uint8_t  report_event;

+    uint16_t start_timer;

+    uint16_t hack_timer;

+    uint16_t trans_timer;

+    uint8_t  fail_redial;

+    uint8_t  drop_redial;

+    uint16_t cleardown_timer;

+    uint16_t init_timer;

+    uint16_t nad_reg_timer;

+    uint16_t nad_dereg_timer;

+    uint8_t  standard;

+    uint16_t era_glonass_redial;

+    uint16_t auto_answer; //auto_answer

+} gsw_eu_ecall_config_t;

+

+typedef enum {

+    GSW_EU_ECALL_CONFIG_ENABLE             = (1 << 0),

+    GSW_EU_ECALL_CONFIG_VOICE_MUTE         = (1 << 1),

+    GSW_EU_ECALL_CONFIG_MODE               = (1 << 2),

+    GSW_EU_ECALL_CONFIG_REPORT_EVENT       = (1 << 3),

+    GSW_EU_ECALL_CONFIG_START_TIMER        = (1 << 4),

+    GSW_EU_ECALL_CONFIG_HACK_TIMER         = (1 << 5),

+    GSW_EU_ECALL_CONFIG_TRANS_TIMER        = (1 << 6),

+    GSW_EU_ECALL_CONFIG_FAIL_REDIAL        = (1 << 7),

+    GSW_EU_ECALL_CONFIG_DROP_REDIAL        = (1 << 8),

+    GSW_EU_ECALL_CONFIG_CLEARDOWN_TIMER    = (1 << 9),

+    GSW_EU_ECALL_CONFIG_INIT_TIMER         = (1 << 10),

+    GSW_EU_ECALL_CONFIG_NAD_REG_TIMER      = (1 << 11),

+    GSW_EU_ECALL_CONFIG_NAD_DEREG_TIMER    = (1 << 12),

+    GSW_EU_ECALL_CONFIG_STANDARD           = (1 << 13),

+    GSW_EU_ECALL_CONFIG_ERA_GLONASS_REDIAL = (1 << 14),

+    GSW_EU_ECALL_CONFIG_AUTO_ANSWER        = (1 << 15),

+} gsw_eu_ecall_config_e;

+

+typedef enum {

+    GSW_EU_ECALL_EVENT_FAIL_NONE                        = 0,

+    GSW_EU_ECALL_EVENT_FAIL_TIMEOUT                     = 1,

+    GSW_EU_ECALL_EVENT_FAIL_HACK_TIMEOUT                = 2,

+    GSW_EU_ECALL_EVENT_FAIL_MSD_TRANS_TIMEOUT           = 3,

+    GSW_EU_ECALL_EVENT_FAIL_IVS_RESET_TIMEOUT           = 4,

+    GSW_EU_ECALL_EVENT_FAIL_CLEAR_DOWN_FALLBACK_TIMEOUT = 5,

+    GSW_EU_ECALL_EVENT_FAIL_IVS_INITIATION_TIMEOUT      = 6,

+} gsw_eu_ecall_event_fail_e;

+

+typedef enum {

+    GSW_EU_ECALL_EVENT_PROCESS_IVS_NONE               = 0,

+    GSW_EU_ECALL_EVENT_PROCESS_IVS_START_RECEIVED_MSD = 1,

+    GSW_EU_ECALL_EVENT_PROCESS_IVS_NACK_RECEIVED      = 2,

+    GSW_EU_ECALL_EVENT_PROCESS_IVS_ACK_RECEIVED       = 3,

+    GSW_EU_ECALL_EVENT_PROCESS_IVS_TX_COMPLETED       = 4,

+    GSW_EU_ECALL_EVENT_PROCESS_IVS_HLACK_RECEIVED     = 5,

+} gsw_eu_ecall_event_process_e;

+

+typedef enum {

+    GSW_EU_ECALL_EVENT_MSDUPADTE_NONE                   = -1,

+    GSW_EU_ECALL_EVENT_MSDUPDATE_IVS_UPDATING_MSD       =  0,

+    GSW_EU_ECALL_EVENT_MSDUPDATE_PSAP_REQURE_UPDATE_MSD =  1,

+    GSW_EU_ECALL_EVENT_MSDUPDATE_IVS_UPDATE_MSD_TIMEOUT =  2,

+} gsw_eu_ecall_event_msdupdate_e;

+

+typedef enum {

+    GSW_EU_ECALL_EVENT_ESTABLISH_NONE     = -1,

+    GSW_EU_ECALL_EVENT_ESTABLISH_SUCCESS  =  0,

+    GSW_EU_ECALL_EVENT_ESTABLISH_FAIL     =  1,

+} gsw_eu_ecall_event_establish_e;

+

+typedef enum {

+    GSW_EU_ECALL_EVENT_EXTEND_STATE_NONE                          = -1,

+    GSW_EU_ECALL_EVENT_EXTEND_STATE_START_RECV_SYN                =  0,

+    GSW_EU_ECALL_EVENT_EXTEND_STATE_T9_TIMEOUT                    =  1,

+    GSW_EU_ECALL_EVENT_EXTEND_STATE_T10_TIMEOUT                   =  2,

+    GSW_EU_ECALL_EVENT_EXTEND_STATE_IVS_ALACK_RECEIVED            =  3,

+    GSW_EU_ECALL_EVENT_EXTEND_STATE_IVS_LLACK_RECEIVED            =  4,

+    GSW_EU_ECALL_EVENT_EXTEND_STATE_STOPPED                       =  5,

+    GSW_EU_ECALL_EVENT_EXTEND_STATE_ANSWERING_INCOMING_PSAP_ECALL =  6,

+    GSW_EU_ECALL_EVENT_EXTEND_STATE_CLEARDOWN_RECEIVED            =  7,

+    GSW_EU_ECALL_EVENT_EXTEND_STATE_CALLBACK_TIMEOUT              =  8,

+    GSW_EU_ECALL_EVENT_IVS_NORMAL_CLEARING                        =  9,

+    GSW_EU_ECALL_EVENT_IVS_ABNORMAL_CLEARING                      =  10,

+} gsw_eu_ecall_event_extend_state_e;

+

+typedef struct

+{

+    uint8_t  ori_remainder_times;

+    uint16_t time;

+} gsw_eu_ecall_event_originate_fail_redial_t;

+

+typedef struct

+{

+    uint8_t  drop_remainder_times;

+    uint16_t time; /* The minimum time duration between the previous call attempt */

+} gsw_eu_ecall_event_drop_redial_t;

+

+

+typedef struct

+{

+    gsw_eu_ecall_event_fail_e                  fail;

+    gsw_eu_ecall_event_process_e               process;

+    gsw_eu_ecall_event_msdupdate_e             msdupdate;

+    gsw_eu_ecall_event_establish_e             establish;

+    uint16_t                                   hack_code;

+    gsw_eu_ecall_event_originate_fail_redial_t ori_redial;

+    gsw_eu_ecall_event_drop_redial_t           drop_redial;

+    gsw_eu_ecall_event_extend_state_e          extend_state;

+} gsw_eu_ecall_event_t;

+

+typedef void (*gsw_eu_ecall_event_cb_f)(gsw_eu_ecall_event_t *p_event);

+

+

+typedef enum {

+    GSW_EU_ECALL_MSD_TRANS_STATUS_NONE     = -1,

+    GSW_EU_ECALL_MSD_TRANS_STATUS_SUCCESS  =  0,

+    GSW_EU_ECALL_MSD_TRANS_STATUS_FAILURE  =  1,

+} gsw_eu_ecall_msd_trans_status_e;

+

+typedef void (*gsw_eu_ecall_status_cb_f)(uint32_t id, gsw_eu_ecall_msd_trans_status_e status);

+

+

+

+typedef int32_t (*gsw_eu_ecall_voice_init)(void);

+

+

+typedef int32_t (*gsw_eu_ecall_voice_deinit)(void);

+typedef int32_t (*gsw_eu_ecall_start)(gsw_eu_ecall_info_t *p_info);  

+typedef int32_t (*gsw_eu_ecall_hangup)(void);   

+typedef int32_t (*gsw_eu_ecall_updateMsd)(const uint8_t *msd, uint32_t msd_len);    

+typedef int32_t (*gsw_eu_ecall_pushMsd)(gsw_eu_ecall_state_e state);    

+typedef int32_t (*gsw_eu_ecall_getConfig)(gsw_eu_ecall_config_t *p_config);    

+typedef int32_t (*gsw_eu_ecall_setConfig)(int32_t item, gsw_eu_ecall_config_t *p_config);    

+typedef int32_t (*gsw_eu_ecall_setEventCB)(gsw_eu_ecall_event_cb_f cb);    

+typedef int32_t (*gsw_eu_ecall_setStatusCB)(gsw_eu_ecall_status_cb_f cb);

+

+st_api_test_case api_testcases[] = 

+{

+    {0,    "print_help"},

+    {1,    "gsw_eu_ecall_voice_init"},

+    {2,    "gsw_eu_ecall_voice_deinit"},

+    {3,    "gsw_eu_ecall_start"},

+    {4,    "gsw_eu_ecall_hangup"},

+    {5,    "gsw_eu_ecall_updateMsd"},

+    {6,    "gsw_eu_ecall_pushMsd"},

+    {7,    "gsw_eu_ecall_getConfig"},

+    {8,    "gsw_eu_ecall_setConfig"},

+    {9,    "gsw_eu_ecall_setEventCB"},

+    {10,   "gsw_eu_ecall_setStatusCB"},

+    {-1,   NULL}

+    

+};

+void sigint_handler(int sig)

+{

+    printf("sigint_handler\n");

+    dlclose(ecall_handle);

+    ecall_handle = NULL;

+

+    exit(0);

+}

+static void gsw_eu_ecall_status_cb(uint32_t id, gsw_eu_ecall_msd_trans_status_e status)

+{

+    printf("id is %u\n",id);

+    printf("status is %d\n",status);

+

+}

+

+

+static void gsw_eu_ecall_event_cb(gsw_eu_ecall_event_t *p_event)

+{

+    printf("p_event->fail: %ud\n",p_event->fail);

+    printf("p_event->process: %d\n",p_event->process);

+    printf("p_event->msdupdate:  %d\n",p_event->msdupdate);

+    printf("p_event->establish: %d\n",p_event->establish);

+    printf("p_event->hack_code: %d\n",p_event->hack_code);

+    printf("p_event->ori_redial.ori_remainder_times: %d\n",p_event->ori_redial.ori_remainder_times);

+    printf("p_event->ori_redial.time: %d\n",p_event->ori_redial.time);

+    printf("p_event->drop_redial.drop_remainder_times: %d\n",p_event->drop_redial.drop_remainder_times);

+    printf("p_event->drop_redial.time: %d\n",p_event->drop_redial.time);

+    printf("p_event->extend_state: %d\n",p_event->extend_state);

+

+}

+

+

+static void set_config(gsw_eu_ecall_config_t *p_config)

+{   

+ 

+    int ret = -1;   

+    p_config->enable = 0;

+    p_config->voice_mute = 0;

+    p_config->mode = 0;

+    p_config->report_event = 0;

+    p_config->start_timer = 0;

+    p_config->hack_timer = 0;

+    p_config->trans_timer = 0;

+    p_config->cleardown_timer = 0;

+    p_config->drop_redial = 0;

+    p_config->init_timer = 0;

+    p_config->nad_reg_timer = 0;

+    p_config->nad_dereg_timer = 0;

+    p_config->standard = 0;

+    p_config->era_glonass_redial = 0;

+    p_config->auto_answer = 0;

+    

+    printf("input p_config->fail_redial\n");

+    ret = scanf("%hhu", &p_config->fail_redial);

+    if(ret)

+    {

+        printf("input ret is %d\n",ret);

+    }

+    

+

+}

+

+static void print_get_config(gsw_eu_ecall_config_t p_config)

+{   

+    

+    printf("input p_config.enable: %d\n",p_config.enable);

+    printf("input p_config.voice_mute:%d\n",p_config.voice_mute);

+    printf("input p_config.mode:%d\n",p_config.mode);

+    printf("input p_config.report_event:%d\n",p_config.report_event);

+    printf("input p_config.start_timer:%d\n",p_config.start_timer);

+    printf("input p_config.hack_timer:%d\n",p_config.hack_timer);

+    printf("input p_config.trans_timer:%d\n",p_config.start_timer);

+    printf("input p_config.fail_redial:%d\n",p_config.fail_redial);

+    printf("input p_config.drop_redial:%d\n",p_config.drop_redial);

+    printf("input p_config.cleardown_timer:%d\n",p_config.cleardown_timer);

+    printf("input p_config.init_timer:%d\n",p_config.init_timer);

+    printf("input p_config.nad_reg_timer:%d\n",p_config.nad_reg_timer);

+    printf("input p_config.nad_dereg_timer:%d\n",p_config.nad_dereg_timer);

+    printf("input p_config.standard:%d\n",p_config.standard);

+    printf("input p_config.era_glonass_redial:%d\n",p_config.era_glonass_redial);

+    printf("input p_config.auto_answer:%d\n",p_config.auto_answer);

+    

+

+}

+void print_help(void)

+{

+    int i;

+

+    printf("Supported test cases:\n");

+    for(i = 0; ; i++)

+    {

+        if(api_testcases[i].cmdIdx == -1)

+        {

+            break;

+        }

+        printf("%d:\t%s\n", api_testcases[i].cmdIdx, api_testcases[i].funcName);

+    }

+}

+

+

+

+//static ecall_init_flag = 0;

+int main(int argc,char *argv[])

+{

+    gsw_eu_ecall_voice_init gsw_eu_ecall_voice_init_ptr = NULL;

+    gsw_eu_ecall_voice_deinit gsw_eu_ecall_voice_deinit_ptr = NULL;

+    gsw_eu_ecall_start gsw_eu_ecall_start_ptr = NULL;

+    gsw_eu_ecall_hangup gsw_eu_ecall_hangup_ptr = NULL;

+    gsw_eu_ecall_updateMsd gsw_eu_ecall_updateMsd_ptr = NULL;

+    gsw_eu_ecall_pushMsd gsw_eu_ecall_pushMsd_ptr = NULL;

+    gsw_eu_ecall_getConfig gsw_eu_ecall_getConfig_ptr = NULL;

+    gsw_eu_ecall_setConfig gsw_eu_ecall_setConfig_ptr = NULL;

+    gsw_eu_ecall_setEventCB gsw_eu_ecall_setEventCB_ptr = NULL;

+    gsw_eu_ecall_setStatusCB gsw_eu_ecall_setStatusCB_ptr = NULL;

+

+    void *ota_handle = dlopen("/lib/libgsw_lib.so", RTLD_NOW );

+    if(ota_handle == NULL)

+    {

+            printf("open lib failed\n");

+            return -1;

+    }

+

+

+    signal(SIGINT, sigint_handler);

+    

+    ecall_handle = dlopen("/lib/libgsw_lib.so", RTLD_NOW );

+    if(ecall_handle == NULL)

+    {

+            printf("open lib failed\n");

+            return -1;

+    }

+    gsw_eu_ecall_voice_init_ptr = (gsw_eu_ecall_voice_init)dlsym(ecall_handle, "gsw_eu_ecall_voice_init");

+    if(gsw_eu_ecall_voice_init_ptr == NULL)

+    {

+            printf("dlsym gsw_eu_ecall_voice_init failed\n");

+            return -1;

+    }

+    gsw_eu_ecall_voice_deinit_ptr = (gsw_eu_ecall_voice_deinit)dlsym(ecall_handle, "gsw_eu_ecall_voice_deinit");

+    if(gsw_eu_ecall_voice_deinit_ptr == NULL)

+    {

+            printf("dlsym gsw_eu_ecall_voice_deinit failed\n");

+            return -1;

+    }

+    gsw_eu_ecall_start_ptr = (gsw_eu_ecall_start)dlsym(ecall_handle, "gsw_eu_ecall_start");

+    if(gsw_eu_ecall_start_ptr == NULL)

+    {

+            printf("dlsym gsw_eu_ecall_start failed\n");

+            return -1;

+    }

+    gsw_eu_ecall_hangup_ptr = (gsw_eu_ecall_hangup)dlsym(ecall_handle, "gsw_eu_ecall_hangup");

+    if(gsw_eu_ecall_hangup_ptr == NULL)

+    {

+            printf("dlsym gsw_eu_ecall_hangup failed\n");

+            return -1;

+    }

+    gsw_eu_ecall_updateMsd_ptr = (gsw_eu_ecall_updateMsd)dlsym(ecall_handle, "gsw_eu_ecall_updateMsd");

+    if(gsw_eu_ecall_updateMsd_ptr == NULL)

+    {

+            printf("dlsym gsw_eu_ecall_updateMsd failed\n");

+            return -1;

+    }

+    gsw_eu_ecall_pushMsd_ptr = (gsw_eu_ecall_pushMsd)dlsym(ecall_handle, "gsw_eu_ecall_pushMsd");

+    if(gsw_eu_ecall_pushMsd_ptr == NULL)

+    {

+            printf("dlsym gsw_eu_ecall_pushMsd failed\n");

+            return -1;

+    }

+    gsw_eu_ecall_getConfig_ptr = (gsw_eu_ecall_getConfig)dlsym(ecall_handle, "gsw_eu_ecall_getConfig");

+    if(gsw_eu_ecall_getConfig_ptr == NULL)

+    {

+            printf("dlsym gsw_eu_ecall_getConfig failed\n");

+            return -1;

+    }

+    gsw_eu_ecall_setConfig_ptr = (gsw_eu_ecall_setConfig)dlsym(ecall_handle, "gsw_eu_ecall_setConfig");

+    if(gsw_eu_ecall_setConfig_ptr == NULL)

+    {

+            printf("dlsym gsw_eu_ecall_setConfig failed\n");

+            return -1;

+    }

+    gsw_eu_ecall_setEventCB_ptr = (gsw_eu_ecall_setEventCB)dlsym(ecall_handle, "gsw_eu_ecall_setEventCB");

+    if(gsw_eu_ecall_setEventCB_ptr == NULL)

+    {

+            printf("dlsym gsw_eu_ecall_setEventCB failed\n");

+            return -1;

+    }   

+    gsw_eu_ecall_setStatusCB_ptr = (gsw_eu_ecall_setStatusCB)dlsym(ecall_handle, "gsw_eu_ecall_setStatusCB");

+    if(gsw_eu_ecall_setStatusCB_ptr == NULL)

+    {

+            printf("dlsym gsw_eu_ecall_setStatusCB failed\n");

+            return -1;

+    }   

+

+

+

+    printf("Enter ecall api test \n");

+    int opt = -1;

+    

+    while (1)

+    {

+        

+        print_help();

+        int ret = scanf("%d",&opt);

+        if (ret == 1)

+        {

+            printf("输入的整数是:%d\n", opt);

+        }

+        

+        switch(opt)

+        {

+            case 0 :

+            {

+                print_help();

+                break;

+            } 

+            case 1 :

+            {

+                int32_t ret = -1;

+                printf("enter gsw_eu_ecall_voice_init");

+                ret = gsw_eu_ecall_voice_init_ptr();

+                printf("gsw_eu_ecall_voice_init ret = %d\n", ret);

+                

+                

+                break;

+            }

+            case 2 :

+            {

+                int32_t ret = -1;

+                printf("enter gsw_eu_ecall_voice_deinit\n");

+                ret = gsw_eu_ecall_voice_deinit_ptr();

+                printf("gsw_eu_ecall_voice_deinit ret = %d\n", ret);

+                break;

+            }

+            case 3 :

+            {

+                printf("enter gsw_eu_ecall_start\n");

+                gsw_eu_ecall_info_t info;

+                memset(&info,0,sizeof(info));

+                

+                int type;

+                printf("Enter MSD data (hex values, space-separated): ");

+ 

+                ret = scanf("%140s",info.msd); 

+                if(ret)

+                {

+                    printf("input ret is %d\n",ret);

+                }

+                info.msd_len = (uint32_t)strlen((char*)info.msd);

+                

+                

+                printf("Enter eCall type (1: Test, 2: Emergency, 3: Reconfig):\n ");

+                ret = scanf("%d", &type);

+                 if(ret)

+                {

+                    printf("input ret is %d\n",ret);

+                }

+                info.type = (gsw_eu_ecall_type_e)type;

+                

+                printf("Enter auto trigger (0: No, 1: Yes): \n");

+                ret=scanf("%d", &info.auto_trigger);

+                if(ret)

+                {

+                    printf("input ret is %d\n",ret);

+                }

+

+                if(type == 1 || type == 3)

+                {

+                    // 输入 eCall 号码

+                    printf("Enter eCall number: \n");

+                    ret = scanf("%82s", info.ecall_number);

+                    if(ret)

+                    {

+                        printf("input ret is %d\n",ret);

+                    }

+                }

+                ret = gsw_eu_ecall_start_ptr(&info);

+                printf("gsw_eu_ecall_start ret = %d\n", ret);

+                break;

+            }

+            case 4 :

+            {

+                int32_t ret = -1;

+                printf("enter gsw_eu_ecall_hangup\n");

+                ret = gsw_eu_ecall_hangup_ptr();

+                printf("gsw_eu_ecall_hangup ret = %d\n", ret);

+                break;

+            }

+            case 5 :

+            {

+                uint8_t msd[100] = "235646023026565";

+                int32_t ret = -1;

+                printf("enter gsw_eu_ecall_updateMsd\n");

+                ret = gsw_eu_ecall_updateMsd_ptr(msd, 100);

+                printf("gsw_eu_ecall_updateMsd ret = %d\n", ret);

+                break;

+            }

+            case 6 :

+            {

+                printf("enter gsw_eu_ecall_pushMsd\n");

+                gsw_eu_ecall_state_e state = -1;

+                int32_t ret = -1;

+                ret = gsw_eu_ecall_pushMsd_ptr(state);

+                printf("gsw_eu_ecall_pushMsd ret = %d\n", ret);

+                break;

+            }

+            case 7 :

+            {

+                printf("enter gsw_eu_ecall_getConfig\n");   

+                gsw_eu_ecall_config_t config;

+                int32_t ret = -1;

+                memset(&config,0,sizeof(config));

+                ret = gsw_eu_ecall_getConfig_ptr(&config);

+                printf("gsw_eu_ecall_getConfig ret = %d\n", ret);

+                print_get_config(config);

+                break;

+            }

+            case 8 :

+            {

+                printf("enter gsw_eu_ecall_setConfig\n");

+                gsw_eu_ecall_config_t config;

+                //config.ori_timeout = 10;

+                int32_t ret = -1;

+                int32_t item = 128;

+                printf("item value %d\n",item);

+                set_config(&config);

+                ret = gsw_eu_ecall_setConfig_ptr(item, &config);

+                printf("gsw_eu_ecall_setConfig ret = %d\n", ret);

+                break;

+            }

+            case 9 :

+            {

+                printf("enter gsw_eu_ecall_setEventCB\n");

+                //gsw_eu_ecall_event_cb_f cb = NULL;

+                int32_t ret = -1;

+                ret = gsw_eu_ecall_setEventCB_ptr(gsw_eu_ecall_event_cb);

+                printf("gsw_eu_ecall_setEventCB ret = %d\n", ret);

+                break;      

+            }

+            case 10 :

+            {

+                printf("""enter gsw_eu_ecall_setStatusCB\n");

+                int32_t ret = -1;

+                ret = gsw_eu_ecall_setStatusCB_ptr(gsw_eu_ecall_status_cb);   

+                printf("gsw_eu_ecall_setStatusCB ret = %d\n", ret);     

+                break;

+

+            }        

+            default:

+            {

+                printf("default");

+                print_help();

+                break;

+            }

+        }

+    }

+    

+    return 0;

+}

+           

diff --git a/mbtk/test/libgsw_lib/gsw_gnss_test.c b/mbtk/test/libgsw_lib/gsw_gnss_test.c
new file mode 100755
index 0000000..51e550c
--- /dev/null
+++ b/mbtk/test/libgsw_lib/gsw_gnss_test.c
@@ -0,0 +1,318 @@
+#include <stdio.h>

+#include <string.h>

+#include <strings.h>

+#include <stdlib.h>

+#include <errno.h>

+#include <fcntl.h>

+#include <signal.h>

+#include <sys/types.h>

+#include <unistd.h>

+#include <pthread.h>

+#include <termios.h>

+#include <time.h>

+#include <sys/ioctl.h>

+#include <dlfcn.h>

+#include <stdint.h>

+#include <stdbool.h>

+

+typedef struct

+{

+    /**< set to sizeof(GpsLocation) */

+    size_t       size;

+    /**< Contains GpsLocationFlags bits. */

+    unsigned short int     flags;

+    /**< Represents latitude in degrees. */

+    double      latitude;

+    /**< Represents longitude in degrees. */

+    double      longitude;

+    /**< Represents altitude in meters above the WGS 84 reference ellipsoid. */

+    double      altitude;

+    /**< Represents speed in meters per second. */

+    float        speed;

+    /**< Represents heading in degrees. */

+    float        bearing;

+    /**< Represents expected accuracy in meters. */

+    float        accuracy;

+    /**< Timestamp for the location fix. */

+    long long int      timestamp;

+}GSW_GNSS_LOCATION_T;

+

+typedef struct {

+    GSW_GNSS_LOCATION_T legacyLocation;

+    float           horizontalAccuracyMeters;

+    /**< Represents expected vertical position accuracy in meters

+    * (68% confidence).*/

+    float           verticalAccuracyMeters;

+    /**< Represents expected speed accuracy in meter per seconds

+    * (68% confidence).*/

+    float           speedAccuracyMetersPerSecond;

+    /**< Represents expected bearing accuracy in degrees

+    * (68% confidence).*/

+    float           bearingAccuracyDegrees;

+}GSW_GNSS_LOCATION_EXT_T;

+

+

+typedef enum{

+    GSW_SWITCH_DISABLE = 0,    /**< configuration switch disable :0 */

+    GSW_SWITCH_ENABLE          /**< configuration switch enable :1 */

+}GSW_GNSS_CONF_SWITCH;

+

+typedef enum{

+    GSW_MODE_GPS = 1,                               /**< GPS only */

+    GSW_MODE_BEIDOU,                                /**< BEIDOU only*/

+    GSW_MODE_GPS_BEIDOU,                            /**< GPS+BEIDOU */

+    GSW_MODE_GLONASS,                               /**< GLONASS only */ /* The high-tech platform does not support this type */

+    GSW_MODE_GPS_GLONASS,                           /**< GPS+GLONASS */

+    GSW_MODE_GLONASS_BEIDOU,                        /**< GLONASS+BEIDOU */ /* The high-tech platform does not support this type */

+    GSW_MODE_GPS_GLONASS_BEIDOU,                    /**< GPS+GLONASS+BEIDOU */ /* The high-tech platform does not support this type */           

+    GSW_MODE_GALILEO,                               /**< GALILEO only */ 

+    GSW_MODE_GPS_GALILEO,                           /**< GPS+GALILEO */ 

+    GSW_MODE_BEIDOU_GALILEO,                        /**< BEIDOU+GALILEO */ 

+    GSW_MODE_GPS_BEIDOU_GALILEO,                    /**< GPS+BEIDOU+GALILEO */ 

+    GSW_MODE_GLONASS_GALILEO,                       /**< GLONASS+GALILEO */ 

+    GSW_MODE_GPS_GLONASS_GALILEO,                   /**< GPS+GLONASS+GALILEO */ 

+    GSW_MODE_BEIDOU_GLONASS_GALILEO,                /**< BEIDOU+GLONASS+GALILEO */ /* The high-tech platform does not support this type */

+}GSW_GNSS_MODE_CONFIGURATION;

+

+typedef void (*gsw_gnss_location_callback_ext)(GSW_GNSS_LOCATION_EXT_T* location);

+typedef void (*gsw_gnss_nmea_callback )(const char* nmea, int length);

+

+typedef struct{

+gsw_gnss_location_callback_ext gsw_location_cb;

+gsw_gnss_nmea_callback gsw_nmea_cb;

+}gsw_gnss_cb;

+

+typedef enum{

+    GSW_FREQ_1HZ = 1,    /**< 1hZ */

+    GSW_FREQ_2HZ = 2,    /**< 2hZ */

+    GSW_FREQ_5HZ = 5,    /**< 5hZ */

+    GSW_FREQ_10HZ = 10,   /**< 10hZ */

+}gnss_freq_type;

+

+typedef struct{

+GSW_GNSS_MODE_CONFIGURATION start_mode;

+gnss_freq_type freq;

+gsw_gnss_cb callback;

+}gsw_gnss_init_configure_t;

+

+int (*gsw_gnss_set_freq)(int freq);

+int (*gsw_gnss_init)(void);

+int (*gsw_gnss_start)(void);

+int (*gsw_gnss_stop)(void);

+int (*gsw_gnss_deinit)(void);

+int (*gsw_gnss_set_start_mode)(GSW_GNSS_MODE_CONFIGURATION start_mode);

+int (*gsw_gnss_epo_switch)(GSW_GNSS_CONF_SWITCH switch_op);

+int (*gsw_gnss_reg_cb_group)(gsw_gnss_cb callback);

+//int (*gsw_gnss_xtra_is_enable)(gsw_xtra_state_e state);

+int (*gsw_gnss_delete_aiding_data)(unsigned int flags);

+int (*gsw_gnss_init_configure_gps)(gsw_gnss_init_configure_t init_configure);

+

+void *dlHandle_gnss_test;

+char *lynqLib_gnss_test = "/lib/libgsw_lib.so";

+

+

+void tmp_gnss_callack(const char* nmea, int length)

+{

+    printf("%s",nmea);

+}

+

+gsw_gnss_cb tmp_ptr = {

+    NULL,

+    tmp_gnss_callack

+};

+

+void user_help(void)

+{

+    printf("\t-1 exit\n"

+           "\t1 gnss init\n"

+           "\t2 gnss deinit \n"

+           "\t3 gnss reg_cb\n"

+           "\t6 gnss start\n"

+           "\t7 gnss stop\n"

+           "\t8 gnss Delete_Aiding_Data and reset\n"

+           "\t9 gnss epo switch\n"

+           "\t10 gnss set startmode\n"

+           "\t11 gnss set frequency\n"

+           "please input operator: >> ");

+}

+void delete_type(void)

+{

+    printf("\t0 DELETE_NOTHING\n"

+           "\t1 DELETE_EPHEMERIS\n"

+           "\t2 DELETE_ALL\n"

+           "please input operator: >> ");

+}

+

+int main(void)

+{

+    int ret;

+    int opt = 0;

+    dlHandle_gnss_test = dlopen(lynqLib_gnss_test, RTLD_NOW);

+    while(1)

+    {

+        printf("=========gnss main=========\n");

+        user_help();

+        if (scanf("%d", &opt) != 1)

+        {  

+            printf("Input error, please check it\n");  

+            while (getchar() != '\n');

+            continue;

+        }

+        while(getchar()!='\n');

+        switch (opt)

+        {

+        case -1:

+        {

+            printf("main exit\n");

+            return 0;

+        }

+

+        case 1:

+        {

+            gsw_gnss_init=(int(*)())dlsym(dlHandle_gnss_test, "gsw_gnss_init");

+            ret = gsw_gnss_init();

+            if(ret < 0)

+            {

+                printf("gsw_gnss_init FAIL.\n");

+                return -1;

+            }

+            printf("gsw_gnss_init success.\n");

+            break;

+        }

+        case 2:

+        {

+            gsw_gnss_deinit=(int(*)())dlsym(dlHandle_gnss_test, "gsw_gnss_deinit");

+            ret =gsw_gnss_deinit();

+            if(ret < 0)

+            {

+                printf("gsw_gnss_deinit FAIL.\n");

+                return -1;

+            }

+            printf("gsw_gnss_deinit success \n");

+            break;

+        }

+        case 3:

+        {

+            gsw_gnss_reg_cb_group=(int(*)(gsw_gnss_cb))dlsym(dlHandle_gnss_test, "gsw_gnss_reg_cb_group");

+            ret =gsw_gnss_reg_cb_group(tmp_ptr);

+            if(ret < 0)

+            {

+                printf("gsw_gnss_reg_cb_group FAIL.\n");

+                return -1;

+            }

+            printf("gsw_gnss_reg_cb_group success \n");

+            break;

+        }

+        // case 4:

+        // {

+        //     qser_Gnss_Deinit=(int(*)(uint32_t))dlsym(dlHandle_gnss, "qser_Gnss_Deinit");

+        //     ret =qser_Gnss_Deinit(ph_gnss);

+        //     if(ret < 0)

+        //     {

+        //         printf("mopen_gnss_client_Deinit FAIL.\n");

+        //         return -1;

+        //     }

+        //     printf("mopen_gnss_client_Deinit success \n");

+        //     break;

+        // }

+        // case 5:

+        // {

+        //     qser_Gnss_Deinit=(int(*)(uint32_t))dlsym(dlHandle_gnss, "qser_Gnss_Deinit");

+        //     ret =qser_Gnss_Deinit(ph_gnss);

+        //     if(ret < 0)

+        //     {

+        //         printf("mopen_gnss_client_Deinit FAIL.\n");

+        //         return -1;

+        //     }

+        //     printf("mopen_gnss_client_Deinit success \n");

+        //     break;

+        // }

+        case 6:

+        {

+            gsw_gnss_start=(int(*)())dlsym(dlHandle_gnss_test, "gsw_gnss_start");

+            ret =gsw_gnss_start();

+            if(ret < 0)

+            {

+                printf("gsw_gnss_start FAIL.\n");

+                return -1;

+            }

+            printf("gsw_gnss_start success \n");

+            break;

+        }

+        case 7:

+        {

+            gsw_gnss_stop=(int(*)())dlsym(dlHandle_gnss_test, "gsw_gnss_stop");

+            ret =gsw_gnss_stop();

+            if(ret < 0)

+            {

+                printf("gsw_gnss_stop FAIL.\n");

+                return -1;

+            }

+            printf("gsw_gnss_stop success \n");

+            break;

+        }

+        case 8:

+        {

+            int flags; // 1-dele no ; 2- dele eph ; 3 dele all

+            gsw_gnss_delete_aiding_data=(int(*)(unsigned int))dlsym(dlHandle_gnss_test, "gsw_gnss_delete_aiding_data");

+            delete_type();

+            if (scanf("%d", &flags) != 1)

+                printf("input error,please check it");

+            ret =gsw_gnss_delete_aiding_data(flags);

+            if(ret < 0)

+            {

+                printf("gsw_gnss_delete_aiding_data FAIL.\n");

+                return -1;

+            }

+            printf("gsw_gnss_delete_aiding_data success \n");

+            break;

+        }

+        case 9:

+        {

+            int able;

+            gsw_gnss_epo_switch=(int(*)(GSW_GNSS_CONF_SWITCH))dlsym(dlHandle_gnss_test, "gsw_gnss_epo_switch");

+            if (scanf("%d", &able) != 1)

+                printf("input error,please check it");

+            ret =gsw_gnss_epo_switch(able);

+            if(ret < 0)

+            {

+                printf("mopen_gnss_client_Deinit FAIL.\n");

+                return -1;

+            }

+            printf("mopen_gnss_client_Deinit success \n");

+            break;

+        }

+        case 10:

+        {

+            int conf;

+            gsw_gnss_set_start_mode=(int(*)(uint32_t))dlsym(dlHandle_gnss_test, "gsw_gnss_set_start_mode");

+            if (scanf("%d", &conf) != 1)

+                printf("input error,please check it");

+            ret =gsw_gnss_set_start_mode(conf);

+            if(ret < 0)

+            {

+                printf("gsw_gnss_set_start_mode FAIL.\n");

+                return -1;

+            }

+            printf("gsw_gnss_set_start_mode success \n");

+            break;

+        }

+        case 11:

+        {

+            int frequency;

+            gsw_gnss_set_freq=(int(*)(int))dlsym(dlHandle_gnss_test, "gsw_gnss_set_freq");

+            if (scanf("%d", &frequency) != 1)

+                printf("input error,please check it");

+            ret =gsw_gnss_set_freq(frequency);

+            if(ret < 0)

+            {

+                printf("gsw_gnss_set_freq FAIL.\n");

+                return -1;

+            }

+            printf("frequency is %d\n",frequency);

+            printf("gsw_gnss_set_freq success\n");

+            break;

+        }

+        }

+    }

+}
\ No newline at end of file
diff --git a/mbtk/test/libgsw_lib/gsw_gpio_test.c b/mbtk/test/libgsw_lib/gsw_gpio_test.c
new file mode 100755
index 0000000..3dbf1fc
--- /dev/null
+++ b/mbtk/test/libgsw_lib/gsw_gpio_test.c
@@ -0,0 +1,145 @@
+#include <stdio.h>

+#include <string.h>

+#include <strings.h>

+#include <stdlib.h>

+#include <errno.h>

+#include <fcntl.h>

+#include <signal.h>

+#include <sys/types.h>

+#include <unistd.h>

+#include <pthread.h>

+#include <termios.h>

+#include <time.h>

+#include <sys/ioctl.h>

+#include <dlfcn.h>

+#include <stdint.h>

+#include <stdbool.h>

+

+typedef enum{

+  GSW_HAL_PINDIR_IN,

+  GSW_HAL_PINDIR_OUT,

+}gsw_hal_pinDirection;

+

+typedef enum{

+  GSW_HAL_LEVEL_LOW,

+  GSW_HAL_LEVEL_HIGH,

+}gsw_hal_pinLevel;

+

+typedef enum{

+  GSW_HAL_PULL_NULL,

+  GSW_HAL_PULL_DOWN,

+  GSW_HAL_PULL_UP,

+}gsw_hal_pinPullSel;

+

+typedef enum{

+  GSW_HAL_USB_DISCONNECTED,

+  GSW_HAL_USB_CONNECTED,

+}gsw_hal_usbStatus;

+

+int32_t (*gsw_gpio_Init)(uint32_t, gsw_hal_pinDirection, gsw_hal_pinLevel);

+int32_t (*gsw_gpio_SetDirection)(uint32_t, gsw_hal_pinDirection);

+int32_t (*gsw_gpio_SetLevel)(uint32_t, gsw_hal_pinLevel);

+gsw_hal_pinLevel (*gsw_gpio_GetLevel)(uint32_t);

+gsw_hal_usbStatus (*gsw_hwpin_is_usb_connected)();

+int32_t (*gsw_setWakeupLevel)(gsw_hal_pinLevel);

+void *dlHandle_gpio;

+char *lynqLib_gpio = "/lib/libgsw_lib.so";

+

+int main(int argc,char **argv)

+{

+    int ret;

+    dlHandle_gpio = dlopen(lynqLib_gpio, RTLD_NOW);

+    if (argc == 4)

+    {

+        if (strcmp(argv[1], "D") == 0)

+        {

+            gsw_gpio_SetDirection=(int32_t(*)(uint32_t, gsw_hal_pinDirection))dlsym(dlHandle_gpio, "gsw_gpio_SetDirection");

+            ret = gsw_gpio_SetDirection(atoi(argv[2]), atoi(argv[3]));

+            if(ret < 0)

+            {

+                printf("gsw_gpio_SetDirection FAIL.\n");

+                return -1;

+            }

+            printf("gsw_gpio_SetDirection success.\n");

+        }

+        else if (strcmp(argv[1], "V") == 0)

+        {

+            gsw_gpio_SetLevel=(int32_t(*)(uint32_t, gsw_hal_pinLevel))dlsym(dlHandle_gpio, "gsw_gpio_SetLevel");

+            ret = gsw_gpio_SetLevel(atoi(argv[2]), atoi(argv[3]));

+            if(ret < 0)

+            {

+                printf("gsw_gpio_SetLevel FAIL.\n");

+                return -1;

+            }

+            printf("gsw_gpio_SetLevel success.\n");

+        }

+        else

+        {

+            gsw_gpio_Init=(int32_t(*)(uint32_t, gsw_hal_pinDirection, gsw_hal_pinLevel))dlsym(dlHandle_gpio, "gsw_gpio_Init");

+            ret = gsw_gpio_Init(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]));

+            if(ret < 0)

+            {

+                printf("gsw_gpio_Init FAIL.\n");

+                return -1;

+            }

+            printf("gsw_gpio_Init success.\n");

+        }

+    }

+

+    else if (argc == 3)

+    {

+        

+        if (strcmp(argv[1], "W") == 0)

+        {

+            gsw_setWakeupLevel=(int32_t(*)(gsw_hal_pinLevel))dlsym(dlHandle_gpio, "gsw_setWakeupLevel");

+            ret = gsw_setWakeupLevel(atoi(argv[2]));

+            if(ret < 0)

+            {

+                printf("gsw_setWakeupLevel FAIL.\n");

+                return -1;

+            }

+            printf("gsw_setWakeupLevel success.\n");

+        }

+        else

+        {

+            printf("error,please check input\n");

+            return -1;

+        }

+    }

+    else if (argc == 2)

+    {

+        if (strcmp(argv[1], "U") == 0)

+        {

+            gsw_hwpin_is_usb_connected=(gsw_hal_usbStatus(*)())dlsym(dlHandle_gpio, "gsw_hwpin_is_usb_connected");

+            ret = gsw_hwpin_is_usb_connected();

+            if(ret == 0)

+            {

+                printf("gsw_hwpin_is_usb_Unconnected ret = %d\n",ret);

+                return 0;

+            }

+            else

+            {

+                printf("gsw_hwpin_is_usb_connected.ret = %d\n",ret);

+                return 0;

+            }

+            

+        }

+        else

+        {

+            gsw_gpio_GetLevel=(gsw_hal_pinLevel(*)(uint32_t))dlsym(dlHandle_gpio, "gsw_gpio_GetLevel");

+            ret = gsw_gpio_GetLevel(atoi(argv[1]));

+            if(ret < 0)

+            {

+                printf("gsw_gpio_GetLevel FAIL.\n");

+                return -1;

+            }

+            printf("gsw_gpio_GetLevel success.\n");

+        }

+    }

+    else

+    {

+        printf("error,please check input\n");

+        return -1;

+    }

+    return 0;

+}
\ No newline at end of file
diff --git a/mbtk/test/libgsw_lib/gsw_nw_test.c b/mbtk/test/libgsw_lib/gsw_nw_test.c
new file mode 100755
index 0000000..9fc90b1
--- /dev/null
+++ b/mbtk/test/libgsw_lib/gsw_nw_test.c
@@ -0,0 +1,1318 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <dlfcn.h>
+#include <stdint.h>
+#include <string.h>
+#include <pthread.h>
+
+//mbtk include
+#define LYNQ_AIR_PLANE_MODE_ON      4    //at+cfun = 4
+#define LYNQ_AIR_PLANE_MODE_OFF     1   // at+cfun = 1
+
+
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
+#ifndef FALSE
+#define FALSE   (0)
+#endif
+ 
+ 
+#ifndef TRUE
+#define TRUE    (!FALSE)
+#endif
+
+typedef unsigned int uint32;
+typedef unsigned char uint8;
+typedef unsigned short uint16;
+typedef void (*mbtk_info_callback_func)(const void* data, int data_len);
+
+typedef enum
+{
+    MBTK_DEV_MODEM_MIN_FUN,                                   //Modem 最小功能
+    MBTK_DEV_MODEM_FULL_FUN,                                  //Modem 全功能
+    MBTK_DEV_MODEM_DISABLE_RECEIVE_RF_CIRCUITS = 3,           //Modem 禁用射频接收电路
+    MBTK_DEV_MODEM_DISABLE_TRANSMIT_AND_RECEIVE_RF_CIRCUITS,  //Modem禁用射频发射和接收电路
+    MBTK_DEV_MODEM_DISABLE_SIM,                               //Modem 禁用(U)SIM 卡
+    MBTK_DEV_MODEM_TURN_OFF_FULL_SECONDARY_RECEIVE,           //Modem 完全禁用辅助接收
+}MBTK_DEV_MODEM_FUNCTION;
+
+typedef enum
+{
+    MBTK_CELL_TYPE_GSM = 0,
+    MBTK_CELL_TYPE_UMTS,
+    MBTK_CELL_TYPE_LTE
+} mbtk_cell_type_enum;
+
+typedef struct
+{
+    MBTK_DEV_MODEM_FUNCTION fun;
+    int rst;
+} mbtk_modem_info_t;
+
+typedef struct
+{
+    int client_fd;
+    pthread_t read_thread_id;
+    int exit_fd[2];
+    bool is_waitting;
+    pthread_cond_t cond;
+    pthread_mutex_t mutex;
+
+    pthread_mutex_t send_mutex;
+
+    // Temp response data.
+    uint16 info_err;
+    uint16 data_len;
+    void *data;
+
+    //mbtk wyq for server_ready_status add start
+    char server_ready_status;
+    //mbtk wyq for server_ready_status add end
+
+    mbtk_info_callback_func net_state_cb;
+    mbtk_info_callback_func call_state_cb;
+    mbtk_info_callback_func sms_state_cb;
+    mbtk_info_callback_func radio_state_cb;
+    mbtk_info_callback_func sim_state_cb;
+    mbtk_info_callback_func pdp_state_cb;
+    //add signal by xr
+    mbtk_info_callback_func signal_state_cb;
+} mbtk_info_handle_t;
+
+
+
+typedef struct
+{
+    // LTE server cell: tac, PCI, dlEuarfcn, ulEuarfcn, band
+    // LTE cell: phyCellId,euArfcn,rsrp,rsrq
+    // WCDMA server cell: lac, ci, arfcn
+    // WCDMA cell: lac, ci, arfcn
+    // GSM server cell: lac, ci, arfcn, bsic
+    // GSM cell:
+    mbtk_cell_type_enum type : 8;
+    uint32 value1; //tac
+    uint32 value2; //pci
+    uint32 value3; //dlEuarfcn
+    uint32 value4; //ul arfcn
+    uint32 value5; //band
+	uint32 value6; //mcc
+    uint32 value7; //mnc
+    uint32 value8; //cid
+    uint32 value9; //rsrp
+    uint32 value10; //cell identiy
+} __attribute__((packed)) mbtk_cell_info_t;
+
+
+
+
+
+typedef struct
+{
+    uint8 net_pref;     // mbtk_net_pref_enum
+    uint16 gsm_band;    // mbtk_gsm_band_enum
+    uint16 umts_band;   // mbtk_umts_band_enum
+    uint32 tdlte_band;  // mbtk_tdlte_band_enum
+    uint32 fddlte_band; // mbtk_fddlte_band_enum
+    uint32 lte_ext_band; // mbtk_lte_ext_band_enum
+} __attribute__((packed)) mbtk_band_info_t;
+
+typedef struct list_arraynode
+{
+    void *data;
+    struct list_arraynode *next;
+} list_arraynode_t;
+
+typedef struct list_treenode
+{
+    list_arraynode_t *data;
+    int count;
+    struct list_treenode *left;
+    struct list_treenode *right;
+} list_treenode_t;
+
+typedef int (*list_sort_func)(void *data1, void *data2);
+typedef void (*list_free_func)(void *data);
+
+typedef struct list_node
+{
+    uint32 size;
+    list_sort_func sort_func;
+    list_free_func free_func;
+
+    uint32 cur_index;
+    list_arraynode_t *cur_array_data;
+
+    list_arraynode_t array_data;
+    list_treenode_t tree_data;
+} list_node_t;
+
+/*
+0: GSM
+1: GSM Compact
+2: UTRAN
+3: GSM w/EGPRS
+4: UTRAN w/HSDPA
+5: UTRAN w/HSUPA
+6: UTRAN w/HSDPA and HSUPA
+7: E-UTRAN
+8: UTRAN HSPA+
+*/
+typedef enum {
+    MBTK_RADIO_TECH_GSM = 0,
+    MBTK_RADIO_TECH_GSM_COMPACT,
+    MBTK_RADIO_TECH_UTRAN,
+    MBTK_RADIO_TECH_GSM_EGPRS,
+    MBTK_RADIO_TECH_UTRAN_HSDPA,
+    MBTK_RADIO_TECH_UTRAN_HSUPA,
+    MBTK_RADIO_TECH_UTRAN_HSDPA_HSUPA,
+    MBTK_RADIO_TECH_E_UTRAN,      // LTE
+    MBTK_RADIO_TECH_UTRAN_HSPA
+} mbtk_radio_technology_enum;
+
+typedef struct
+{
+    /*
+    0: automatic
+    1: manual
+    */
+    uint8 net_sel_mode;
+    /*
+    0: GSM
+    1: GSM Compact
+    2: UTRAN
+    3: GSM w/EGPRS
+    4: UTRAN w/HSDPA
+    5: UTRAN w/HSUPA
+    6: UTRAN w/HSDPA and HSUPA
+    7: E-UTRAN
+    8: UTRAN HSPA+
+    0xFF: Unused
+    */
+    uint8 net_type;
+    //uint8 plmn[10]; // 46000
+    /*
+    0: unknown
+    1: available
+    2: current
+    3: forbidden
+    */
+    uint8 net_state;
+    uint32 plmn;
+} __attribute__((packed)) mbtk_net_info_t;
+
+
+typedef enum
+{
+    MBTK_NET_REG_STATE_NON = 0,
+    MBTK_NET_REG_STATE_HOME,
+    MBTK_NET_REG_STATE_SEARCHING,
+    MBTK_NET_REG_STATE_DENIED,
+    MBTK_NET_REG_STATE_UNKNOWN,
+    MBTK_NET_REG_STATE_ROAMING,
+    MBTK_NET_REG_STATE_SMS_ONLY,
+    MBTK_NET_REG_STATE_ROAMING_SMS,
+    MBTK_NET_REG_STATE_ATTACHED_EMERGENCY,
+    MBTK_NET_REG_STATE_CSFB_HOME,
+    MBTK_NET_REG_STATE_CSFB_ROAMING,
+    MBTK_NET_REG_STATE_EMERGENCY_ONLY
+} mbtk_net_reg_state_enum;
+
+typedef struct
+{
+    uint8 call_state;// mbtk_net_reg_state_enum
+    uint8 data_state;// mbtk_net_reg_state_enum
+    uint8 ims_state;// mbtk_net_reg_state_enum
+    uint8 type; // mbtk_radio_technology_enum
+    uint16 lac;
+    uint32 ci;
+} __attribute__((packed)) mbtk_net_reg_info_t;
+
+typedef struct
+{
+    uint8 type; // mbtk_radio_technology_enum
+    uint8 rssi; // 0: 113 dBm or less
+                // 1: 111 dBm
+                // 2��30: 109��53 dBm
+                // 31: 51 dBm or greater
+                // 99: not known or not detectable
+    uint8 rxlev;// 0:rssi < -110 dBm
+                // 1: -110 dBm �� rssi < -109 dBm
+                // 2: -109 dBm �� rssi < -108 dBm
+                // ......
+                // 61: -50 dBm �� rssi < -49 dBm
+                // 62: -49 dBm �� rssi < -48 dBm
+                // 63: -48 dBm �� rssi
+                // 99: not known or not detectable
+    uint8 ber;  // 0...7 as RXQUAL values in the table in 3GPP TS 45.008 [20] subclause 8.2.4
+                // 99 not known or not detectable
+    uint8 rscp; // 0: rscp < -120 dBm
+                // 1: -120 dBm �� rscp < -119 dBm
+                // 2: -119 dBm �� rscp < -118 dBm
+                // ......
+                // 94: -27 dBm �� rscp < -26 dBm
+                // 95: -26 dBm �� rscp < -25 dBm
+                // 96: - 25 dBm �� rscp
+                // 255: not known or not detectable
+    uint8 ecno; // 0: Ec/Io < -24 dB
+                // 1: -24 dB �� Ec/Io < -23.5 dB
+                // 2: -23.5 dB �� Ec/Io < -23 dB
+                // ......
+                // 47: -1 dB �� Ec/Io < -0.5 dB
+                // 48: -0.5 dB �� Ec/Io < 0 dB
+                // 49: 0 dB �� Ec/Io
+                // 255: not known or not detectable
+    uint8 rsrq; // 0: rsrq < -19.5 dB
+                // 1: -19.5 dB �� rsrq < -19 dB
+                // 2: -19 dB �� rsrq < -18.5 dB
+                // ......
+                // 32: -4 dB �� rsrq < -3.5 dB
+                // 33: -3.5 dB �� rsrq < -3 dB
+                // 34: -3 dB �� rsrq
+                // 255: not known or not detectable
+    uint8 rsrp; // 0: rsrp < -140 dBm
+                // 1: -140 dBm �� rsrp < -139 dBm
+                // 2: -139 dBm �� rsrp < -138 dBm
+                // ......
+                // 95: -46 dBm �� rsrp < -45 dBm
+                // 96: -45 dBm �� rsrp < -44 dBm
+                // 97: -44 dBm �� rsrp
+                // 255: not known or not detectable
+} __attribute__((packed)) mbtk_signal_info_t;
+
+#define lib_gsw_nw_path "/lib/libgsw_lib.so"
+static void *dlHandle_nw = NULL;
+
+//gsw include
+
+
+#define GSW_HAL_SUCCESS 0
+#define GSW_HAL_FAIL -1
+#define GSW_HAL_MEM_INVAILD -2
+#define GSW_NW_OPERATION_NAME_LEN 128
+#define GSW_NW_PLMN_LEN 6
+#define GSW_NW_MCC_LEN 3
+#define GSW_NW_MNC_LEN 3
+#define GSW_NW_PARA_MAX_LEN 128
+#define GSW_MCC_MAX_LEN 16
+#define GSW_MNC_MAX_LEN 16
+#define GSW_APN_CHANNEL_MAX 10
+#define GSW_POXY_ADDR_MAX_LEN 64
+#define GSW_PDP_TYPE_MAX_LEN 16
+#define GSW_APN_MAX_LEN 65
+#define GSW_APN_ID_MAX_LEN 32
+#define GSW_APN_TYPE_MAX_LEN 50
+#define GSW_USR_MAX_LEN 16
+#define GSW_PWD_MAX_LEN 16
+#define GSW_AUTH_TYPE_MAX_LEN 50
+#define GSW_PROTOCO_MAX_LEN 64
+#define GSW_CARRIER_ID_MAX_LEN 64
+#define GSW_IFACE_NAME_MAX_LEN 50
+#define GSW_PDP_ADDR_MAX_LEN 64
+#define GSW_DNS_APN_MAX_LEN 64
+#define GSW_GETWAYS_ADDR_MAX_LEN 64
+#define GSW_RSP_MAX_LEN 256
+#define GSW_PLMN_LIST_MAX_LEN 85
+
+
+
+typedef enum service_domain
+{
+    GSW_SRV_DOMAIN_NO_SVC       = 0x0,   /**< no service */
+    GSW_SRV_DOMAIN_CS_ONLY      = 0x1,   /**< cs only */
+    GSW_SRV_DOMAIN_PS_ONLY      = 0x2,   /**< ps only */
+    GSW_SRV_DOMAIN_CS_PS        = 0x3,   /**< reg all in service */
+} GSW_SERVICE_DOMAIN_E;
+
+typedef enum gsw_network_reg_state
+{
+    GSW_NETWORK_REG_NOT_REGISTERED           = 0x0,   /**< no service */
+    GSW_NETWORK_REG_REGISTERED               = 0x1,   /**< reg in service home */
+    GSW_NETWORK_REG_NOT_REGISTERED_SEARCHING = 0x2,   /**< searching network */
+    GSW_NETWORK_REG_REGISTRATION_DENIED      = 0x3,   /**< network denny device */
+    GSW_NETWORK_REG_REGISTRATION_UNKNOWN     = 0x4,   /**< unknown state */
+    GSW_NETWORK_REG_REGISTRATION_ROAMING     = 0x5,   /**< roaming state  in service */
+    GSW_NETWORK_REG_LIMITED_SERVICE     = 0x6,   /**< limited service */
+} GSW_NW_REG_STATE_E;
+
+typedef enum gsw_network_radio_interface
+{
+    GSW_NETWORK_RADIO_NO_SVC            = 0x0,   /**< radio state no service */
+    GSW_NETWORK_RADIO_CDMA_1X           = 0x1,   /**< cdma 1x */
+    GSW_NETWORK_RADIO_CDMA_1XEVDO       = 0x2,   /**< cdma evdo */
+    GSW_NETWORK_RADIO_AMPS              = 0x3,   /**< amps gsm 2g*/
+    GSW_NETWORK_RADIO_GSM               = 0x4,   /**< gsm */
+    GSW_NETWORK_RADIO_UMTS              = 0x5,   /**< umts wcdma*/
+    GSW_NETWORK_RADIO_LTE               = 0x6,   /**< LTE 4G */
+    GSW_NETWORK_RADIO_TDSCDMA           = 0x7,   /**< TDS 3G*/
+    GSW_NETWORK_RADIO_NR5G              = 0x8,   /**< NR 5G*/
+} GSW_NW_RADIO_ACCESS_TECH_E;
+
+
+typedef enum gsw_network_roaming_state
+{
+    GSW_NETWORK_ROAMING_OFF      = 0x0,   /**< roaming off */
+    GSW_NETWORK_ROAMING_ON       = 0x1,   /**< roaming on*/
+} GSW_NW_ROAMING_STATE_E;
+
+typedef enum oprate_mode
+{
+    GSW_OP_MODE_LPM    = 0,   /**< radio state off*/
+    GSW_OP_MODE_ONLINE = 1,   /**< radio state on*/
+    GSW_OP_MODE_FTM    = 2,   /**< radio state ftm*/
+    GSW_OP_MODE_OFFLINE = 3,   /**< radio state offline*/
+} OPERATE_MODE_E;
+
+typedef enum prefer_mode
+{
+    GSW_PREFER_MODE_GSW    = 1,   /**<2G only*/
+    GSW_PREFER_MODE_WCDMA    = 2,   /**< 3G only*/ 
+    GSW_PREFER_MODE_WCDMA_GSM    = 3,   /**< 3G/2G*/
+    GSW_PREFER_MODE_LTE    = 4,   /**< 4G only*/
+    GSW_PREFER_MODE_NR5G    = 5,   /**< 5G only*/
+    GSW_PREFER_MODE_NR5G_LTE    = 8,   /**< 5G/4G*/
+    GSW_PREFER_MODE_LTE_WCDMA_GSM    = 9,   /**< 4G/3G/2G*/
+    GSW_PREFER_MODE_NR5G_LTE_WCDMA_GSM    = 32,   /**<  5G/4G/3G/2G*/
+} PREFER_MODE_E;
+
+typedef enum gsw_hal_nw_mode_state_type
+{
+    GSW_MODEM_STATE_UNKNOWN = 0,
+    GSW_MODEM_STATE_ONLINE,
+    GSW_MODEM_STATE_OFFLINE,
+    GSW_SDK_STATE_SERVICE_DOWN,
+    GSW_SDK_STATE_SERVICE_UP,// service down->up 需要routectl 重启
+    GSW_SDK_STATE_GPS_DOWN,
+    GSW_SDK_STATE_GPS_UP,
+} gsw_mode_state_e;
+
+
+typedef struct
+{
+    GSW_NW_RADIO_ACCESS_TECH_E   rej_rat;   /**< current network radio tech*/
+    GSW_SERVICE_DOMAIN_E         rej_domain;   /**< reject code from ps or cs*/
+    int                          rej_cause;   /**< reject code number*/
+} GSW_NW_REJ_CAUSE_E;
+
+typedef struct
+{
+    int32_t gw_sig_valid; /**< 1 valid,1 invalid*/
+    int32_t rssi;         /**< Valid values are (0-31, 99) as defined in TS 27.007 8.5 */
+    int32_t wcdma_sig_valid;/**< 1 valid,0 invalid*/
+    int32_t rscp;        /**< The Received Signal Code Power in dBm multipled by -1.
+                      * Range : 25 to 120
+                      * INT_MAX: 0x7FFFFFFF denotes invalid value.
+                      * Reference: 3GPP TS 25.123, section 9.1.1.1 */
+    int32_t ecno;        /**< Valid values are positive integers.  This value is the actual Ec/Io multiplied
+                      * by -10.  Example: If the actual Ec/Io is -12.5 dB, then this response value
+                      * will be 125.*/
+    int32_t lte_sig_valid;/**< 1 valid,0 invalid*/
+    int32_t rsrp;        /**< The current Reference Signal Receive Power in dBm multipled by -1.
+                      * Range: 44 to 140 dBm
+                      * INT_MAX: 0x7FFFFFFF denotes invalid value.
+                      * Reference: 3GPP TS 36.133 9.1.4 */
+    int32_t rsrq;        /**< The current Reference Signal Receive Quality in dB multiplied by -1.
+                      * Range: 20 to 3 dB.
+                      * INT_MAX: 0x7FFFFFFF denotes invalid value.
+                      * Reference: 3GPP TS 36.133 9.1.7 */
+    int32_t rssnr;       /**< The current reference signal signal-to-noise ratio in 0.1 dB units.
+                      * Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB).
+                      * INT_MAX : 0x7FFFFFFF denotes invalid value.
+                      * Reference: 3GPP TS 36.101 8.1.1 */
+    int32_t nr_sig_valid;/**<1 valid,0 invalid*/
+    int32_t ssRsrp;      /**< SS(Synchronization Signal) reference signal received power, multipled by -1.
+                      * Reference: 3GPP TS 38.215.
+                      * Range [44, 140], INT_MAX means invalid/unreported.*/
+    int32_t ssRsrq;      /**< SS reference signal received quality, multipled by -1.
+                      * Reference: 3GPP TS 38.215.
+                      * Range [3, 20], INT_MAX means invalid/unreported.*/
+    int32_t ssSinr;      /**< SS signal-to-noise and interference ratio.
+                      * Reference: 3GPP TS 38.215 section 5.1.*, 3GPP TS 38.133 section 10.1.16.1.
+                      * Range [-23, 40], INT_MAX means invalid/unreported.*/
+    int32_t csiRsrp;     /**< CSI reference signal received power, multipled by -1.
+                      * Reference: 3GPP TS 38.215.
+                      * Range [44, 140], INT_MAX means invalid/unreported.*/
+    int32_t csiRsrq;     /**< CSI reference signal received quality, multipled by -1.
+                      * Reference: 3GPP TS 38.215.
+                      * Range [3, 20], INT_MAX means invalid/unreported.*/
+    int32_t csiSinr;     /**< CSI signal-to-noise and interference ratio.
+                      * Reference: 3GPP TS 138.215 section 5.1.*, 3GPP TS 38.133 section 10.1.16.1.
+                      * Range [-23, 40], INT_MAX means invalid/unreported.*/
+} signalStrength_t;
+
+typedef struct
+{
+    GSW_NW_REG_STATE_E           reg_state;   /**< network cs regstate*/
+    GSW_NW_REG_STATE_E           ps_state;   /**< network ps regstate*/
+    GSW_NW_RADIO_ACCESS_TECH_E   reg_rat;   /**< current radio state*/
+    GSW_SERVICE_DOMAIN_E         srv_domain;   /**< current cs or ps state*/
+    GSW_NW_ROAMING_STATE_E       roaming_ind;   /**< roaming state*/
+    char                         reg_plmn[GSW_NW_PLMN_LEN + 1];   /**< current cell plmn*/
+    char                         operator_name[GSW_NW_OPERATION_NAME_LEN + 1];   /**< operator name*/
+    char                         cell_id[128];   /**< cell id*/
+    char                         tac[128];   /**< cell tac*/
+    char                         lac[128];   /**< cell lac*/
+    int                          sid;   /**< cell sid cdma*/
+    int                          nid;   /**< cell nid cdma*/
+} GSW_NW_SERVING_INFO;
+
+
+typedef struct
+{
+       char long_eons[128];     /* Full name of the operator*/
+       char short_eons[128];      /* Shor name of the operator*/
+       char mcc[4];        /* Mobile country code*/
+       char mnc[4];        /* Mobile network code*/
+}gsw_mobile_operator_name;
+
+#define MAX_CELL_EXT_INFO           (5)
+
+typedef struct
+{
+    unsigned char   cell_id_valid;
+    unsigned char   pci_valid;
+    unsigned char   psc_valid;
+    unsigned char   band_valid;
+    unsigned char   arfcn_valid;
+    unsigned char   rssi_valid;
+    unsigned char   rsrp_valid;
+    unsigned char   rsrq_valid;
+    unsigned char   sinr_valid;
+    unsigned char   rscp_valid;
+    unsigned char   ecio_valid;
+    GSW_NW_RADIO_ACCESS_TECH_E   rat;
+    unsigned int    cell_id;
+    int             pci;
+    int             psc;
+    int             band;
+    int             arfcn;
+    int             rssi;
+    int             rsrp;
+    int             rsrq;
+    int             sinr;
+    int             rscp;
+    int             ecio;
+    char            mcc[5];
+    char            mnc[5];
+} GSW_NW_CELL_EXT_INFO;
+
+typedef struct
+{
+    GSW_NW_RADIO_ACCESS_TECH_E   rat;   /**< current radio state*/
+
+    unsigned char   mcc_valid;
+    char            mcc[5];
+
+    unsigned char   mnc_valid;
+    char            mnc[5];
+
+    unsigned char   cell_id_valid;
+    unsigned int    cell_id;        /**< cell id*/
+
+    unsigned char   pci_valid;
+    int             pci;            /**<physical cell id*/
+
+    unsigned char   psc_valid;
+    int             psc;            /*wcdma primary scramble code*/
+
+    unsigned char   nrarfcn_valid;
+    int             nrarfcn;         /*nr cell freq*/
+
+    unsigned char   earfcn_valid;
+    int             earfcn;         /*lte cell freq*/
+
+    unsigned char   uarfcn_valid;
+    int             uarfcn;         /*wcdma cell freq*/
+
+    unsigned char   arfcn_valid;
+    int             arfcn;          /*gsw cell freq*/
+
+    unsigned char   tac_valid;
+    unsigned int    tac;            /**< cell tac*/
+
+    unsigned char   lac_valid;
+    unsigned int    lac;            /**< cell lac*/
+
+    unsigned char   sid_valid;
+    int             sid;            /**< cell sid cdma*/
+
+    unsigned char   nid_valid;
+    int             nid;            /**< cell nid cdma*/
+
+    unsigned char   lteMode_valid;
+    int             lteMode;        /*tdd 0, fdd 1*/
+
+    unsigned char   rssi_valid;
+    int             rssi;           /**< Valid values are (0-31, 99) as defined in TS 27.007 8.5 */
+
+    unsigned char   rscp_valid;
+    int             rscp;           /**< The Received Signal Code Power in dBm multipled by -1.
+                                      * Range : 25 to 120
+                                      * INT_MAX: 0x7FFFFFFF denotes invalid value.
+                                      * Reference: 3GPP TS 25.123, section 9.1.1.1 */
+
+    unsigned char   ecio_valid;
+    int             ecio;           /**< Valid values are positive integers.  This value is the actual Ec/Io multiplied
+                                      * by -10.  Example: If the actual Ec/Io is -12.5 dB, then this response value
+                                      * will be 125.*/
+
+    unsigned char   rsrp_valid;
+    int             rsrp;           /**< The current Reference Signal Receive Power in dBm multipled by -1.
+                                      * Range: 44 to 140 dBm
+                                      * INT_MAX: 0x7FFFFFFF denotes invalid value.
+                                      * Reference: 3GPP TS 36.133 9.1.4 */
+
+    unsigned char   rsrq_valid;
+    int             rsrq;           /**< The current Reference Signal Receive Quality in dB multiplied by -1.
+                                      * Range: 20 to 3 dB.
+                                      * INT_MAX: 0x7FFFFFFF denotes invalid value.
+                                      * Reference: 3GPP TS 36.133 9.1.7 */
+
+    unsigned char   rssnr_valid;
+    int             rssnr;          /**< The current reference signal signal-to-noise ratio in 0.1 dB units.
+                                      * Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB).
+                                      * INT_MAX : 0x7FFFFFFF denotes invalid value.
+                                      * Reference: 3GPP TS 36.101 8.1.1 */
+
+    unsigned char   band_valid;
+    int             band;
+
+    unsigned char   bler_valid;
+    int             bler;           /*bit error rate*/
+
+    GSW_NW_CELL_EXT_INFO ext_info[MAX_CELL_EXT_INFO];   /* Used to hold neighborhood information for service cells. */
+} GSW_NW_CELL_INFO;
+
+typedef struct {
+    char mcc[GSW_MCC_MAX_LEN];
+    char mnc[GSW_MNC_MAX_LEN];
+} gsw_nw_plmn_t;
+
+
+typedef struct {
+    int plmn_list_len;
+    gsw_nw_plmn_t plmn_list[GSW_PLMN_LIST_MAX_LEN];
+} gsw_nw_plmn_list_t;
+
+typedef struct
+{
+    /*    Configuration parameters for MCM network full band network scan when OOS (out of service)*/
+    int t_min;
+    int t_step;
+    int t_max;
+}GSW_NW_OOS_CONFIG_INFO_T;
+
+typedef void (* GSW_NW_ServingInfoHandlePtr)(GSW_NW_SERVING_INFO serving_info);
+typedef void (* GSW_NW_SigInfoHandlePtr)(signalStrength_t sig_info);
+typedef void (* GSW_NW_RejectCauseHandlePtr)(GSW_NW_REJ_CAUSE_E *rej_cause);
+typedef void (* GSW_HAL_NW_AIRPLANE_MODE_HANDLE_PTR)(int32_t airplane_mode);
+typedef void (* GSW_NW_ModemStateHandlePtr)(gsw_mode_state_e state);
+
+int (*gsw_reg_serving_info_callback)(GSW_NW_ServingInfoHandlePtr handle_ptr);
+int (*gsw_reg_sig_info_callback)(GSW_NW_SigInfoHandlePtr handle_ptr);
+int (*gsw_reg_rej_cause_callback)(GSW_NW_RejectCauseHandlePtr handle_ptr);
+int (*gsw_nw_sdk_init)(int token);
+int (*gsw_nw_sdk_deinit)(void);
+int (*gsw_get_nwinfo)(GSW_NW_SERVING_INFO *serving_info);
+int (*gsw_get_netype)(int32_t *netype);
+int (*gsw_get_opmode)(int *op_mode);
+int (*gsw_set_opmode)(int32_t op_mode);
+int (*gsw_get_mode_preference)(int32_t *mode_pref);
+int (*gsw_set_mode_preference)(int32_t mode_pref);
+int (*gsw_get_sig_info)(int32_t *csq_value);
+int (*gsw_network_set_power_mode)(int8_t mode);
+int (*gsw_sigInfo_to_csq)(int32_t netType, int32_t sigValue);
+int (*gsw_get_forbidden_networks)(gsw_nw_plmn_list_t *plmn_list);
+int (*gsw_add_forbidden_networks)(gsw_nw_plmn_list_t *plmn_list);
+int (*gsw_remove_forbidden_networks)(gsw_nw_plmn_list_t *plmn_list);
+int (*gsw_clear_forbidden_networks)(void);
+int (*gsw_get_mobile_operator_name)(gsw_mobile_operator_name *nw_operator_name_infos);
+int (*gsw_reg_set_modem_status_event_callback)(GSW_NW_ModemStateHandlePtr handle_ptr);
+int (*gsw_get_cell_info)(GSW_NW_CELL_INFO *cell_info);
+int (*gsw_oos_config_get)(GSW_NW_OOS_CONFIG_INFO_T *pt_info);
+int (*gsw_oos_config_set)(GSW_NW_OOS_CONFIG_INFO_T *pt_info);
+
+
+static int gsw_nw_api_import()
+{
+    dlHandle_nw = dlopen(lib_gsw_nw_path, RTLD_NOW);
+    if (dlHandle_nw == NULL) {
+        printf("error: %s\n", dlerror());
+        return -1;
+    }
+
+    gsw_nw_sdk_init = (int(*)(int token))dlsym(dlHandle_nw, "gsw_nw_sdk_init");
+    if (gsw_nw_sdk_init == NULL) {
+        printf("gsw_nw_sdk_init dlysm failed \n");
+        return -1;
+    }
+
+    gsw_nw_sdk_deinit = (int(*)(void))dlsym(dlHandle_nw, "gsw_nw_sdk_deinit");
+    if (gsw_nw_sdk_deinit == NULL) {
+        printf("gsw_nw_sdk_deinit dlysm failed \n");
+        return -1;
+    }
+
+    gsw_get_nwinfo = (int(*)(GSW_NW_SERVING_INFO *serving_info))dlsym(dlHandle_nw, "gsw_get_nwinfo");
+    if (gsw_get_nwinfo == NULL) {
+        printf("gsw_get_nwinfo dlysm failed \n");
+        return -1;
+    }
+
+    gsw_get_netype = (int(*)(int32_t *netype))dlsym(dlHandle_nw, "gsw_get_netype");
+    if (gsw_get_netype == NULL) {
+        printf("gsw_get_netype dlysm failed \n");
+        return -1;
+    }
+
+    gsw_get_opmode = (int(*)(int *op_mode))dlsym(dlHandle_nw, "gsw_get_opmode");
+    if (gsw_get_opmode == NULL) {
+        printf("gsw_get_opmode dlysm failed \n");
+        return -1;
+    }
+
+    gsw_set_opmode = (int(*)(int32_t op_mode))dlsym(dlHandle_nw, "gsw_set_opmode");
+    if (gsw_set_opmode == NULL) {
+        printf("gsw_set_opmode dlysm failed \n");
+        return -1;
+    }
+
+    gsw_get_mode_preference = (int(*)(int32_t *mode_pref))dlsym(dlHandle_nw, "gsw_get_mode_preference");
+    if (gsw_get_mode_preference == NULL) {
+        printf("gsw_get_mode_preference dlysm failed \n");
+        return -1;
+    }
+
+    gsw_set_mode_preference = (int(*)(int32_t mode_pref))dlsym(dlHandle_nw, "gsw_set_mode_preference");
+    if (gsw_set_mode_preference == NULL) {
+        printf("gsw_set_mode_preference dlysm failed \n");
+        return -1;
+    }
+
+    gsw_get_sig_info = (int(*)(int32_t *csq_value))dlsym(dlHandle_nw, "gsw_get_sig_info");
+    if (gsw_get_sig_info == NULL) {
+        printf("gsw_get_sig_info dlysm failed \n");
+        return -1;
+    }
+
+    gsw_network_set_power_mode = (int(*)(int8_t mode))dlsym(dlHandle_nw, "gsw_network_set_power_mode");
+    if (gsw_network_set_power_mode == NULL) {
+        printf("gsw_network_set_power_mode dlysm failed \n");
+        return -1;
+    }
+
+    gsw_sigInfo_to_csq = (int(*)(int32_t netType, int32_t sigValue))dlsym(dlHandle_nw, "gsw_sigInfo_to_csq");
+    if (gsw_sigInfo_to_csq == NULL) {
+        printf("gsw_sigInfo_to_csq dlysm failed \n");
+        return -1;
+    }
+
+    gsw_get_forbidden_networks = (int(*)(gsw_nw_plmn_list_t *plmn_list))dlsym(dlHandle_nw, "gsw_get_forbidden_networks");
+    if (gsw_get_forbidden_networks == NULL) {
+        printf("gsw_get_forbidden_networks dlysm failed \n");
+        return -1;
+    }
+
+    gsw_add_forbidden_networks = (int(*)(gsw_nw_plmn_list_t *plmn_list))dlsym(dlHandle_nw, "gsw_add_forbidden_networks");
+    if (gsw_add_forbidden_networks == NULL) {
+        printf("gsw_add_forbidden_networks dlysm failed \n");
+        return -1;
+    }
+
+    gsw_remove_forbidden_networks = (int(*)(gsw_nw_plmn_list_t *plmn_list))dlsym(dlHandle_nw, "gsw_remove_forbidden_networks");
+    if (gsw_remove_forbidden_networks == NULL) {
+        printf("gsw_remove_forbidden_networks dlysm failed \n");
+        return -1;
+    }
+
+    gsw_clear_forbidden_networks = (int(*)(void))dlsym(dlHandle_nw, "gsw_clear_forbidden_networks");
+    if (gsw_clear_forbidden_networks == NULL) {
+        printf("gsw_clear_forbidden_networks dlysm failed \n");
+        return -1;
+    }
+
+    gsw_get_mobile_operator_name = (int(*)(gsw_mobile_operator_name *nw_operator_name_infos))dlsym(dlHandle_nw, "gsw_get_mobile_operator_name");
+    if (gsw_get_mobile_operator_name == NULL) {
+        printf("gsw_get_mobile_operator_name dlysm failed \n");
+        return -1;
+    }
+
+    gsw_reg_set_modem_status_event_callback = (int(*)(GSW_NW_ModemStateHandlePtr handle_ptr))dlsym(dlHandle_nw, "gsw_reg_set_modem_status_event_callback");
+    if (gsw_reg_set_modem_status_event_callback == NULL) {
+        printf("gsw_reg_set_modem_status_event_callback dlysm failed \n");
+        return -1;
+    }
+
+    gsw_get_cell_info = (int(*)(GSW_NW_CELL_INFO *cell_info))dlsym(dlHandle_nw, "gsw_get_cell_info");
+    if (gsw_get_cell_info == NULL) {
+        printf("gsw_get_cell_info dlysm failed \n");
+        return -1;
+    }
+
+    gsw_reg_serving_info_callback = (int(*)(GSW_NW_ServingInfoHandlePtr handle_ptr))dlsym(dlHandle_nw, "gsw_reg_serving_info_callback");
+    if (gsw_reg_serving_info_callback == NULL) {
+        printf("gsw_reg_serving_info_callback dlysm failed \n");
+        return -1;
+    }
+
+    gsw_reg_sig_info_callback = (int(*)(GSW_NW_SigInfoHandlePtr handle_ptr))dlsym(dlHandle_nw, "gsw_reg_sig_info_callback");
+    if (gsw_reg_sig_info_callback == NULL) {
+        printf("gsw_reg_sig_info_callback dlysm failed \n");
+        return -1;
+    }
+
+    gsw_reg_rej_cause_callback = (int(*)(GSW_NW_RejectCauseHandlePtr handle_ptr))dlsym(dlHandle_nw, "gsw_reg_rej_cause_callback");
+    if (gsw_reg_rej_cause_callback == NULL) {
+        printf("gsw_reg_rej_cause_callback dlysm failed \n");
+        return -1;
+    }
+
+    gsw_oos_config_get = (int(*)(GSW_NW_OOS_CONFIG_INFO_T *oos_config))dlsym(dlHandle_nw, "gsw_oos_config_get");
+    if (gsw_oos_config_get == NULL) {
+        printf("gsw_oos_config_get dlysm failed \n");
+        return -1;
+    }
+
+    gsw_oos_config_set = (int(*)(GSW_NW_OOS_CONFIG_INFO_T *oos_config))dlsym(dlHandle_nw, "gsw_oos_config_set");
+    if (gsw_oos_config_set == NULL) {
+        printf("gsw_oos_config_set dlysm failed \n");
+        return -1;
+    }
+
+    return 0;
+
+}
+
+static void gsw_serving_info_callback(GSW_NW_SERVING_INFO serving_info)
+{
+    printf("gsw_serving_info_callback: \n");
+    printf("reg_state = %d\n", serving_info.reg_state);
+    printf("ps_state = %d\n", serving_info.ps_state);
+    printf("reg_rat = %d\n", serving_info.reg_rat);
+    printf("srv_domain = %d\n", serving_info.srv_domain);
+    printf("roaming_ind = %d\n", serving_info.roaming_ind);
+    printf("reg_plmn = %s\n", serving_info.reg_plmn);
+    printf("operator_name = %s\n", serving_info.operator_name);
+    printf("cell_id = %s\n", serving_info.cell_id);
+    printf("tac = %s\n", serving_info.tac);
+    printf("lac = %s\n", serving_info.lac);
+    printf("sid = %d\n", serving_info.sid);
+    printf("nid = %d\n", serving_info.nid);
+}
+
+static void gsw_sig_info_callback(signalStrength_t sig_info)
+{
+    printf("gsw_sig_info_callback: \n");
+    printf("gw_sig_valid = %d\n", sig_info.gw_sig_valid);
+    printf("rssi = %d\n", sig_info.rssi);
+    printf("wcdma_sig_valid = %d\n", sig_info.wcdma_sig_valid);
+    printf("rscp = %d\n", sig_info.rscp);
+    printf("ecno = %d\n", sig_info.ecno);
+    printf("lte_sig_valid = %d\n", sig_info.lte_sig_valid);
+    printf("rsrp = %d\n", sig_info.rsrp);
+    printf("rsrq = %d\n", sig_info.rsrq);
+    printf("rssnr = %d\n", sig_info.rssnr);
+    printf("nr_sig_valid = %d\n", sig_info.nr_sig_valid);
+    printf("ssRsrp = %d\n", sig_info.ssRsrp);
+    printf("ssRsrq = %d\n", sig_info.ssRsrq);
+    printf("ssSinr = %d\n", sig_info.ssSinr);
+    printf("csiRsrp = %d\n", sig_info.csiRsrp);
+    printf("csiRsrq = %d\n", sig_info.csiRsrq);
+    printf("csiSinr = %d\n", sig_info.csiSinr);
+}
+
+static void gsw_rej_cause_callback(GSW_NW_REJ_CAUSE_E *rej_cause)
+{
+    printf("gsw_rej_cause_callback: \n");
+    printf("rej_rat = %d\n", rej_cause->rej_rat);
+    printf("rej_domain = %d\n", rej_cause->rej_domain);
+    printf("rej_cause = %d\n", rej_cause->rej_cause);
+}
+
+static void gsw_modem_status_cb(gsw_mode_state_e state)
+{
+    printf("gsw_modem_status_cb: \n");
+    printf("state = %d\n", state);
+}
+
+
+void dump_items()
+{
+    printf("\n");
+    printf("The current module is: network \n");
+
+    printf("-------------------------------------------------------------------------\n");
+    printf("|  index | function name                                              |\n");
+    printf("|  -1       exit\n");
+    printf("   1       gsw_nw_sdk_init\n");
+    printf("   2       gsw_nw_sdk_deinit\n");
+    printf("   3       gsw_get_nwinfo\n");
+    printf("   4       gsw_get_netype\n");
+    printf("   5       gsw_get_opmode\n");
+    printf("   6       gsw_set_opmode\n");
+    printf("   7       gsw_get_mode_preference\n");
+    printf("   8       gsw_set_mode_preference\n");
+    printf("   9       gsw_get_sig_info\n");
+    printf("   10      gsw_network_set_power_mode\n");
+    printf("   11      gsw_sigInfo_to_csq\n");
+    printf("   12      gsw_get_forbidden_networks\n");
+    printf("   13      gsw_add_forbidden_networks\n");
+    printf("   14      gsw_remove_forbidden_networks\n");
+    printf("   15      gsw_clear_forbidden_networks\n");
+    printf("   16      gsw_get_mobile_operator_name\n");
+    printf("   17      gsw_reg_set_modem_status_event_callback\n");
+    printf("   18      gsw_get_cell_info\n");
+    printf("   19      gsw_reg_serving_info_callback\n");
+    printf("   20      gsw_reg_sig_info_callback\n");
+    printf("   21      gsw_reg_rej_cause_callback\n");
+    printf("   22      gsw_oos_config_get\n");
+    printf("   23      gsw_oos_config_set\n");
+    printf("-------------------------------------------------------------------------\n");
+}
+
+int main(int argc, char *argv[])
+{
+    int ret;
+    char operator[10];
+    int opt;
+
+    ret = gsw_nw_api_import();
+    if (ret != 0) {
+        printf("gsw_nw_api_import failed \n");
+        return -1;
+    }
+    
+
+    while(1)
+    {
+        dump_items();
+        printf("input the index of module: ");
+
+        opt = -1;
+        printf("%s",fgets(operator, sizeof(operator), stdin));
+        fflush(stdin);
+
+        opt = atoi(operator);
+        switch (opt) {
+        case -1:
+        {
+            printf("main exit\n");
+            return 0;
+        }
+        case 1:
+        {
+            printf("gsw_nw_sdk_init\n");
+            ret = gsw_nw_sdk_init(1024);
+            printf("gsw_nw_sdk_init ret = %d\n",ret);
+            break;
+        }
+        case 2:
+        {
+            printf("gsw_nw_sdk_deinit\n");
+            ret = gsw_nw_sdk_deinit();
+            printf("gsw_nw_sdk_deinit ret = %d\n",ret);
+            break;
+        }
+        case 3:
+        {
+            GSW_NW_SERVING_INFO* nwinfo;
+            nwinfo = (GSW_NW_SERVING_INFO*)malloc(sizeof(GSW_NW_SERVING_INFO));
+            memset(nwinfo, 0x00, sizeof(GSW_NW_SERVING_INFO));
+            printf("gsw_get_nwinfo start\n");
+            ret = gsw_get_nwinfo(nwinfo);
+            if(ret != 0)
+            {
+                printf("gsw_get_nwinfo failed \n");
+                continue;
+            }
+            printf("nwinfo.reg_state = %d\nnwinfo.ps_state = %d\nnwinfo.reg_rat = %d\nnwinfo.srv_domain = %d\nnwinfo.roaming_ind = %d\nnwinfo.reg_plmn = %s\nnwinfo.operator_name = %s\nnwinfo.cell_id = %s\nnwinfo.lac = %s\nnwinfo.sid=%d\nnwinfo.nid = %d\n",nwinfo->reg_state, nwinfo->ps_state, nwinfo->reg_rat, nwinfo->srv_domain, nwinfo->roaming_ind, nwinfo->reg_plmn, nwinfo->operator_name, nwinfo->cell_id, nwinfo->lac, nwinfo->sid, nwinfo->nid);
+            free(nwinfo);
+            break;
+        }
+        case 4:
+        {
+            int nettype;
+            ret = gsw_get_netype(&nettype);
+            if(ret != 0)
+            {
+                printf("gsw_get_netype failed \n");
+                continue;
+            }
+            printf("nettype = %d\n", nettype);
+            break;
+        }
+
+        case 5:
+        {
+            int opmode;
+            ret = gsw_get_opmode(&opmode);
+            if(ret != 0)
+            {
+                printf("gsw_get_opmode failed \n");
+                continue;
+            }
+            printf("opmode = %d\n", opmode);
+            break;
+        }
+
+        case 6:
+        {
+            printf("input the opmode: ");
+            memset(operator,0x00, sizeof(operator));
+            printf("%s\n",fgets(operator, sizeof(operator)-1, stdin));
+            fflush(stdin);
+            opt = atoi(operator);
+            ret = gsw_set_opmode(opt);
+            if(ret != 0)
+            {
+                printf("gsw_set_opmode failed \n");
+                continue;
+            }
+            break;
+        }
+
+        case 7:
+        {
+            int mode_pref;
+            ret = gsw_get_mode_preference(&mode_pref);
+            if(ret != 0)
+            {
+                printf("gsw_get_mode_preference failed \n");
+                continue;
+            }
+            printf("mode_pref = %d\n", mode_pref);
+            break;
+        }
+
+        case 8:
+        {
+            printf("input the mode_pref: ");
+            memset(operator,0x00, sizeof(operator));
+            printf("%s\n",fgets(operator, sizeof(operator)-1, stdin));
+            fflush(stdin);
+            opt = atoi(operator);
+            ret = gsw_set_mode_preference(opt);
+            if(ret != 0)
+            {
+                printf("gsw_set_mode_preference failed \n");
+                continue;
+            }
+            break;
+        }
+
+        case 9:
+        {
+            int siginfo;
+            ret = gsw_get_sig_info(&siginfo);
+            if(ret != 0)
+            {
+                printf("gsw_get_sig_info failed \n");
+                continue;
+            }
+            printf("signal info: siginfo = %d\n", siginfo);
+            break;
+        }
+            
+        case 10:
+        {
+            printf("input the power mode: ");
+            memset(operator,0x00, sizeof(operator));
+            printf("%s\n",fgets(operator, sizeof(operator)-1, stdin));
+            fflush(stdin);
+            opt = atoi(operator);
+            ret = gsw_network_set_power_mode(opt);
+            if(ret != 0)
+            {
+                printf("gsw_network_set_power_mode failed \n");
+                continue;
+            }
+            break;
+        }
+
+        case 11:
+        {
+            int nettype;
+            int sigValue;
+            printf("please input the netType:");
+            memset(operator,0x00, sizeof(operator));
+            printf("%s\n",fgets(operator, sizeof(operator)-1, stdin));
+            fflush(stdin);
+            nettype = atoi(operator);
+
+            printf("input the sigValue: ");
+            memset(operator,0x00, sizeof(operator));
+            printf("%s\n",fgets(operator, sizeof(operator)-1, stdin));
+            fflush(stdin);
+            sigValue = atoi(operator);
+
+            ret = gsw_sigInfo_to_csq(nettype, sigValue);
+            printf("csq = %d\n", ret);
+
+            break;
+        }
+
+        case 12:
+        {
+            printf("gsw_get_forbidden_networks start\n");
+            gsw_nw_plmn_list_t fplmn_list;
+            fplmn_list.plmn_list_len = 0;
+            ret = gsw_get_forbidden_networks(&fplmn_list);
+            if(ret != 0)
+            {
+                printf("gsw_get_forbidden_networks failed \n");
+                continue;
+            }
+
+            printf("gsw_get_forbidden_networks end\n");
+            for(int i = 0; i < fplmn_list.plmn_list_len; i++)
+            {
+                printf("list[%d] mcc = %s,mnc = %s\n",i, fplmn_list.plmn_list[i].mcc, fplmn_list.plmn_list[i].mnc);
+            }
+
+            break;
+        }
+        case 13:
+        {
+            printf("gsw_add_forbidden_networks start\n");
+            gsw_nw_plmn_list_t fplmn_list_set;
+            fplmn_list_set.plmn_list_len = 1;
+            strcpy(fplmn_list_set.plmn_list[0].mcc, "460");
+            strcpy(fplmn_list_set.plmn_list[0].mnc, "09");
+
+            ret = gsw_add_forbidden_networks(&fplmn_list_set);
+            if(ret != 0)
+            {
+                printf("gsw_add_forbidden_networks failed \n");
+                continue;
+            }
+            printf("gsw_add_forbidden_networks end\n");
+            break;
+        }
+        case 14:
+        {
+            printf("gsw_add_forbidden_networks start\n");
+            gsw_nw_plmn_list_t fplmn_list_remove;
+            fplmn_list_remove.plmn_list_len = 1;
+            strcpy(fplmn_list_remove.plmn_list[0].mcc, "460");
+            strcpy(fplmn_list_remove.plmn_list[0].mnc, "02");
+
+            ret = gsw_remove_forbidden_networks(&fplmn_list_remove);
+            if(ret != 0)
+            {
+                printf("gsw_add_forbidden_networks failed \n");
+                continue;
+            }
+            printf("gsw_add_forbidden_networks end\n");
+            break;
+        }
+            
+        case 15:
+        {
+            printf("gsw_clear_forbidden_networks start\n");
+            ret = gsw_clear_forbidden_networks();
+            if(ret != 0)
+            {
+                printf("gsw_clear_forbidden_networks failed \n");
+                continue;
+            }
+            printf("gsw_clear_forbidden_networks end\n");
+            break;
+        }
+
+        case 16:
+        {
+            gsw_mobile_operator_name opname;
+
+            ret = gsw_get_mobile_operator_name(&opname);
+            if(ret != 0)
+            {
+                printf("gsw_get_mobile_operator_name failed \n");
+                continue;
+            }
+
+            printf("opname.operator_name = %s\nopname.operator_code = %s\nopname.mcc=%s\nopname.mnc=%s", opname.long_eons, opname.short_eons, opname.mcc, opname.mnc);
+            break;
+        }
+
+        case 17:
+        {
+            printf("gsw_reg_set_modem_status_event_callback\n");
+            ret = gsw_reg_set_modem_status_event_callback(gsw_modem_status_cb);
+            if(ret != 0)
+            {
+                printf("gsw_reg_set_modem_status_event_callback failed \n");
+                continue;
+            }
+            printf("gsw_reg_set_modem_status_event_callback success\n");
+            break;
+        }
+
+        case 18:
+        {
+            printf("gsw_get_cell_info starts\n");
+            GSW_NW_CELL_INFO cell_info;
+            memset(&cell_info, 0x00, sizeof(GSW_NW_CELL_INFO));
+            ret = gsw_get_cell_info(&cell_info);
+            if(ret != 0)
+            {
+                printf("gsw_get_cell_info failed \n");
+                continue;
+            }
+            
+            printf("--------------------serving cell info ------------------------------\n");
+            printf("mcc_valid = %d\n",cell_info.mcc_valid);
+            printf("mcc = %s\n",cell_info.mcc);
+            printf("mnc_valid = %d\n",cell_info.mnc_valid);
+            printf("mnc = %s\n",cell_info.mnc);
+            printf("cell_id_valid = %d\n",cell_info.cell_id_valid);
+            printf("cell_id = %u\n",cell_info.cell_id);
+            printf("pci_valid = %d\n",cell_info.pci_valid);
+            printf("pci = %d\n",cell_info.pci);
+            printf("psc_valid = %d\n",cell_info.psc_valid);
+            printf("psc = %d\n",cell_info.psc);
+            printf("earfcn_valid = %d\n",cell_info.earfcn_valid);
+            printf("earfcn = %d\n",cell_info.earfcn);
+            printf("uarfcn_valid = %d\n",cell_info.uarfcn_valid);
+            printf("uarfcn = %d\n",cell_info.uarfcn);
+            printf("arfcn_valid = %d\n",cell_info.arfcn_valid);
+            printf("arfcn = %d\n",cell_info.arfcn);
+            printf("tac_valid = %d\n",cell_info.tac_valid);
+            printf("tac = %u\n",cell_info.tac);
+            printf("lac_valid = %d\n",cell_info.lac_valid);
+            printf("lac = %u\n",cell_info.lac);
+            printf("sid_valid = %d\n",cell_info.sid_valid);
+            printf("sid = %d\n",cell_info.sid);
+            printf("nid_valid = %d\n",cell_info.nid_valid);
+            printf("nid = %d\n",cell_info.nid);
+            printf("lteMode_valid = %d\n",cell_info.lteMode_valid);
+            printf("lteMode = %d\n",cell_info.lteMode);
+            printf("rssi_valid = %d\n",cell_info.rssi_valid);
+            printf("rssi = %d\n",cell_info.rssi);
+            printf("rsrq_valid = %d\n",cell_info.rsrq_valid);
+            printf("rsrq = %d\n",cell_info.rsrq);
+            printf("ecio_valid = %d\n",cell_info.ecio_valid);
+            printf("ecio = %d\n",cell_info.ecio);
+            printf("rsrp_valid = %d\n",cell_info.rsrp_valid);
+            printf("rsrp = %d\n",cell_info.rsrp);
+            printf("rsrq_valid = %d\n",cell_info.rsrq_valid);
+            printf("rsrq = %d\n",cell_info.rsrq);
+            printf("rssnr_valid = %d\n",cell_info.rssnr_valid);
+            printf("rssnr = %d\n",cell_info.rssnr);
+            printf("band_valid = %d\n",cell_info.band_valid);
+            printf("band = %d\n",cell_info.band);
+            printf("bler_valid = %d\n",cell_info.bler_valid);
+            printf("bler = %d\n",cell_info.bler);
+
+
+            printf("-----------------------------------------------------------------------------------\n");
+
+            printf("-------------------------------------inter cell info ------------------------------\n");
+
+            for(int i = 0; i <MAX_CELL_EXT_INFO ; i++)
+            {
+                printf("-----------------------------------------------------------\n");
+                printf("inter cell info[%d] rat = %d\n",i,cell_info.ext_info[i].rat);
+
+                printf("inter cell info[%d] mcc = %s\n",i,cell_info.ext_info[i].mcc);
+
+                printf("inter cell info[%d] mnc = %s\n",i,cell_info.ext_info[i].mnc);
+
+                printf("inter cell info[%d] pci_valid = %d\n",i,cell_info.ext_info[i].pci_valid);
+                printf("inter cell info[%d] pci = %d\n",i,cell_info.ext_info[i].pci);
+
+                printf("inter cell info[%d] arfcn_valid = %d\n",i,cell_info.ext_info[i].arfcn_valid);
+                printf("inter cell info[%d] arfcn = %d\n",i,cell_info.ext_info[i].arfcn);
+
+                printf("inter cell info[%d] rsrp_valid = %d\n",i,cell_info.ext_info[i].rsrp_valid);
+                printf("inter cell info[%d] rsrp = %d\n",i,cell_info.ext_info[i].rsrp);
+                
+                printf("inter cell info[%d] rsrq_valid = %d\n",i,cell_info.ext_info[i].rsrq_valid);
+                printf("inter cell info[%d] rsrq = %d\n",i,cell_info.ext_info[i].rsrq);
+
+                printf("inter cell info[%d] cell_id_valid = %d\n",i,cell_info.ext_info[i].cell_id_valid);
+                printf("inter cell info[%d] cell_id = %u\n",i,cell_info.ext_info[i].cell_id);
+
+                printf("inter cell info[%d] band_valid = %d\n",i,cell_info.ext_info[i].band_valid);
+                printf("inter cell info[%d] band = %u\n",i,cell_info.ext_info[i].band);
+
+                printf("-----------------------------------------------------------\n");
+            }
+
+
+            break;
+        }
+
+        case 19:
+        {
+            printf("gsw_reg_serving_info_callback start\n");
+            ret = gsw_reg_serving_info_callback(gsw_serving_info_callback);
+            break;
+        }
+
+        case 20:
+        {
+            printf("gsw_reg_sig_info_callback start\n");
+            ret = gsw_reg_sig_info_callback(gsw_sig_info_callback);
+            break;
+        }
+
+        case 21:
+        {
+            printf("gsw_reg_rej_cause_callback\n");
+            ret = gsw_reg_rej_cause_callback(gsw_rej_cause_callback);
+            break;
+        }
+
+        case 22:
+        {
+            printf("gsw_oos_config_get\n");
+            GSW_NW_OOS_CONFIG_INFO_T oos_cfg;
+            ret = gsw_oos_config_get(&oos_cfg);
+            if(ret != 0)
+            {
+                printf("gsw_oos_config_get failed \n");
+                continue;
+            }
+
+            else
+            {
+                printf("oos_cfg.t_min = %d\n",oos_cfg.t_min);
+                printf("oos_cfg.t_max = %d\n",oos_cfg.t_max);
+                printf("oos_cfg.t_step = %d\n",oos_cfg.t_step);
+            }
+            break;
+        }
+
+        case 23:
+        {
+            printf("gsw_oos_config_set\n");
+            GSW_NW_OOS_CONFIG_INFO_T oos_cfg;
+            oos_cfg.t_min = 5;
+            oos_cfg.t_step = 5;
+            oos_cfg.t_max = 5;
+
+            ret = gsw_oos_config_set(&oos_cfg);
+            if(ret != 0)
+            {
+                printf("gsw_oos_config_set failed \n");
+                continue;
+            }
+            else
+            {
+                printf("gsw_oos_config_set success\n");
+            }
+            break;
+        }
+
+
+        default:
+        {
+            continue;
+        }
+
+
+        }
+    }
+
+
+}
diff --git a/mbtk/test/libgsw_lib/gsw_oem_rw_test.c b/mbtk/test/libgsw_lib/gsw_oem_rw_test.c
new file mode 100755
index 0000000..723c0c6
--- /dev/null
+++ b/mbtk/test/libgsw_lib/gsw_oem_rw_test.c
@@ -0,0 +1,181 @@
+#include <stdio.h>

+#include <stdlib.h>

+#include <string.h>

+#include <time.h>

+#include <fcntl.h>

+#include <unistd.h>

+#include <sys/ioctl.h>

+#include <mtd/mtd-user.h>

+#include <errno.h>

+

+#include "gsw_oem_rw_interface.h"

+

+

+#define FLASH_DEVICE    "/dev/mtd32"

+

+

+

+#define TEST_BLOCK_ID 1  // 测试使用的block ID

+

+void print_usage(void)

+{

+    printf("Usage:\n");

+    printf("  1: Write test data to block\n");

+    printf("  2: Read data from block\n");

+    printf("  0: Exit\n");

+    printf("Please input your choice: ");

+}

+

+int write_test(void)

+{

+    int ret;

+    struct mtd_info_user mtd_info;

+    int fd;

+    char *write_buf = NULL;

+    unsigned int max_write_size;

+

+

+    fd = open(FLASH_DEVICE, O_RDONLY);

+    if (fd == -1) {

+        printf("Error opening flash device: %s\n", strerror(errno));

+        return GSW_HAL_NORMAL_FAIL;

+    }

+

+    if (ioctl(fd, MEMGETINFO, &mtd_info) < 0) {

+        printf("Error getting MTD info: %s\n", strerror(errno));

+        close(fd);

+        return GSW_HAL_NORMAL_FAIL;

+    }

+    

+    close(fd);

+    

+    max_write_size = mtd_info.erasesize;

+    printf("MTD erase size: %u bytes\n", max_write_size);

+

+   

+    write_buf = (char *)malloc(max_write_size);

+    if (write_buf == NULL) 

+    {

+        printf("Failed to allocate write buffer\n");

+        return -1;

+    }

+    

+    int block_id = -1;

+    printf("enter block id \n");

+    ret = scanf("%d",&block_id);

+     memset(write_buf, 0, max_write_size);

+    snprintf(write_buf, max_write_size, "Test data for block %d, timestamp: %d", 

+             block_id, (int)time(NULL));

+    printf("Write data: %s\n", write_buf);

+    printf("Writing data to block %d...\n", block_id);

+    ret = gsw_oem_write_data_ext(block_id, write_buf, max_write_size);

+    if (ret != GSW_HAL_SUCCESS) 

+    {

+        printf("Write failed with error: %d\n", ret);

+    } 

+    else

+    {

+        printf("Write successful\n");

+    }

+

+    free(write_buf);

+    return ret;

+}

+

+int read_test(void)

+{

+    int ret;

+    unsigned int read_len = 0;

+    struct mtd_info_user mtd_info;

+    int fd;

+    char *read_buf = NULL;

+    unsigned int max_read_size;

+

+

+    fd = open(FLASH_DEVICE, O_RDONLY);

+    if (fd == -1) {

+        printf("Error opening flash device: %s\n", strerror(errno));

+        return GSW_HAL_NORMAL_FAIL;

+    }

+

+    if (ioctl(fd, MEMGETINFO, &mtd_info) < 0) {

+        printf("Error getting MTD info: %s\n", strerror(errno));

+        close(fd);

+        return GSW_HAL_NORMAL_FAIL;

+    }

+    

+    close(fd);

+    

+    max_read_size = mtd_info.erasesize;

+    printf("MTD erase size: %u bytes\n", max_read_size);

+

+

+    read_buf = (char *)malloc(max_read_size);

+    if (read_buf == NULL) 

+    {

+        printf("Failed to allocate read buffer\n");

+        return -1;

+    }

+

+    memset(read_buf, 0, max_read_size);

+

+    int block_id = -1;

+    printf("enter block id \n");

+    ret = scanf("%d",&block_id);

+    printf("Reading data from block %d...\n", block_id);

+    

+    ret = gsw_oem_read_data_ext(block_id, read_buf, &read_len);

+    if (ret != GSW_HAL_SUCCESS) 

+    {

+        printf("Read failed with error: %d\n", ret);

+    }

+    else 

+    {

+        printf("Read %u bytes\n", read_len);

+        printf("Read data: %s\n", read_buf);

+    }

+    free(read_buf);  

+    return ret;

+}

+

+int main()

+{

+    int choice;

+    int ret = 0;

+

+    while (1) 

+    {

+        print_usage();

+        if (scanf("%d", &choice) != 1) 

+        {

+            printf("Invalid input\n");

+           

+            while (getchar() != '\n');

+            continue;

+        }

+

+       

+        while (getchar() != '\n');

+

+        switch (choice) 

+        {

+            case 0:

+                printf("Exit\n");

+                return 0;

+            case 1:

+                ret = write_test();

+                break;

+            case 2:

+                ret = read_test();

+                break;

+            default:

+                printf("Invalid choice\n");

+                break;

+        }

+

+        printf("\n");

+    }

+

+    return ret;

+}

+

diff --git a/mbtk/test/libgsw_lib/gsw_ota_test.c b/mbtk/test/libgsw_lib/gsw_ota_test.c
new file mode 100755
index 0000000..99531e9
--- /dev/null
+++ b/mbtk/test/libgsw_lib/gsw_ota_test.c
@@ -0,0 +1,385 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+#include <signal.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <dlfcn.h>
+
+typedef struct
+{
+    int cmdIdx;
+    char *funcName;
+}st_api_test_case;
+
+
+
+typedef enum 
+{
+    GSW_OTA_SUCCESS,
+    GSW_OTA_FAILURE,
+    GSW_OTA_TIMEOUT,
+    GSW_OTA_INPROCESS,
+    GSW_OTA_NO_TASK
+}E_GSW_OTA_RET;
+
+typedef enum _gsw_ota_ret
+{
+    GSW_OTA_SYSTEM_A,
+    GSW_OTA_SYSTEM_B,
+}E_GSW_OTA_SYSTEM;
+
+
+typedef enum
+{
+    GSW_UPDATE_SUCCEED = 0, //update succeed
+    GSW_UPDATE_INPROGRESS,  //update in progress
+    GSW_UPDATE_BACKUP,      //A/B partition sync in progress
+    GSW_UPDATE_FAILED,      //update failed
+    GSW_UPDATE_WAITEDONE,   //update in-active part finished,not switch update part.
+    GSW_UPDATE_NEEDSYNC,    //switch update part, need sync A/B part
+    GSW_UPDATE_CANCEL       //updata cancel success
+}gsw_update_state_t;
+
+typedef enum
+{
+    GSW_UPDATE_NOERROR=0,          //升级成功
+    GSW_UPDATE_ARGUMENTERROR,      //升级程序启动参数错误
+    GSW_UPDATE_SDCARDNOEXIST,      //未挂载外置FLASH等存储设备
+    GSW_UPDATE_PACKAGENOEXIST,     //升级包不存在
+    GSW_UPDATE_UNZIPFAILED,        //解压升级包出错
+    GSW_UPDATE_PARTITIONFLUSHERROR,//写入分区出错
+    GSW_UPDATE_XMLPARSEERROR,      //解析 fotaconfig.xml 文件出错
+    GSW_UPDATE_DIFFUBIUNATTACH,    //差分升级 UBI 分区挂载异常
+    GSW_UPDATE_NOSPACELEFT,        //空间不足
+    GSW_UPDATE_FILECHECKFAILED,    //MD5 值校验失败
+    GSW_UPDATE_BSPATCHFAILED,      //bspatch 合成新文件夹失败
+    GSW_UPDATE_NOFINDPARTITION,    //待升级分区不存在
+    GSW_UPDATE_UBIVOLUMEERROR,      //差分升级,待升级 UBI 卷不存在
+    GSW_UPDATE_NOFOTACONFIGFILE,   //升级包中无 fotaconfig.xml 文件
+    GSW_UPDATE_GETOLDSOFTWAREFAILED,//读取原始版本固件失败
+    GSW_UPDATE_FILENOTEXIST,       //文件不存在
+    GSW_UPDATE_UPGRADECANCELED,    //升级或分区同步被取消
+    GSW_UPDATE_NONEEDCANCEL,       //取消升级失败
+    GSW_UPDATE_NOGOING             //升级或分区同步正在进行,不可重复操作
+}gsw_update_exit_code_t;
+
+
+typedef struct
+{
+    unsigned int percentage; //update progress0-100
+    gsw_update_state_t update_state;
+    gsw_update_exit_code_t exit_code; 
+}gsw_update_info_s;
+
+typedef struct
+{
+    gsw_update_state_t update_state;
+    uint8_t is_damaged; //TURE: damaged FALSE:no damaged
+    uint8_t damaged_partname[16];
+}gsw_system_status_s;
+
+typedef int32_t (*gsw_update_modem_start_autobackup)(char* file_path);
+typedef bool (*gsw_update_modem_check_condition)(void);
+typedef E_GSW_OTA_RET (*gsw_update_modem_result_query)(void);
+typedef int32_t (*gsw_update_modem_start_nobackup)(char* file_path);
+typedef E_GSW_OTA_SYSTEM (*gsw_update_modem_get_system)(void);
+typedef int32_t (*gsw_update_modem_cancel)(void);
+typedef int32_t (*gsw_update_modem_get_info)(gsw_update_info_s *update_info);
+typedef int32_t (*gsw_update_modem_get_status)(gsw_system_status_s *system_status); 
+typedef int32_t (*gsw_update_modem_sync)(void);
+typedef int32_t (*gsw_update_modem_switch)(void);
+
+gsw_update_modem_start_autobackup gsw_update_modem_start_autobackup_ptr = NULL;
+
+static void *ota_handle = NULL;
+
+st_api_test_case api_testcases[] = 
+{
+    {0,    "print_help"},
+    {1,    "gsw_update_modem_start_autobackup"},
+    {2,    "gsw_update_modem_check_condition"},
+    {3,    "gsw_update_modem_result_query"},
+    {4,    "gsw_update_modem_get_system"},
+    {5,    "gsw_update_modem_get_info"},
+    {6,    "gsw_update_modem_get_status"},
+    {7,    "gsw_update_modem_sync"},
+    {8,    "gsw_update_modem_switch"},
+    {9,    "gsw_update_modem_start_nobackup"},
+    {10,   "gsw_update_modem_cancel"},
+    {-1,   NULL}
+    
+};
+
+void print_help(void)
+{
+    int i;
+
+    printf("Supported test cases:\n");
+    for(i = 0; ; i++)
+    {
+        if(api_testcases[i].cmdIdx == -1)
+        {
+            break;
+        }
+        printf("%d:\t%s\n", api_testcases[i].cmdIdx, api_testcases[i].funcName);
+    }
+}
+
+void  *fota_thread(void *arg)
+{
+    char *file_path = (char *)arg;
+    int ret = -1;
+    ret = gsw_update_modem_start_autobackup_ptr(file_path);
+    printf("gsw_update_modem_start_autobackup ret = %d\n", ret);
+    return NULL;
+}
+
+void sigint_handler(int sig)
+{
+    printf("sigint_handler\n");
+    dlclose(ota_handle);
+    ota_handle = NULL;
+    gsw_update_modem_start_autobackup_ptr = NULL;
+    exit(0);
+}
+void clear_input_buffer() 
+{
+    int c;
+   
+    while ((c = getchar()) != '\n' && c != EOF);
+}
+
+int main(int argc,char *argv[])
+{
+    gsw_update_modem_check_condition gsw_update_modem_check_condition_ptr = NULL;
+    gsw_update_modem_result_query gsw_update_modem_result_query_ptr = NULL;
+    gsw_update_modem_get_system gsw_update_modem_get_system_ptr = NULL;    
+    gsw_update_modem_get_info gsw_update_modem_get_info_ptr = NULL;
+    gsw_update_modem_get_status gsw_update_modem_get_status_ptr = NULL;
+    gsw_update_modem_sync gsw_update_modem_sync_ptr = NULL;
+    gsw_update_modem_switch gsw_update_modem_switch_ptr = NULL;
+    gsw_update_modem_start_nobackup gsw_update_modem_start_nobackup_ptr = NULL;
+    gsw_update_modem_cancel gsw_update_modem_cancel_ptr = NULL;
+
+    signal(SIGINT, sigint_handler);
+    if (argc < 2)
+    {
+        printf("Usage: %s <file_path>\n", argv[0]);
+        return -1; // 确保提供了文件路径
+    }
+    char *file_path = argv[1];
+    ota_handle = dlopen("/lib/libgsw_lib.so", RTLD_NOW );
+    if(ota_handle == NULL)
+    {
+            printf("open lib failed\n");
+            return -1;
+    }
+
+    gsw_update_modem_start_autobackup_ptr = (gsw_update_modem_start_autobackup)dlsym(ota_handle, "gsw_update_modem_start_autobackup");
+    if(gsw_update_modem_start_autobackup_ptr == NULL)
+    {
+            printf("dlsym gsw_update_modem_start_autobackup failed\n");
+            return -1;
+    }
+
+    gsw_update_modem_check_condition_ptr = (gsw_update_modem_check_condition)dlsym(ota_handle, "gsw_update_modem_check_condition");
+    if(gsw_update_modem_check_condition_ptr == NULL)
+    {
+            printf("dlsym gsw_update_modem_check_condition failed\n");
+            return -1;
+    }
+
+    gsw_update_modem_result_query_ptr = (gsw_update_modem_result_query)dlsym(ota_handle, "gsw_update_modem_result_query");
+    if(gsw_update_modem_result_query_ptr == NULL)
+    {
+            printf("dlsym gsw_update_modem_result_query failed\n");
+            return -1;
+    }
+
+    gsw_update_modem_get_system_ptr = (gsw_update_modem_get_system)dlsym(ota_handle, "gsw_update_modem_get_system");
+    if(gsw_update_modem_get_system_ptr == NULL)
+    {
+            printf("dlsym gsw_update_modem_get_system failed\n");
+            return -1;
+    }
+
+    gsw_update_modem_get_info_ptr = (gsw_update_modem_get_info)dlsym(ota_handle, "gsw_update_modem_get_info");
+    if(gsw_update_modem_get_info_ptr == NULL)
+    {
+            printf("dlsym gsw_update_modem_get_info failed\n");
+            return -1;
+    }
+
+    gsw_update_modem_get_status_ptr = (gsw_update_modem_get_status)dlsym(ota_handle, "gsw_update_modem_get_status");
+    if(gsw_update_modem_get_status_ptr == NULL)
+    {
+            printf("dlsym gsw_update_modem_get_status failed\n");
+            return -1;
+    }
+
+    gsw_update_modem_sync_ptr = (gsw_update_modem_sync)dlsym(ota_handle, "gsw_update_modem_sync");
+    if(gsw_update_modem_sync_ptr == NULL)
+    {
+            printf("dlsym gsw_update_modem_sync failed\n");
+            return -1;
+    }
+
+    gsw_update_modem_switch_ptr = (gsw_update_modem_switch)dlsym(ota_handle, "gsw_update_modem_switch");
+    if(gsw_update_modem_switch_ptr == NULL)
+    {
+            printf("dlsym gsw_update_modem_switch failed\n");
+            return -1;
+    }
+
+    gsw_update_modem_start_nobackup_ptr = (gsw_update_modem_start_nobackup)dlsym(ota_handle, "gsw_update_modem_start_nobackup");    
+    if(gsw_update_modem_start_nobackup_ptr == NULL)
+    {
+            printf("dlsym gsw_update_modem_start_nobackup failed\n");
+            return -1;
+    }
+
+    gsw_update_modem_cancel_ptr = (gsw_update_modem_cancel)dlsym(ota_handle, "gsw_update_modem_cancel");
+    if(gsw_update_modem_cancel_ptr == NULL)
+    {
+            printf("dlsym gsw_update_modem_cancel failed\n");
+            return -1;
+    }
+
+
+
+    printf("Enter ota api test \n");
+    int opt = -1;
+    print_help();
+    while (1)
+    {
+        char buffer[100]; // 用于存储输入的缓冲区
+        
+        printf("请输入选项: \n");
+        if (fgets(buffer, sizeof(buffer), stdin) != NULL)
+        {
+            
+            if (sscanf(buffer, "%d", &opt) != 1) 
+            {
+                printf("无效输入,请输入一个整数。\n");
+                clear_input_buffer(); 
+                continue; 
+            }
+        }
+        else
+        {
+            
+            clear_input_buffer(); 
+            continue; 
+        }
+
+        printf("输入的整数是:%d\n", opt);
+        
+        switch(opt)
+        {
+            case 0 :
+            {
+                print_help();
+                break;
+            } 
+            case 1 :
+            {
+                int32_t ret = -1;
+                pthread_t thread_id_reboot;
+                ret = pthread_create(&thread_id_reboot, NULL, fota_thread, (void*)file_path);
+                if (ret != 0) 
+                {
+                    printf("pthread_create failed \n");
+                    return -1;
+                }
+                break;
+
+            }
+            case 2 :
+            {
+                bool ret = false;
+                ret = gsw_update_modem_check_condition_ptr();
+                printf("gsw_update_modem_check_condition ret = %d\n", ret);
+                break;
+            }
+            case 3 :	
+            {
+                E_GSW_OTA_RET	ret = -1;
+                ret = gsw_update_modem_result_query_ptr();
+                printf("gsw_update_modem_result_query ret = %d\n", ret);
+                break;
+            }
+            case 4 :
+            {
+                E_GSW_OTA_SYSTEM	ret = -1;
+                ret = gsw_update_modem_get_system_ptr();
+                printf("gsw_update_modem_get_system ret = %d\n", ret);
+                printf("system %c\n", ret == 0? 'a' : 'b');
+
+                break;
+            }
+            case 5 :
+            {
+                int32_t	ret = -1;
+                gsw_update_info_s update_info = {0};
+                ret =  gsw_update_modem_get_info_ptr(&update_info);
+                printf("gsw_update_modem_get_info ret = %d\n", ret);
+               	
+                printf("update_info. = %u\n",update_info.percentage);
+                printf("update_state. = %d\n",update_info.update_state);
+                printf("exit_code. = %d\n",update_info.exit_code);
+
+                break;
+            }
+            case 6:
+            {
+                int32_t ret = -1;
+                gsw_system_status_s system_status = {0};
+                ret = gsw_update_modem_get_status_ptr(&system_status);
+                printf("gsw_update_modem_get_status ret is %d\n",ret);
+                break;
+                
+            }
+            case 7:
+            {
+                int32_t ret = -1;
+                ret = gsw_update_modem_sync_ptr();
+                printf("gsw_update_modem_sync ret is %d\n",ret );
+                break;
+            }
+            case 8 :
+            {
+                int32_t ret = -1;
+                ret = gsw_update_modem_switch_ptr();
+                printf("gsw_update_modem_switch ret is %d \n",ret);
+                break;
+
+            }
+            case 9:
+            {
+                int32_t ret = -1;
+                ret = gsw_update_modem_start_nobackup_ptr(file_path);
+                printf("gsw_update_modem_start_nobackup ret is %d\n",ret);
+                break;
+            }
+            case 10:
+            {
+                int32_t ret = -1;
+                ret = gsw_update_modem_cancel_ptr();
+                printf("gsw_update_modem_cancel ret is %d\n",ret);
+                break;
+            }
+            default:
+                printf("invalid opt\n");
+                break;
+        }
+        
+    }
+    
+    
+    return 0;
+
+
+}
+
diff --git a/mbtk/test/libgsw_lib/gsw_passwd_test.c b/mbtk/test/libgsw_lib/gsw_passwd_test.c
new file mode 100755
index 0000000..4bc0779
--- /dev/null
+++ b/mbtk/test/libgsw_lib/gsw_passwd_test.c
@@ -0,0 +1,59 @@
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <termios.h>
+#include <time.h>
+#include <sys/ioctl.h>
+#include <dlfcn.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+
+int (*gsw_set_passwd)(char *username, char *passwd);
+void *dlHandle;
+char *lynqLib = "/lib/libgsw_lib.so";
+
+int main(int argc, char *argv[])
+{
+    int ret;
+    char tmp1[128];
+    char tmp2[128];
+    if(argc != 3)
+    {
+        printf("parameter error,please input username and passwd\n");
+        return -1;
+    }
+    strcpy(tmp1, argv[1]);
+    strcpy(tmp2, argv[2]);
+    printf("username is %s, passwd is %s\n",tmp1, tmp2);
+    dlHandle = dlopen(lynqLib, RTLD_NOW);
+    if(dlHandle == NULL)
+    {
+        printf("dlopen libgsw_lib fail\n");
+        return -1;
+    }
+    gsw_set_passwd=(int(*)(char *username, char *passwd))dlsym(dlHandle, "gsw_set_passwd");
+    if(dlHandle == NULL)
+    {
+        printf("dlsym gsw_set_passwd fail\n");
+        return -1;
+    }
+    ret = gsw_set_passwd(tmp1, tmp2);
+    if(ret)
+    {
+        printf("gsw_set_passwd fail\n");
+    }
+    else
+    {
+        printf("gsw_set_passwd successful\n");
+    }
+    
+    return 0;
+}
diff --git a/mbtk/test/libgsw_lib/gsw_pm_test.c b/mbtk/test/libgsw_lib/gsw_pm_test.c
new file mode 100755
index 0000000..933cf9e
--- /dev/null
+++ b/mbtk/test/libgsw_lib/gsw_pm_test.c
@@ -0,0 +1,132 @@
+#include <stdio.h>

+#include <string.h>

+#include <strings.h>

+#include <stdlib.h>

+#include <errno.h>

+#include <fcntl.h>

+#include <signal.h>

+#include <sys/types.h>

+#include <unistd.h>

+#include <pthread.h>

+#include <termios.h>

+#include <time.h>

+#include <sys/ioctl.h>

+#include <dlfcn.h>

+#include <stdint.h>

+#include <stdbool.h>

+

+typedef void (*GSW_PM_WAKEUPCALLBACK)(int32_t wakeup_in);

+

+void tmp_callback(int32_t wakeup_in)

+{

+    printf("wackout value %d\n",wakeup_in);

+}

+

+int32_t (*gsw_autosleep_enable)(void);

+int32_t (*gsw_autosleep_disenable)(void);

+int32_t (*gsw_pm_sdk_init)(GSW_PM_WAKEUPCALLBACK );

+int32_t (*gsw_pm_enter_sleep)(const char *gsw_wakelock_name);

+int32_t (*gsw_pm_exit_sleep)(const char *gsw_wakelock_name);

+void (*gsw_modem_log_sync)(void);

+

+const char *tmp_name = "pm_test_lock";

+

+void *dlHandle_pm;

+char *lynqLib_pm = "/lib/libgsw_lib.so";

+

+void user_help(void)

+{

+    printf("\t1 autosleep_enable\n"

+           "\t2 autosleep_disenable \n"

+           "\t3 pm_sdk_init\n"

+           "\t4 pm_enter_sleep\n"

+           "\t5 pm_exit_sleep\n"

+           "\t6 modem_log_sync\n"

+           "please input operator: >> ");

+}

+

+int main(void)

+{

+    int ret;

+    int opt = 0;

+    dlHandle_pm = dlopen(lynqLib_pm, RTLD_NOW);

+    while(1)

+    {

+        printf("=========PM main=========\n");

+        user_help();

+        if (scanf("%d", &opt) != 1)

+            printf("input error,please check it");

+        while(getchar()!='\n');

+        switch (opt)

+        {

+        case 1:

+        {

+            gsw_autosleep_enable=(int32_t(*)())dlsym(dlHandle_pm, "gsw_autosleep_enable");

+            ret = gsw_autosleep_enable();

+            if(ret < 0)

+            {

+                printf("gsw_autosleep_enable FAIL.\n");

+                return -1;

+            }

+            printf("gsw_autosleep_enable success.\n");

+            return 0;

+        }

+        case 2:

+        {

+            gsw_autosleep_disenable=(int32_t(*)())dlsym(dlHandle_pm, "gsw_autosleep_disenable");

+            ret = gsw_autosleep_disenable();

+            if(ret < 0)

+            {

+                printf("gsw_autosleep_disenable FAIL.\n");

+                return -1;

+            }

+            printf("gsw_autosleep_disenable success.\n");

+            return 0;

+        }

+        case 3:

+        {

+            gsw_pm_sdk_init=(int32_t(*)(GSW_PM_WAKEUPCALLBACK ))dlsym(dlHandle_pm, "gsw_pm_sdk_init");

+            ret = gsw_pm_sdk_init(tmp_callback);

+            if(ret < 0)

+            {

+                printf("gsw_pm_sdk_init FAIL.\n");

+                return -1;

+            }

+            printf("gsw_pm_sdk_init success.\n");

+            break;

+        }

+        case 4:

+        {

+            gsw_pm_enter_sleep=(int32_t(*)(const char *gsw_wakelock_name))dlsym(dlHandle_pm, "gsw_pm_enter_sleep");

+            ret = gsw_pm_enter_sleep(tmp_name);

+            if(ret < 0)

+            {

+                printf("gsw_pm_enter_sleep FAIL.\n");

+                return -1;

+            }

+            printf("gsw_pm_enter_sleep success.\n");

+            return 0;

+        }

+        case 5:

+        {

+            gsw_pm_exit_sleep=(int32_t(*)(const char *gsw_wakelock_name))dlsym(dlHandle_pm, "gsw_pm_exit_sleep");

+            ret = gsw_pm_exit_sleep(tmp_name);

+            if(ret < 0)

+            {

+                printf("gsw_pm_exit_sleep FAIL.\n");

+                return -1;

+            }

+            printf("gsw_pm_exit_sleep success.\n");

+            break;

+        }

+        case 6:

+        {

+            gsw_modem_log_sync=(void(*)())dlsym(dlHandle_pm, "gsw_modem_log_sync");

+            gsw_modem_log_sync();

+            printf("gsw_modem_log_sync success.\n");

+            return 0;

+        }

+        }

+    }

+    return 0;

+}
\ No newline at end of file
diff --git a/mbtk/test/libgsw_lib/gsw_sim_test.c b/mbtk/test/libgsw_lib/gsw_sim_test.c
new file mode 100755
index 0000000..6ba8288
--- /dev/null
+++ b/mbtk/test/libgsw_lib/gsw_sim_test.c
@@ -0,0 +1,372 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <dlfcn.h>
+#include <stdint.h>
+#include <string.h>
+#include <pthread.h>
+
+//mbtk include
+
+typedef unsigned int uint32;
+typedef unsigned char uint8;
+typedef unsigned short uint16;
+typedef void (*mbtk_info_callback_func)(const void* data, int data_len);
+
+typedef struct
+{
+    int client_fd;
+    pthread_t read_thread_id;
+    int exit_fd[2];
+    bool is_waitting;
+    pthread_cond_t cond;
+    pthread_mutex_t mutex;
+
+    pthread_mutex_t send_mutex;
+
+    // Temp response data.
+    uint16 info_err;
+    uint16 data_len;
+    void *data;
+
+    //mbtk wyq for server_ready_status add start
+    char server_ready_status;
+    //mbtk wyq for server_ready_status add end
+
+    mbtk_info_callback_func net_state_cb;
+    mbtk_info_callback_func call_state_cb;
+    mbtk_info_callback_func sms_state_cb;
+    mbtk_info_callback_func radio_state_cb;
+    mbtk_info_callback_func sim_state_cb;
+    mbtk_info_callback_func pdp_state_cb;
+    //add signal by xr
+    mbtk_info_callback_func signal_state_cb;
+} mbtk_info_handle_t;
+
+typedef enum {
+    MBTK_SIM_ABSENT = 0,
+    MBTK_SIM_NOT_READY = 1,
+    MBTK_SIM_READY = 2,
+    MBTK_SIM_PIN = 3,
+    MBTK_SIM_PUK = 4,
+    MBTK_SIM_NETWORK_PERSONALIZATION = 5
+} mbtk_sim_state_enum;
+
+typedef enum
+{
+    MBTK_DEV_MODEM_MIN_FUN,                                   //Modem 最小功能
+    MBTK_DEV_MODEM_FULL_FUN,                                  //Modem 全功能
+    MBTK_DEV_MODEM_DISABLE_RECEIVE_RF_CIRCUITS = 3,           //Modem 禁用射频接收电路
+    MBTK_DEV_MODEM_DISABLE_TRANSMIT_AND_RECEIVE_RF_CIRCUITS,  //Modem禁用射频发射和接收电路
+    MBTK_DEV_MODEM_DISABLE_SIM,                               //Modem 禁用(U)SIM 卡
+    MBTK_DEV_MODEM_TURN_OFF_FULL_SECONDARY_RECEIVE,           //Modem 完全禁用辅助接收
+}MBTK_DEV_MODEM_FUNCTION;
+
+typedef struct
+{
+    MBTK_DEV_MODEM_FUNCTION fun;
+    int rst;
+} mbtk_modem_info_t;
+
+
+
+
+//gsw include
+#define GSW_HAL_SUCCESS 0
+#define GSW_HAL_FAIL -1
+#define GSW_HAL_MEM_INVAILD -2
+#define GSW_SIM_ICCID_LENGTH 20+1 
+#define GSW_SIM_IMSI_LENGTH 20+1 
+#define GSW_SIM_MSISDN_LENGTH 20+1
+#define GSW_SIM_IMEI_LENGTH 20+1
+
+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;
+
+
+int (*gsw_sim_sdk_init)(int32_t token);
+int (*gsw_sim_sdk_deinit)(void);
+int (*gsw_get_sim_status)(int32_t *sim_state);
+int (*gsw_get_sim_iccid)(int32_t len, int8_t *iccid);
+int (*gsw_get_sim_imsi)(int32_t len, int8_t *imsi);
+int (*gsw_get_sim_msisdn)(int32_t len, int8_t *msisdn);
+int (*gsw_get_imei)(int32_t len, int8_t *imei);
+int (*gsw_set_sim_power_down)(void);
+int (*gsw_set_sim_power_up)(void);
+int (*gsw_reset_modem)(void);
+
+
+#define lib_gsw_sim_path "/lib/libgsw_lib.so"
+static void *dlHandle_sim = NULL;
+
+
+static int gsw_sim_api_import()
+{
+    dlHandle_sim = dlopen(lib_gsw_sim_path, RTLD_NOW);
+    if (dlHandle_sim == NULL) {
+        printf("dlopen gsw_sim_sdk_init fail\n");
+        return GSW_HAL_FAIL;
+    }
+
+    gsw_sim_sdk_init = (int(*)(int32_t token))dlsym(dlHandle_sim, "gsw_sim_sdk_init");
+    if (gsw_sim_sdk_init == NULL) {
+        printf("dlsym gsw_sim_sdk_init fail\n");
+        return GSW_HAL_FAIL;
+    }
+
+    gsw_sim_sdk_deinit = (int(*)(void))dlsym(dlHandle_sim, "gsw_sim_sdk_deinit");
+    if (gsw_sim_sdk_deinit == NULL) {
+        printf("dlsym gsw_sim_sdk_deinit fail\n");
+        return GSW_HAL_FAIL;
+    }
+
+    gsw_get_sim_status = (int(*)(int32_t *sim_state))dlsym(dlHandle_sim, "gsw_get_sim_status");
+    if (gsw_get_sim_status == NULL) {
+        printf("dlsym gsw_get_sim_status fail\n");
+        return GSW_HAL_FAIL;
+    }
+
+    gsw_get_sim_iccid = (int(*)(int32_t len, int8_t *iccid))dlsym(dlHandle_sim, "gsw_get_sim_iccid");
+    if (gsw_get_sim_iccid == NULL) {
+        printf("dlsym gsw_get_sim_iccid fail\n");
+        return GSW_HAL_FAIL;
+    }
+
+    gsw_get_sim_imsi = (int(*)(int32_t len, int8_t *imsi))dlsym(dlHandle_sim, "gsw_get_sim_imsi");
+    if (gsw_get_sim_imsi == NULL) {
+        printf("dlsym gsw_get_sim_imsi fail\n");
+        return GSW_HAL_FAIL;
+    }
+
+    gsw_get_sim_msisdn = (int(*)(int32_t len, int8_t *msisdn))dlsym(dlHandle_sim,"gsw_get_sim_msisdn");
+    if (gsw_get_sim_msisdn == NULL) {
+        printf("dlsym gsw_get_sim_msisdn fail\n");
+        return GSW_HAL_FAIL;
+    }
+
+    gsw_get_imei = (int(*)(int32_t len, int8_t *imei))dlsym(dlHandle_sim,"gsw_get_imei");
+    if (gsw_get_imei == NULL) {
+        printf("dlsym gsw_get_imei fail\n");
+        return GSW_HAL_FAIL;
+    }
+
+    gsw_set_sim_power_down = (int(*)(void))dlsym(dlHandle_sim,"gsw_set_sim_power_down");
+    if (gsw_set_sim_power_down == NULL) {
+        printf("dlsym gsw_set_sim_power_down fail\n");
+        return GSW_HAL_FAIL;
+    }
+
+    gsw_set_sim_power_up = (int(*)(void))dlsym(dlHandle_sim,"gsw_set_sim_power_up");
+    if (gsw_set_sim_power_up == NULL) {
+        printf("dlsym gsw_set_sim_power_up fail\n");
+        return GSW_HAL_FAIL;
+    }
+
+    gsw_reset_modem = (int(*)(void))dlsym(dlHandle_sim,"gsw_reset_modem");
+    if (gsw_reset_modem == NULL) {
+        printf("dlsym gsw_reset_modem fail\n");
+        return GSW_HAL_FAIL;
+    }
+
+    return GSW_HAL_SUCCESS;
+}
+
+
+
+int main()
+{
+    char operator[10];
+    int opt;
+    int ret = -1;
+
+    gsw_sim_api_import();
+
+    while(1)
+    {
+        printf("-1.exit\n");
+        printf("1.sim init\n");
+        printf("2.sim deinit\n");
+        printf("3.imsi : Get IMSI.\n");
+        printf("4.iccid : Get ICCID.\n");
+        printf("5.msisdn : Get phone number.\n");
+        printf("6.sim states\n");
+        printf("7.sim power_down\n");
+        printf("8.sim power_up\n");
+        printf("9.reset modem\n");
+        printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Enter cmd:");
+
+        char* temp = NULL;
+        memset(operator, 0, sizeof(operator));
+        temp = fgets(operator, sizeof(operator), stdin);
+        fflush(stdin);
+
+        printf("temp = %s",temp);
+        opt = atoi(operator);
+        switch(opt)
+        {
+            case -1:
+            {
+                printf("exit\n");
+                return 0;
+            }
+            //gsw_sim_sdk_init
+            case 1:
+            {
+                printf("sdk_init\n");
+                ret = gsw_sim_sdk_init(123);
+                if(ret == 0)
+                {
+                    printf("gsw_sim_sdk_init success\n");
+                }
+                else
+                {
+                    printf("gsw_sim_sdk_init fail,ret = %d\n",ret);
+                }
+                break;
+            }
+
+            //sim deinit
+            case 2:
+            {
+                printf("sim deinit\n");
+                ret = gsw_sim_sdk_deinit();
+                if(ret == 0)
+                {
+                    printf("gsw_sim_sdk_deinit success\n");
+                }
+                else
+                {
+                    printf("gsw_sim_sdk_deinit fail,ret = %d\n",ret);
+                }
+                break;
+            }
+
+            //imsi
+            case 3:
+            {
+                char imsi[GSW_SIM_IMEI_LENGTH] = {0};
+                ret = gsw_get_sim_imsi(GSW_SIM_IMEI_LENGTH, (int8_t *)imsi);
+                if(ret == 0)
+                {
+                    printf("gsw_get_sim_imsi success, imsi = %s\n",imsi);
+                }
+                else
+                {
+                    printf("gsw_get_sim_imsi fail,ret = %d\n",ret);
+                }
+                break;
+            }
+            
+            //iccid
+            case 4:
+            {
+                char iccid[GSW_SIM_ICCID_LENGTH] = {0};
+                ret = gsw_get_sim_iccid(GSW_SIM_ICCID_LENGTH, (int8_t *)iccid);
+                if(ret == 0)
+                {
+                    printf("gsw_get_sim_iccid success, iccid = %s\n",iccid);
+                }
+                else
+                {
+                    printf("gsw_get_sim_iccid fail,ret = %d\n",ret);
+                }
+                break;
+            }
+
+            //msisdn
+            case 5:
+            {
+                char msisdn[GSW_SIM_MSISDN_LENGTH] = {0};
+                ret = gsw_get_sim_msisdn(GSW_SIM_MSISDN_LENGTH, (int8_t *)msisdn);
+                if(ret == 0)
+                {
+                    printf("gsw_get_sim_msisdn success, msisdn = %s\n",msisdn);
+                }
+                else
+                {
+                    printf("gsw_get_sim_msisdn fail,ret = %d\n",ret);
+                }
+                break;
+            }
+            //sim states
+            case 6:
+            {
+                int sim_state;
+                printf("start gsw_get_sim_status\n");
+                ret = gsw_get_sim_status(&sim_state);
+                printf("end gsw_get_sim_status\n");
+                if(ret == 0)
+                {
+                    printf("gsw_get_sim_status success,sim_state = %d\n",sim_state);
+                }
+                else
+                {
+                    printf("gsw_get_sim_status fail,ret = %d\n",ret);
+                }
+                break;
+            }
+
+            //sim power_down
+            case 7:
+            {
+                ret = gsw_set_sim_power_down();
+                if(ret == 0)
+                {
+                    printf("gsw_set_sim_power_down success\n");
+                }
+                else
+                {
+                    printf("gsw_set_sim_power_down fail,ret = %d\n",ret);
+                }
+                break;
+            }
+
+            //sim power_up
+            case 8:
+            {
+                ret = gsw_set_sim_power_up();
+                if(ret == 0)
+                {
+                    printf("gsw_set_sim_power_up success\n");
+                }
+                else
+                {
+                    printf("gsw_set_sim_power_up fail,ret = %d\n",ret);
+                }
+                break;
+            }
+
+            //reset modem
+            case 9:
+            {
+                ret = gsw_reset_modem();
+                if(ret == 0)
+                {
+                    printf("gsw_reset_modem success\n");
+                }
+                else
+                {
+                    printf("gsw_reset_modem fail,ret = %d\n",ret);
+                }
+                break;
+            }
+
+            default :
+            {
+                printf("error cmd.\n");
+                continue;
+            }
+                
+        }
+    }
+
+
+
+
+}
diff --git a/mbtk/test/libgsw_lib/gsw_sms_test.c b/mbtk/test/libgsw_lib/gsw_sms_test.c
new file mode 100755
index 0000000..7678208
--- /dev/null
+++ b/mbtk/test/libgsw_lib/gsw_sms_test.c
@@ -0,0 +1,308 @@
+#include <stdio.h>

+#include <stdlib.h>

+#include <stdbool.h>

+#include <dlfcn.h>

+#include <stdint.h>

+#include <string.h>

+

+

+#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*/

+

+#define GSW_HAL_SMS_ADDRESS_LEN GSW_SMS_ADDRESS_LEN

+#define GSW_HAL_SMS_RECV_CONT_MAX GSW_SMS_RECV_CONT_MAX

+

+typedef unsigned short uint16_t;

+typedef unsigned int uint32_t;

+typedef unsigned short uint16;

+typedef uint32_t sms_client_handle_type;

+

+typedef enum

+{

+    GSW_SMS_FULL_FLG,               /**< sms full flag*/

+    GSW_SMS_RECEIVED_FLG,           /**<recv new sms flag*/

+}gsw_sms_state_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 gsw_hal_sms_date

+{

+    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;

+

+typedef struct gsw_hal_sms_msg_type

+{

+    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 void (* GSW_HAL_SMS_CALLBACK_FUN)(gsw_sms_state_e state, gsw_sms_msg_type_t *report_info);

+

+

+int (*gsw_sms_reg_callback)(GSW_HAL_SMS_CALLBACK_FUN handle_ptr);

+int (*gsw_sms_sdk_init)(int32_t token);

+int (*gsw_sms_sdk_deinit)(void);

+int (*gsw_send_sms)(int8_t *phone_num, int32_t char_set, int8_t *msg, int32_t msg_len);

+int (*gsw_get_smsc_address)(int32_t len, int8_t *smsc);

+int (*gsw_set_smsc_address)(const int8_t *smsc);

+

+#define lib_gsw_sms_path "/lib/libgsw_lib.so"

+static void *dlHandle_sms;

+

+

+void gsw_test_callback(gsw_sms_state_e state, gsw_sms_msg_type_t *report_info)

+{

+    printf("gsw_test_callback: state = %d\n", state);

+    printf("gsw_test_callback: report_info->src_num = %s\n", report_info->src_num);

+    printf("gsw_test_callback: report_info->dest_num = %s\n", report_info->dest_num);

+    printf("gsw_test_callback: report_info->content_encode = %d\n", report_info->content_encode);

+    printf("gsw_test_callback: report_info->content_len = %d\n", report_info->content_len);

+    printf("gsw_test_callback: report_info->content = %s\n", report_info->content);

+    printf("gsw_test_callback: report_info->date->year = %s\n", report_info->date.year);

+    printf("gsw_test_callback: report_info->date->month = %s\n", report_info->date.month);

+    printf("gsw_test_callback: report_info->date->day = %s\n", report_info->date.day);

+    printf("gsw_test_callback: report_info->date->hour = %s\n", report_info->date.hour);

+    printf("gsw_test_callback: report_info->date->minutes = %s\n", report_info->date.minutes);

+    printf("gsw_test_callback: report_info->date->seconds = %s\n", report_info->date.seconds);

+    printf("gsw_test_callback: report_info->date->timezone = %s\n", report_info->date.timezone);

+}

+

+

+static int gsw_sms_api_import()

+{

+    dlHandle_sms = dlopen(lib_gsw_sms_path, RTLD_NOW);

+    if (dlHandle_sms == NULL) {

+        printf("Failed to open %s\n", lib_gsw_sms_path);

+        return -1;

+    }

+

+    gsw_sms_sdk_init = (int(*)(int32_t token))dlsym(dlHandle_sms,"gsw_sms_sdk_init");

+    if(gsw_sms_sdk_init == NULL)

+    {

+        printf("gsw_sms_sdk_init fail\n");

+        return -1;

+    }

+

+    gsw_sms_reg_callback = (int(*)(GSW_HAL_SMS_CALLBACK_FUN handle_ptr))dlsym(dlHandle_sms,"gsw_sms_reg_callback");

+    if(gsw_sms_reg_callback == NULL)

+    {

+        printf("gsw_sms_reg_callback fail\n");

+        return -1;

+    }

+

+    gsw_send_sms = (int(*)(int8_t *phone_num, int32_t char_set, int8_t *msg, int32_t msg_len))dlsym(dlHandle_sms,"gsw_send_sms");

+    if(gsw_send_sms == NULL)

+    {

+        printf("gsw_send_sms fail\n");

+        return -1;

+    }

+

+    gsw_get_smsc_address = (int(*)(int32_t len, int8_t *smsc))dlsym(dlHandle_sms,"gsw_get_smsc_address");

+    if(gsw_get_smsc_address == NULL)

+    {

+        printf("gsw_get_smsc_address fail\n");

+        return -1;

+    }

+

+    gsw_set_smsc_address = (int(*)(const int8_t *smsc))dlsym(dlHandle_sms,"gsw_set_smsc_address");

+    if(gsw_set_smsc_address == NULL)

+    {

+        printf("gsw_set_smsc_address fail\n");

+        return -1;

+    }

+

+    gsw_sms_sdk_deinit = (int(*)(void))dlsym(dlHandle_sms,"gsw_sms_sdk_deinit");

+    if(gsw_sms_sdk_deinit == NULL)

+    {

+        printf("gsw_sms_sdk_deinit fail\n");

+        return -1;

+    }

+

+    return 0;

+}

+

+int main()

+{

+    int ret = -1;

+    int opt = -1;

+    char operator[10];

+    char phone_number[GSW_HAL_SMS_ADDRESS_LEN] = {0};

+    char serv_numer[GSW_HAL_SMS_ADDRESS_LEN] = {0};

+

+    ret = gsw_sms_api_import();

+    if(ret != 0)

+    {

+        printf("gsw_sms_api_import fail\n");

+        return -1;

+    }

+

+    while(1)

+    {

+        printf("=========sms main=========\n"

+        "\t-1 exit\n"

+        "\t1 sms init\n"

+        "\t2 send text sms\n"

+        "\t3 wait receive new sms\n"

+        "\t4 send PDU sms\n"

+        "\t7 query service number\n"

+        "\t8 set service number\n"

+        "\t9 deinit sms\n"

+        "operator: >> \n");

+

+        opt = -1;

+        ret = -1;

+        printf("%s\n",fgets(operator, sizeof(operator), stdin));

+        fflush(stdin);

+        opt = atoi(operator);

+        switch (opt)

+        {

+            case -1:

+            {

+                printf("main exit\n");

+                return 0;

+            }

+            case 1:

+            {

+                printf("gsw_sms_sdk_init start");

+                ret = gsw_sms_sdk_init(1234);

+                if(ret != 0)

+                {

+                    printf("gsw_sms_sdk_init fail,ret = %d\n",ret);

+                    dlclose(dlHandle_sms);

+                    continue;

+                }

+                

+                break;

+            }

+            case 2:

+            {

+                char *tmp = "all man hello world";

+                printf("input phone number:\n");

+                memset(phone_number, 0x0, GSW_HAL_SMS_ADDRESS_LEN);

+                //fgets(phone_number, MAX_LEN, stdin);

+                printf("%d\n",scanf("%15s", phone_number));

+                fflush(stdin);

+                int len = strlen(tmp);

+                ret = gsw_send_sms((int8_t*)phone_number, 0, (int8_t*)tmp, len);

+                if(ret != 0)

+                {

+                    printf("gsw_send_sms fail,ret = %d\n",ret);

+                    continue;

+                }

+                break;

+            }

+

+            case 3:

+            {

+                printf("gsw_sms_reg_callback start\n");

+                ret = gsw_sms_reg_callback(gsw_test_callback);

+                if(ret != 0)

+                {

+                    printf("gsw_sms_reg_callback fail,ret = %d\n",ret);

+                    continue;

+                }

+                printf("gsw_sms_reg_callback end");

+                break;

+            }

+

+            case 4:

+            {

+                char *tmp = "你好"; 

+                printf("input phone number:\n");

+                memset(phone_number, 0x0, GSW_HAL_SMS_ADDRESS_LEN);

+                //fgets(phone_number, MAX_LEN, stdin);

+                printf("%d\n",scanf("%15s", phone_number));

+                fflush(stdin);

+                int len = strlen(tmp);

+                ret = gsw_send_sms((int8_t*)phone_number, 2, (int8_t *)tmp, len);

+                if(ret != 0)

+                {

+                    printf("gsw_send_sms fail,ret = %d\n",ret);

+                    continue;

+                }

+                break;

+            }

+

+            case 7:

+            {   

+                printf("gsw_get_smsc_address start\n");

+                ret = gsw_get_smsc_address(GSW_HAL_SMS_ADDRESS_LEN, (int8_t *)serv_numer);

+                if(ret != 0)

+                {

+                    printf("gsw_get_smsc_address fail,ret = %d\n",ret);

+                    continue;

+                }

+                printf("smsc: %s\n", serv_numer);

+                break;

+            }

+            

+            case 8:

+            {

+                printf("input phone number:\n");

+                memset(phone_number, 0x0, GSW_HAL_SMS_ADDRESS_LEN);

+                //fgets(phone_number, MAX_LEN, stdin);

+                printf("%d\n",scanf("%15s", phone_number));

+                fflush(stdin);

+                printf("start memcpy\n");

+                memcpy(serv_numer, phone_number, GSW_HAL_SMS_ADDRESS_LEN);

+                ret = gsw_set_smsc_address((const int8_t *)serv_numer);

+                if(ret != 0)

+                {

+                    printf("gsw_set_smsc_address fail,ret = %d\n",ret);

+                    continue;

+                }

+                printf("smsc: %s\n", serv_numer);

+                break;

+            }

+            

+

+            case 9:

+            {

+

+                printf("gsw_sms_sdk_deinit start\n");

+                ret = gsw_sms_sdk_deinit();

+                if(ret != 0)

+                {

+                    printf("gsw_sms_sdk_deinit fail,ret = %d\n",ret);

+                    dlclose(dlHandle_sms);

+                    continue;

+                }

+                break;

+            }

+

+            default:

+            {

+                continue;

+            }

+            

+        }

+

+

+    }

+

+

+

+

+

+}

+

diff --git a/mbtk/test/libgsw_lib/gsw_tee_test.c b/mbtk/test/libgsw_lib/gsw_tee_test.c
new file mode 100755
index 0000000..8d845ae
--- /dev/null
+++ b/mbtk/test/libgsw_lib/gsw_tee_test.c
@@ -0,0 +1,130 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+#include <unistd.h>
+#include <stdint.h>
+
+#define TEST_OBJECT_SIZE	7000
+
+void *dlHandle_tee;
+char *lynqLib_tee = "/lib/libgsw_lib.so";
+
+
+int32_t (*gsw_tee_sdk_init)(void);
+int32_t (*gsw_tee_write_secure_data)(const char* in_obj_name, char* in_buf, unsigned int in_buf_len);
+int32_t (*gsw_tee_read_secure_data)(const char* in_obj_name, char* out_buf, unsigned int* p_out_buf_len);
+int32_t (*gsw_tee_delete_secure_data)(const char* in_obj_name);
+int32_t (*gsw_tee_check_secure_data)(const char* in_obj_name);
+int32_t (*gsw_tee_sdk_deinit)(void);
+
+int tee_init(void)
+{
+    dlHandle_tee = dlopen(lynqLib_tee, RTLD_NOW);
+    
+    if(dlHandle_tee == NULL)
+    {
+        printf("dlHandle_tee is NULL\n");
+        return -1;
+    }
+    printf("dlHandle_tee is success\n");
+
+    gsw_tee_sdk_init=(int32_t(*)())dlsym(dlHandle_tee, "gsw_tee_sdk_init");
+    if(gsw_tee_sdk_init == NULL)
+    {
+        printf("gsw_tee_sdk_init is NULL\n");
+        return -1;
+    }
+    printf("gsw_tee_sdk_init is success\n");
+
+    gsw_tee_write_secure_data=(int32_t(*)(const char* in_obj_name, char* in_buf, unsigned int in_buf_len))dlsym(dlHandle_tee, "gsw_tee_write_secure_data");
+    if(gsw_tee_write_secure_data == NULL)
+    {
+        printf("gsw_tee_write_secure_data is NULL\n");
+        return -1;
+    }
+
+    
+    gsw_tee_read_secure_data=(int32_t(*)(const char* in_obj_name, char* in_buf, unsigned int* p_out_buf_len))dlsym(dlHandle_tee, "gsw_tee_read_secure_data");
+    if(gsw_tee_read_secure_data == NULL)
+    {
+        printf("gsw_tee_read_secure_data is NULL\n");
+        return -1;
+    }
+
+    gsw_tee_delete_secure_data=(int32_t(*)(const char* in_obj_name))dlsym(dlHandle_tee, "gsw_tee_delete_secure_data");
+    if(gsw_tee_delete_secure_data == NULL)
+    {
+        printf("gsw_tee_delete_secure_data is NULL\n");
+        return -1;
+    }
+
+    gsw_tee_check_secure_data=(int32_t(*)(const char* in_obj_name))dlsym(dlHandle_tee, "gsw_tee_check_secure_data");
+    if(gsw_tee_check_secure_data == NULL)
+    {
+        printf("gsw_tee_check_secure_data is NULL\n");
+        return -1;
+    }
+
+    gsw_tee_sdk_deinit=(int32_t(*)())dlsym(dlHandle_tee, "gsw_tee_sdk_deinit");
+    if(gsw_tee_sdk_deinit == NULL)
+    {
+        printf("gsw_tee_sdk_deinit is NULL\n");
+        return -1;
+    }
+
+    return 0;
+}   
+
+
+
+int main(void)
+{
+    int ret;
+    unsigned int len;
+    char obj1_id[] = "object#1";
+    char obj1_data[] = "123456789";
+    char read_data[TEST_OBJECT_SIZE];
+    
+    printf("gsw_optee_test start\n");
+    ret = tee_init();
+    if(ret != 0)
+    {
+        printf("tee_init fail\n");
+    }
+
+    ret = gsw_tee_sdk_init();
+    if(ret != 0)
+    {
+        printf("gsw_tee_sdk_init fail\n");
+	    return ret;
+    }
+    ret = gsw_tee_write_secure_data(obj1_id, obj1_data, sizeof(obj1_data));
+    if(ret != 0)
+    {
+        printf("gsw_tee_write_secure_data fail\n");
+        return ret;
+    }
+
+    ret = gsw_tee_read_secure_data(obj1_id, read_data, &len);
+    if(ret != 0)
+    {
+        printf("gsw_tee_read_secure_data fail\n");
+        return ret;
+    }
+    printf("read_data: %s\n", read_data);
+    
+    ret = gsw_tee_delete_secure_data(obj1_id);
+    if(ret != 0)
+    {
+        printf("gsw_tee_delete_secure_data fail\n");
+        return ret;
+    }
+    ret = gsw_tee_check_secure_data(obj1_id);
+    printf("gsw_tee_check_secure_data ret = %d\n", ret); 
+
+    ret = gsw_tee_sdk_deinit();
+    printf("gsw_tee_sdk_deinit ret = %d\n", ret); 
+    return 0;
+
+}
diff --git a/mbtk/test/libgsw_lib/gsw_uart_test.c b/mbtk/test/libgsw_lib/gsw_uart_test.c
new file mode 100755
index 0000000..95b7654
--- /dev/null
+++ b/mbtk/test/libgsw_lib/gsw_uart_test.c
@@ -0,0 +1,215 @@
+#include <stdio.h>

+#include <string.h>

+#include <strings.h>

+#include <stdlib.h>

+#include <errno.h>

+#include <fcntl.h>

+#include <signal.h>

+#include <sys/types.h>

+#include <unistd.h>

+#include <pthread.h>

+#include <termios.h>

+#include <time.h>

+#include <sys/ioctl.h>

+#include <dlfcn.h>

+#include <stdint.h>

+#include <stdbool.h>

+#define MY_IOCTL_CMD3  _IOW('d', 1, char*) // 写入字符串

+typedef enum{

+  GSW_HAL_BAUDRATE_1200=1200,

+  GSW_HAL_BAUDRATE_1800=1800,

+  GSW_HAL_BAUDRATE_4800=4800,

+  GSW_HAL_BAUDRATE_9600=9600,

+  GSW_HAL_BAUDRATE_19200=19200,

+  GSW_HAL_BAUDRATE_38400=38400,

+  GSW_HAL_BAUDRATE_57600=57600,

+  GSW_HAL_BAUDRATE_115200=115200,

+  GSW_HAL_BAUDRATE_230400=230400,

+  GSW_HAL_BAUDRATE_460800=460800,

+  GSW_HAL_BAUDRATE_500000=500000,

+  GSW_HAL_BAUDRATE_576000=576000,

+  GSW_HAL_BAUDRATE_921600=921600

+}gsw_hal_uart_baudrate;

+

+int32_t (*gsw_uart_open_ex)(int8_t *port, gsw_hal_uart_baudrate, uint32_t, int8_t, uint32_t);

+int32_t (*gsw_uart_flush)(int32_t);

+int32_t (*gsw_uart_close)(int32_t);

+int32_t (*gsw_uart_write)(int32_t, const uint8_t *buffer, uint32_t);

+int32_t (*gsw_uart_read)(int32_t, uint8_t *buffer, uint32_t, int32_t);

+int32_t (*gsw_uart_ioctl)(int32_t, uint32_t, void *pvalue);

+void *dlHandle_uart;

+char *lynqLib_uart = "/lib/libgsw_lib.so";

+

+

+int8_t *port; 

+gsw_hal_uart_baudrate baudrate;

+uint32_t bits = -1;

+int8_t parity = 3;

+uint32_t stop = -1;

+int fd = -1;

+int ret = -1;

+void prama(char *buffer)

+{

+    char *words[10];

+    for (int i = 0; i < 10; i++)

+    {

+        words[i] = (char *)malloc(20 * sizeof(char));

+        if (words[i] != NULL)

+        {

+            strcpy(words[i], "");

+        }

+    }

+    int i = 0;

+    buffer[strlen(buffer)-1] = '\0';

+    char *token = strtok(buffer, " ");  

+    while (token != NULL && i < 10)

+    {  

+        strcpy(words[i], token);

+        printf("var%d = %s\n", i, words[i]);

+        i++;

+        token = strtok(NULL, " ");

+    }

+    if (words[0])

+        port = (int8_t *)words[0];

+    if (words[1])

+        baudrate = atoi(words[1]);

+    if (words[2])

+        bits = atoi(words[2]);

+    if (words[3])

+        parity = (int8_t)(words[3][0]);

+    if (words[4])

+        stop = atoi(words[4]);

+    

+    for (int i = 1; i < 10; i++)

+    {

+        free(words[i]);

+    }

+    return;

+}

+

+void *read_function(void *timeout_ms)

+{

+    uint8_t buf[128];

+    while(1)

+    {

+        memset(buf,0,sizeof(buf));

+        ret = gsw_uart_read(fd, buf, sizeof(buf) - 1, *(int *)timeout_ms);

+        if(ret > 0)

+        {

+            if(memcmp(buf, "exit", 4) == 0)

+            {

+                printf("exit\n");

+                break;

+            }

+        printf("%s\n",buf);

+        printf("gsw_uart_read success.\n");

+        }

+    }

+    close(fd);

+    return NULL;

+}

+

+int main(void)

+{

+    int opt = 0;

+    int timeout_ms;

+    dlHandle_uart = dlopen(lynqLib_uart, RTLD_NOW);

+    pthread_t read_thread;

+    while(1)

+    {

+        printf("=========uart main=========\n");

+        if (scanf("%d", &opt) != 1)

+            printf("input error,please check it");

+        while(getchar()!='\n');

+        switch (opt)

+        {

+            case 1:

+            {

+                char buffer[126];

+                if (fgets(buffer, sizeof(buffer), stdin) == NULL)

+                {

+                    printf("input error\n");

+                    break;

+                }

+                prama(buffer);

+                gsw_uart_open_ex=(int32_t(*)(int8_t *port, gsw_hal_uart_baudrate, uint32_t, int8_t, uint32_t))dlsym(dlHandle_uart, "gsw_uart_open_ex");

+                fd = gsw_uart_open_ex(port, baudrate, bits, parity, stop);

+                if(fd < 0)

+                {

+                    printf("gsw_uart_open_ex FAIL.\n");

+                    break;

+                }

+                

+                printf("gsw_uart_open_ex success.\n");

+                break;

+            }

+

+            case 2:

+            {

+                gsw_uart_flush=(int32_t(*)(int32_t))dlsym(dlHandle_uart, "gsw_uart_flush");

+                ret = gsw_uart_flush(fd);

+                if(ret < 0)

+                {

+                    printf("gsw_uart_flush FAIL.\n");

+                    break;

+                }

+                printf("gsw_uart_flush success.\n");

+                break;

+            }

+

+            case 3:

+            {

+                gsw_uart_close=(int32_t(*)(int32_t))dlsym(dlHandle_uart, "gsw_uart_close");

+                ret = gsw_uart_close(fd);

+                if(ret < 0)

+                {

+                    printf("gsw_uart_close FAIL.\n");

+                    break;

+                }

+                free(port);

+                printf("gsw_uart_close success.\n");

+                return 0;

+            }

+

+            case 4:

+            {

+                const uint8_t *buf = (const uint8_t *)"Hello ward";

+                gsw_uart_write=(int32_t(*)(int32_t, const uint8_t *buffer, uint32_t))dlsym(dlHandle_uart, "gsw_uart_write");

+                ret = gsw_uart_write(fd, buf, strlen((const char* )buf));

+                if(ret < 0)

+                {

+                    printf("gsw_uart_write FAIL.\n");

+                    break;

+                }

+                printf("gsw_uart_write success.\n");

+                break;

+            }

+

+            case 5:

+            {

+                printf("Non-blocking read : 0\nBlockage : 1\nTimeout time (milliseconds) : greater than 1\n");

+                ret = scanf("%d",&timeout_ms); 

+                gsw_uart_read=(int32_t(*)(int32_t, uint8_t *buffer, uint32_t, int32_t))dlsym(dlHandle_uart, "gsw_uart_read");

+                pthread_create(&read_thread, NULL, read_function, (void *)&timeout_ms);

+                pthread_join(read_thread, NULL);

+                break;

+            }

+

+            case 6:

+            {

+                char buf[128] = "Hello ward";

+                gsw_uart_ioctl=(int32_t(*)(int32_t, uint32_t, void *pvalue))dlsym(dlHandle_uart, "gsw_uart_ioctl");

+                ret = gsw_uart_ioctl(fd, MY_IOCTL_CMD3, buf);

+                if(ret < 0)

+                {

+                    printf("gsw_uart_ioctl FAIL.\n");

+                    break;

+                }

+                printf("gsw_uart_ioctl success.\n");

+                break;

+            }

+        }

+

+    }

+    return 0;

+}

diff --git a/mbtk/test/libgsw_lib/gsw_usb_test.c b/mbtk/test/libgsw_lib/gsw_usb_test.c
new file mode 100755
index 0000000..8d58ed9
--- /dev/null
+++ b/mbtk/test/libgsw_lib/gsw_usb_test.c
@@ -0,0 +1,95 @@
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <termios.h>
+#include <time.h>
+#include <sys/ioctl.h>
+#include <dlfcn.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "gsw_usb.h"
+
+int32_t (*gsw_usb_permanent_switch_demo)(EN_GSW_USB_SWITCH_TYPE type);
+int32_t (*gsw_usb_tempporary_switch_demo)(EN_GSW_USB_SWITCH_TYPE type);
+void *dlHandle;
+char *lynqLib = "/lib/libgsw_lib.so";
+
+int main(int argc, char *argv[])
+{
+    int ret;
+    EN_GSW_USB_SWITCH_TYPE type;
+    bool usb_change = false;
+    if(argc != 2)
+    {
+        printf("parameter error,please input open or close\n");
+        return -1;
+    }
+
+    if(strcmp(argv[0],"gsw_usb_test") == 0)
+        usb_change = true;
+    else
+        usb_change = false;
+    printf("usb is %s\n",argv[1]);
+    if(strcmp(argv[1],"open") == 0)
+        type = EN_GSW_USB_SWITCH_OPEN;
+    else if(strcmp(argv[1],"close") == 0)
+        type = EN_GSW_USB_SWITCH_CLOSE;
+    else
+    {
+        printf("parameter error,please input open or close\n");
+        return -1;
+    }
+    dlHandle = dlopen(lynqLib, RTLD_NOW);
+    if(dlHandle == NULL)
+    {
+        printf("dlopen libgsw_lib fail\n");
+        return -1;
+    }
+    if(usb_change)
+    {
+        gsw_usb_permanent_switch_demo=(int32_t(*)(EN_GSW_USB_SWITCH_TYPE type))dlsym(dlHandle, "gsw_usb_permanent_switch");
+        if(gsw_usb_permanent_switch_demo == NULL)
+        {
+            printf("dlsym gsw_usb_permanent_switch_demo fail\n");
+            return -1;
+        }
+        ret = gsw_usb_permanent_switch_demo(type);
+        if(ret)
+        {
+            printf("gsw_usb_permanent_switch_demo fail\n");
+        }
+        else
+        {
+            printf("gsw_usb_permanent_switch_demo successful\n");
+        }
+    }
+    else
+    {
+        gsw_usb_tempporary_switch_demo=(int32_t(*)(EN_GSW_USB_SWITCH_TYPE type))dlsym(dlHandle, "gsw_usb_tempporary_switch");
+        if(gsw_usb_tempporary_switch_demo == NULL)
+        {
+            printf("dlsym gsw_usb_tempporary_switch_demo fail\n");
+            return -1;
+        }
+        ret = gsw_usb_tempporary_switch_demo(type);
+        if(ret)
+        {
+            printf("gsw_usb_tempporary_switch_demo fail\n");
+        }
+        else
+        {
+            printf("gsw_usb_tempporary_switch_demo successful\n");
+        }
+    }
+    
+    
+    return 0;
+}
diff --git a/mbtk/test/libgsw_lib/gsw_uuid_test.c b/mbtk/test/libgsw_lib/gsw_uuid_test.c
new file mode 100755
index 0000000..f02ccb2
--- /dev/null
+++ b/mbtk/test/libgsw_lib/gsw_uuid_test.c
@@ -0,0 +1,70 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+
+#define CPMEM_DEVICE "/dev/cpmem"
+#define CPLOAD_IOC_MAGIC 'Z'
+#define CPLOAD_IOCTL_SET_CP_ADDR _IOW(CPLOAD_IOC_MAGIC, 1, int)
+#define CPLOAD_IOCTL_GET_CP_FUSE _IOR(CPLOAD_IOC_MAGIC, 2, int)
+
+static int getUniqueKey(unsigned char *key, int keylen)
+{
+    unsigned char ukey[24];
+    int fd;
+
+    if (keylen < 16)
+    {
+        fprintf(stderr, "Error: Key length must be at least 16 bytes.\n");
+        return -1;
+    }
+
+    fd = open(CPMEM_DEVICE, O_RDONLY);
+    if (fd == -1)
+    {
+        perror("Error opening device");
+        return -1;
+    }
+
+    memset(ukey, 0, sizeof(ukey));
+
+    if (ioctl(fd, CPLOAD_IOCTL_GET_CP_FUSE, ukey) == -1)
+    {
+        perror("Error in ioctl");
+        close(fd);
+        return -1;
+    }
+
+    close(fd);
+
+    memcpy(key, ukey, 8);
+    memcpy(&key[8], ukey, 8);
+
+    return 0;
+}
+
+int main()
+{
+    unsigned char key[16];
+    int ret;
+
+    ret = getUniqueKey(key, sizeof(key));
+    if (ret == 0)
+    {
+        printf("Unique Key: ");
+        for (int i = 0; i < sizeof(key)/2; i++)
+        {
+            printf("%02x", key[i]);
+        }
+        printf("\n");
+    }
+    else
+    {
+        fprintf(stderr, "Failed to get unique key.\n");
+        return EXIT_FAILURE;
+    }
+
+    return EXIT_SUCCESS;
+}
\ No newline at end of file
diff --git a/mbtk/test/libgsw_lib/gsw_voice_test.c b/mbtk/test/libgsw_lib/gsw_voice_test.c
new file mode 100755
index 0000000..894ac86
--- /dev/null
+++ b/mbtk/test/libgsw_lib/gsw_voice_test.c
@@ -0,0 +1,494 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <dlfcn.h>
+#include <stdint.h>
+#include <string.h>
+#include <pthread.h>
+
+// mbtk includes
+
+typedef unsigned int uint32;
+typedef unsigned char uint8;
+typedef unsigned short uint16;
+typedef void (*mbtk_info_callback_func)(const void* data, int data_len);
+
+typedef struct
+{
+    int client_fd;
+    pthread_t read_thread_id;
+    int exit_fd[2];
+    bool is_waitting;
+    pthread_cond_t cond;
+    pthread_mutex_t mutex;
+
+    pthread_mutex_t send_mutex;
+
+    // Temp response data.
+    uint16 info_err;
+    uint16 data_len;
+    void *data;
+
+    //mbtk wyq for server_ready_status add start
+    char server_ready_status;
+    //mbtk wyq for server_ready_status add end
+
+    mbtk_info_callback_func net_state_cb;
+    mbtk_info_callback_func call_state_cb;
+    mbtk_info_callback_func sms_state_cb;
+    mbtk_info_callback_func radio_state_cb;
+    mbtk_info_callback_func sim_state_cb;
+    mbtk_info_callback_func pdp_state_cb;
+    //add signal by xr
+    mbtk_info_callback_func signal_state_cb;
+} mbtk_info_handle_t;
+
+typedef struct
+{
+    uint8 call_wait;
+    uint8 dir1;
+    uint8 dir;
+    uint8 state;
+    uint8 mode;
+    uint8 mpty;
+    char phone_number[100];
+    uint8 type;
+    uint8 pas;
+    uint8 disconnected_id;
+} __attribute__((packed)) mbtk_call_info_t;
+
+typedef enum {
+    MBTK_CLCC = 1,
+    MBTK_CPAS,
+    MBTK_DISCONNECTED,
+} mbtk_call_enum;
+
+typedef enum {
+    MBTK_CALL_RADY,                 //MT allows commands from TA/TE
+    MBTK_CALL_UNAVAILABLE,          //MT does not allow commands from TA/TE
+    MBTK_CALL_UNKNOWN,              //MT is not guaranteed to respond to instructions
+    MBTK_CALL_RINGING,              //MT is ready for commands from TA/TE, but the ringer is active
+    MBTK_CALL_PROGRESS,             //MT is ready for commands from TA/TE, but a call is in progress
+    MBTK_CALL_ASLEEP,               //MT is unable to process commands from TA/TE because it is in a low functionality state
+    MBTK_CALL_ACTIVE,
+} mbtk_call_pas_enum;
+
+typedef uint32_t voice_client_handle_type;
+
+
+// GSW includes
+#define GSW_HAL_SUCCESS 0
+#define GSW_HAL_FAIL -1
+#define GSW_HAL_MEM_INVAILD -2
+
+
+typedef int CallHandle;
+typedef enum {
+    GSW_VOICE_CALL_HOLDING = 0,
+    GSW_VOICE_CALL_DIALING,
+    GSW_VOICE_CALL_ALERTING,
+    GSW_VOICE_CALL_CONNECTED,
+    GSW_VOICE_CALL_INCOMING,
+    GSW_VOICE_CALL_WAITING,
+    GSW_VOICE_CALL_END,
+}VoiceCallState;
+
+typedef enum{
+    GSW_AUDIO_MODE_CODEC = 0,
+    GSW_AUDIO_MODE_RTP = 1,
+}AudioMode;
+
+typedef enum {
+    GSW_RTP_CLIENT = 0,
+    GSW_RTP_SERVER,
+}RTPMode;
+
+typedef void (*CallStateInd)(CallHandle, VoiceCallState);
+
+
+int32_t (*gsw_voice_sdk_init)(CallStateInd ind);
+int32_t (*gsw_voice_set_speaker_volume)(int32_t volume);
+int32_t (*gsw_voice_normal_voice_start)(CallHandle *handle, const char *callNumber);
+int32_t (*gsw_voice_answer)(CallHandle handle);
+int32_t (*gsw_voice_hangup)(CallHandle handle);
+int32_t (*gsw_voice_set_auto_answer_mode)(int32_t mode);
+int32_t (*gsw_voice_get_current_call_end_reason)(CallHandle handle);
+/*#############################rtp begin*/
+int32_t (*gsw_voice_set_audio_mode)(AudioMode audioMode);
+int32_t (*gsw_voice_set_remote_rtp_ip)(const char *ip, int32_t len);
+int32_t (*gsw_voice_set_rtp_port)(RTPMode rtpMode, int32_t port);
+int32_t (*gsw_voice_set_rtp_param)(int32_t clockRate, int32_t channel, int32_t latency);
+/*#############################rtp end*/
+
+CallHandle call_handle;
+
+#define lib_gsw_voice_path "/lib/libgsw_lib.so"
+static void *dlHandle_voice = NULL;
+
+void gsw_test_callback(CallHandle handle, VoiceCallState state)
+{
+
+    printf("gsw_test_callback succeess!\n");
+    printf("id = %d, state = %d\n", handle, state);
+
+    call_handle = handle;
+    printf("set call_handle = %d\n", call_handle);
+    printf("call_handle = %d\n", call_handle);
+
+}
+
+static int gsw_rtp_api_import()
+{
+   gsw_voice_set_audio_mode = (int32_t (*)(AudioMode audioMode))dlsym(dlHandle_voice, "gsw_voice_set_audio_mode");
+   if(gsw_voice_set_audio_mode == NULL) {
+       printf("dlsym gsw_voice_set_audio_mode failed: %s\n", dlerror());
+       return -1;
+   }
+
+
+   gsw_voice_set_remote_rtp_ip = (int32_t (*)(const char *ip, int32_t len))dlsym(dlHandle_voice, "gsw_voice_set_remote_rtp_ip");
+   if(gsw_voice_set_remote_rtp_ip == NULL) {
+       printf("dlsym gsw_voice_set_remote_rtp_ip failed: %s\n", dlerror());
+       return -1;
+   }
+
+       
+   gsw_voice_set_rtp_port = (int32_t (*)(RTPMode rtpMode, int32_t port))dlsym(dlHandle_voice, "gsw_voice_set_rtp_port");
+   if(gsw_voice_set_rtp_port == NULL) {
+       printf("dlsym gsw_voice_set_rtp_port failed: %s\n", dlerror());
+       return -1;
+   }
+
+   
+   gsw_voice_set_rtp_param = (int32_t (*)(int32_t clockRate, int32_t channel, int32_t latency))dlsym(dlHandle_voice, "gsw_voice_set_rtp_param");
+   if(gsw_voice_set_rtp_param == NULL) {
+       printf("dlsym gsw_voice_set_rtp_param failed: %s\n", dlerror());
+       return -1;
+   }
+
+   gsw_voice_get_current_call_end_reason = (int32_t (*)(CallHandle handle))dlsym(dlHandle_voice, "gsw_voice_get_current_call_end_reason");
+   if(gsw_voice_get_current_call_end_reason == NULL) {
+       printf("dlsym gsw_voice_get_current_call_end_reason failed: %s\n", dlerror());
+       return -1;
+   }
+   
+   return 0;
+
+}
+
+
+
+static int gsw_call_api_import()
+{
+    dlHandle_voice = dlopen(lib_gsw_voice_path, RTLD_NOW);
+    if (!dlHandle_voice) {
+        printf("dlopen %s failed: %s\n", lib_gsw_voice_path, dlerror());
+        return -1;
+    }
+
+    gsw_voice_sdk_init = (int32_t (*)(CallStateInd ind))dlsym(dlHandle_voice, "gsw_voice_sdk_init");
+    if(gsw_voice_sdk_init == NULL) {
+        printf("dlsym gsw_voice_sdk_init failed: %s\n", dlerror());
+        return -1;
+    }
+
+    gsw_voice_set_speaker_volume = (int32_t (*)(int32_t volume))dlsym(dlHandle_voice, "gsw_voice_set_speaker_volume");
+    if(gsw_voice_set_speaker_volume == NULL) {
+        printf("dlsym gsw_voice_set_speaker_volume failed: %s\n", dlerror());
+        return -1;
+    }
+    
+    gsw_voice_normal_voice_start = (int32_t (*)(CallHandle *, const char *))dlsym(dlHandle_voice, "gsw_voice_normal_voice_start");
+    if(gsw_voice_normal_voice_start == NULL) {
+        printf("dlsym gsw_voice_normal_voice_start failed: %s\n", dlerror());
+        return -1;
+    }
+
+    gsw_voice_answer = (int32_t (*)(CallHandle handle))dlsym(dlHandle_voice, "gsw_voice_answer");
+    if(gsw_voice_answer == NULL) {
+        printf("dlsym gsw_voice_answer failed: %s\n", dlerror());
+        return -1;
+
+    }
+
+    gsw_voice_hangup = (int32_t (*)(CallHandle handle))dlsym(dlHandle_voice, "gsw_voice_hangup");
+    if(gsw_voice_hangup == NULL) {
+        printf("dlsym gsw_voice_hangup failed: %s\n", dlerror());
+        return -1;
+    }
+
+    gsw_voice_set_auto_answer_mode = (int32_t (*)(int32_t mode))dlsym(dlHandle_voice, "gsw_voice_set_auto_answer_mode");
+    if(gsw_voice_set_auto_answer_mode == NULL) {
+        printf("dlsym gsw_voice_set_auto_answer_mode failed: %s\n", dlerror());
+        return -1;
+    }
+
+    return gsw_rtp_api_import();
+}
+
+int main() 
+{
+    char operator[10];
+    int opt;
+    int ret;
+
+    gsw_call_api_import();
+
+    while(1)
+    {
+        printf("=========gsw voice main=========\n"
+        "\t-1 exit\n"
+        "\t1 voice init\n"
+        "\t2 voice dial\n"
+        "\t3 voice hangup\n"
+        "\t4 voice answer\n"
+        "\t5 set auto answer mode\n"
+        "\t6 set speaker volume\n"        
+        "\t7 set audio mode (local codec or rtp) \n"
+        "\t8 set remote rtp ip\n"
+        "\t9 set rtp port\n"
+        "\t10 set rtp param\n"
+        "\t11 get current call end reason\n"
+        "operator: >> \n");
+
+		memset(operator, 0, sizeof(operator));
+        printf("%s\n",fgets(operator, sizeof(operator), stdin));
+        fflush(stdin);
+        opt = atoi(operator);
+        switch (opt)
+        {
+        case -1:
+            printf("main exit\n");
+            return 0;
+        case 1:
+            {
+                printf(">>>>>voice init\n");
+				ret = gsw_voice_sdk_init(gsw_test_callback);
+				if(ret != 0)
+				{
+					printf("gsw_voice_sdk_init fail\n");
+				}
+				else
+				{
+					printf("gsw_voice_sdk_init success\n");
+				}
+            }
+            break;
+        case 2:
+            {
+                printf(">>>>>Input gsw_voice_normal_voice_start<<<<<\n");
+                char number[16] = {0};
+                printf("Enter call number\n");
+                printf("%d\n",scanf("%15s", number));
+                printf("call number is %s\n", number);
+
+                ret = gsw_voice_normal_voice_start(&call_handle, number);
+				if(ret < 0)
+				{
+					printf("gsw_voice_normal_voice_start fail\n");
+				}
+				else
+				{
+					printf("gsw_voice_normal_voice_start success\n");
+				}
+            }
+            break;
+        case 3:
+            {
+                printf(">>>>>Input gsw_voice_hangup<<<<<\n");
+                printf("call_handle is %d\n", call_handle);
+                ret = gsw_voice_hangup(call_handle);
+                if(ret < 0)
+                {
+                    printf("gsw_voice_hangup fail\n");
+                }
+                else
+                {
+                    printf("gsw_voice_hangup success\n");
+                }
+            }
+            break;
+        case 4:
+            {
+                printf(">>>>>Input gsw_voice_answer<<<<<\n");
+                printf("call_handle is %d\n", call_handle);
+                ret = gsw_voice_answer(call_handle);
+				if(ret < 0)
+				{
+					printf("gsw_voice_answer fail\n");
+				}
+				else
+				{
+					printf("gsw_voice_answer success\n");
+				}
+            }
+            break;
+        case 5:
+            {
+                printf(">>>>>Input gsw_voice_set_auto_answer_mode<<<<<\n");
+
+                int mode = 0;
+                printf("Enter set mode\n");
+                printf("%d\n",scanf("%d", &mode));
+                fflush(stdin);
+                printf("mode is %d\n", mode);
+
+                printf("start set auto answer mode(0:disable, 1:enable)\n");
+                ret = gsw_voice_set_auto_answer_mode(mode);
+				if(ret < 0)
+				{
+					printf("gsw_voice_set_auto_answer_mode fail\n");
+				}
+				else
+				{
+					printf("gsw_voice_set_auto_answer_mode success\n");
+				}
+            }
+            break;
+         case 6:
+            {
+                printf(">>>>>Input gsw_voice_set_speaker_volume<<<<<\n");
+
+
+                int volume;
+                
+                printf("Enter set volume\n");
+                printf("%d\n",scanf("%d", &volume));
+                fflush(stdin);
+                printf("volume is %d\n", volume);
+                
+                ret = gsw_voice_set_speaker_volume(volume);
+				if(ret < 0)
+				{
+					printf("gsw_voice_set_speaker_volume fail\n");
+				}
+				else
+				{
+					printf("gsw_voice_set_speaker_volume success\n");
+				}
+            }
+            break;
+        /*#############################rtp begin*/         
+        case 7:
+            {
+                printf(">>>>>Input gsw_voice_set_audio_mode<<<<<\n");
+
+                int mode;    
+
+                printf("Enter set mode (0: local codec, 1:rtp)\n");                
+                printf("%d\n",scanf("%d", &mode));
+                fflush(stdin);
+                printf("mode is %d\n", mode);               
+                                
+                ret = gsw_voice_set_audio_mode(mode);
+				if(ret != 0)
+				{
+					printf("gsw_voice_set_audio_mode fail\n");
+				}
+				else
+				{
+					printf("gsw_voice_set_audio_mode success\n");
+				}
+            }
+            break;
+
+        case 8:
+            {
+                printf(">>>>>Input gsw_voice_set_remote_rtp_ip<<<<<\n");
+
+                char remote_ip_addr[100] = {0};
+                
+                printf("Enter set remote rtp ip address (***.***.***.***) \n");
+                printf("%d\n",scanf("%s", remote_ip_addr));
+                fflush(stdin);
+                printf("remote rtp ip address is %s\n", remote_ip_addr);              
+                              
+                ret = gsw_voice_set_remote_rtp_ip(remote_ip_addr,strlen(remote_ip_addr)+1);
+                if(ret != 0)
+                {
+                    printf("gsw_voice_set_remote_rtp_ip fail\n");
+                }
+                else
+                {
+                    printf("gsw_voice_set_remote_rtp_ip success\n");
+                }
+            }
+            break;
+
+        case 9:
+            {
+                printf(">>>>>Input gsw_voice_set_rtp_port<<<<<\n");
+
+                int mode;    
+                int port;               
+                printf("Enter set mode (0: server, 1:client)\n");
+                printf("%d\n",scanf("%d", &mode));
+                fflush(stdin);
+                printf("mode is %d\n", mode);
+                
+                printf("Enter set port\n");
+                printf("%d\n",scanf("%d", &port));
+                fflush(stdin);
+                printf("port is %d\n", port);
+                
+                ret = gsw_voice_set_rtp_port(mode,port);
+				if(ret != 0)
+				{
+					printf("gsw_voice_set_rtp_port fail\n");
+				}
+				else
+				{
+					printf("gsw_voice_set_rtp_port success\n");
+				}
+            }
+            break;
+
+            
+        case 10:
+            {
+                printf(">>>>>Input gsw_voice_set_rtp_param<<<<<\n");
+
+                int clockRate;
+                int channel;
+                int latency=400;
+                
+                printf("Enter set clockRate (only 8000 and 16000 supoort) \n");
+                printf("%d\n",scanf("%d", &clockRate));
+                fflush(stdin);
+                printf("clockRate is %d\n", clockRate);
+                
+                printf("Enter set channel (only 1 support)\n");
+                printf("%d\n",scanf("%d", &channel));
+                fflush(stdin);
+                printf("channel is %d\n", channel);
+                
+                ret = gsw_voice_set_rtp_param(clockRate, channel, latency);
+                if(ret != 0)
+                {
+                    printf("gsw_voice_set_rtp_param fail\n");
+                }
+                else
+                {
+                    printf("gsw_voice_set_rtp_param success\n");
+                }
+            }
+            break;          
+        /*#############################rtp end*/
+
+        case 11:
+        {
+            printf(">>>>gsw_voice_get_current_call_end_reason<<<\n");
+            ret = gsw_voice_get_current_call_end_reason(call_handle);
+            printf("gsw_voice_get_current_call_end_reason = %d\n", ret);
+            break;
+        }
+ 
+        default:
+            break;
+        }
+
+    }
+	
+    return 0;
+
+}
diff --git a/mbtk/test/libgsw_lib/lynq_bus_hound_monitor.c b/mbtk/test/libgsw_lib/lynq_bus_hound_monitor.c
new file mode 100755
index 0000000..3a81b8c
--- /dev/null
+++ b/mbtk/test/libgsw_lib/lynq_bus_hound_monitor.c
@@ -0,0 +1,200 @@
+/*@file lynq-ndis-uevent.c 
+* @brief adb default port is closed, The uevent event of NDIS is reported to switch port.
+* @author dongyu
+* @date 2022-10-14
+* @version V1.0
+* @copyright MobileTek
+*/
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <termios.h>
+#include <time.h>
+#include <sys/ioctl.h>
+#include <dlfcn.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <sys/socket.h>
+#include <linux/netlink.h>
+
+#define UEVENT_MSG_LEN 1024
+#define USB_REPORTING 3300
+
+struct uevent {
+    const char *action;
+    const char *path;
+    const char *subsystem;
+    const char *firmware;
+    const char *calluser;
+    int major;
+    int minor;
+};
+
+static int open_uevent_socket(void)
+{
+    struct sockaddr_nl addr;
+    int sz = 64*1024;
+    int on = 1;
+    int s;
+
+    memset(&addr, 0, sizeof(addr));
+    addr.nl_family = AF_NETLINK;
+    addr.nl_pid = getpid();
+    addr.nl_groups = 0xffffffff;
+
+    s = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);
+    if(s < 0)
+        return -1;
+
+    setsockopt(s, SOL_SOCKET, SO_RCVBUFFORCE, &sz, sizeof(sz));
+    setsockopt(s, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
+
+    if(bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+        close(s);
+        return -1;
+    }
+
+    return s;
+}
+
+static void parse_event(const char *msg, struct uevent *uevent)
+{
+    uevent->action = "";
+    uevent->path = "";
+    uevent->subsystem = "";
+    uevent->firmware = "";
+    uevent->calluser = "";
+    uevent->major = -1;
+    uevent->minor = -1;
+
+    /* currently ignoring SEQNUM */
+    while(*msg) {
+        printf("%s\n", msg);
+        if(!strncmp(msg, "ACTION=", 7)) {
+            msg += 7;
+            uevent->action = msg;
+        } else if(!strncmp(msg, "DEVPATH=", 8)) {
+            msg += 8;
+            uevent->path = msg;
+        } else if(!strncmp(msg, "SUBSYSTEM=", 10)) {
+            msg += 10;
+            uevent->subsystem = msg;
+        } else if(!strncmp(msg, "FIRMWARE=", 9)) {
+            msg += 9;
+            uevent->firmware = msg;
+        } else if(!strncmp(msg, "MAJOR=", 6)) {
+            msg += 6;
+            uevent->major = atoi(msg);
+        } else if(!strncmp(msg, "MINOR=", 6)) {
+            msg += 6;
+            uevent->minor = atoi(msg);
+        } else if(!strncmp(msg, "CALL_USER=", 10)) {
+            msg += 10;
+            uevent->calluser = msg;
+        }
+
+        /* advance to after the next \0 */
+        while(*msg++);
+    }
+
+    printf("event { '%s', '%s', '%s', '%s', %d, %d }\n",
+                    uevent->action, uevent->path, uevent->subsystem,
+                    uevent->firmware, uevent->major, uevent->minor);
+}
+
+int handle_device_fd(int fd)
+{
+    printf("enter %s\n", __func__);
+	char cmd[128] = {0};
+    for(;;) {
+        char msg[UEVENT_MSG_LEN+2];
+        char cred_msg[CMSG_SPACE(sizeof(struct ucred))];
+        struct iovec iov = {msg, sizeof(msg)};
+        struct sockaddr_nl snl;
+        struct msghdr hdr = {&snl, sizeof(snl), &iov, 1, cred_msg, sizeof(cred_msg), 0};
+
+        ssize_t n = recvmsg(fd, &hdr, 0);
+        if (n <= 0) {
+            break;
+        }
+
+        if ((snl.nl_groups != 1) || (snl.nl_pid != 0)) {
+            /* ignoring non-kernel netlink multicast message */
+            continue;
+        }
+
+        struct cmsghdr * cmsg = CMSG_FIRSTHDR(&hdr);
+        if (cmsg == NULL || cmsg->cmsg_type != SCM_CREDENTIALS) {
+            /* no sender credentials received, ignore message */
+            continue;
+        }
+
+        struct ucred * cred = (struct ucred *)CMSG_DATA(cmsg);
+        if (cred->uid != 0) {
+            /* message from non-root user, ignore */
+            continue;
+        }
+
+        if(n >= UEVENT_MSG_LEN) /* overflow -- discard */
+            continue;
+
+        msg[n] = '\0';
+        msg[n+1] = '\0';
+ 
+        printf("usb ::: msg =  %s\n", msg);
+        struct uevent uevent;
+        parse_event(msg, &uevent);
+
+	if(strcmp(uevent.calluser, "/usr/bin/usb uevent permanent reporting") == 0){
+		sprintf(cmd, "setprop persist.mbtk.usb_pid %d && /sbin/tmp_usb_init %d &", USB_REPORTING, USB_REPORTING);
+    	int ret = system(cmd);
+		if (ret == -1) {
+			fprintf(stderr, "Error: Failed to execute system command.\n");
+			return 1;
+		}
+		printf("USB login port switch permanent successfully!\n");
+		// while(1){
+		// 	sleep(1);
+		// }
+	}
+    else if(strcmp(uevent.calluser, "/usr/bin/usb uevent tempporary reporting") == 0){
+		sprintf(cmd, "/sbin/tmp_usb_init %d &",USB_REPORTING);
+    	int ret = system(cmd);
+		if (ret == -1) {
+			fprintf(stderr, "Error: Failed to execute system command.\n");
+			return 1;
+		}
+		printf("USB login port switch tempporary successfully!\n");
+		// while(1){
+		// 	sleep(1);
+		// }
+	}
+    
+    }
+	return 0;
+}
+
+int main(void)
+{
+    int fd = 0;
+    
+    fd = open_uevent_socket();
+    if (fd < 0) {
+        printf("error!\n");
+        return -1;
+    }
+    
+    handle_device_fd(fd);
+    while(1){
+    	sleep(1);
+    }
+    return 0;
+}