Add basic change for v1453

Change-Id: I9497a61bbc3717f66413794a4e7dee0347c0bc33
diff --git a/mbtk/mbtk_at/src/mbtk_at_basic.c b/mbtk/mbtk_at/src/mbtk_at_basic.c
new file mode 100755
index 0000000..55638ef
--- /dev/null
+++ b/mbtk/mbtk_at/src/mbtk_at_basic.c
@@ -0,0 +1,2322 @@
+/*
+* MBTK Basic AT Process.
+*
+* Author : lb
+* Date   : 2021/11/5 10:14:32
+*
+*/
+#include "mbtk_at.h"
+#include "mbtk_device_info.h"
+#include "mbtk/mbtk_type.h"
+#include "mbtk/mbtk_device.h"
+#include <dlfcn.h>
+
+//#include <sys/statfs.h>
+#include <sys/vfs.h>
+#include <errno.h>
+#include <linux/magic.h>
+#include <time.h>
+#include <sys/time.h>
+#include <signal.h>
+#include <pthread.h>
+#include <time.h>
+#include <sys/time.h>
+#include <cutils/properties.h>
+#include "configwrapper.h"
+#include<linux/msg.h>
+
+//#include "gps.h"
+#include "atcmdsvr_ubus.h"
+
+#define MAX_GPIO_TEST_NUM 60
+
+typedef int (*mbtk_dev_info_read_func)(mbtk_device_info_item_enum, void *, int);
+
+#define MBTK_LIB_PATH "/lib/libmbtk_lib.so"
+const struct blobmsg_policy gps_user_cb_policy1[] = {
+    [0] = {
+        .name = "event",
+        .type = BLOBMSG_TYPE_INT32,
+    },
+};
+
+bool mbtk_urc_enable = TRUE;
+
+int mbtk_at_loopback(int type);
+int mbtk_at_play(const char *args);
+int mbtk_at_rec(const char *args);
+
+typedef struct
+{
+    int gpio;
+    bool busy;
+    bool state;
+} mbtk_gpio_state_t;
+
+static bool gpio_test_usable = true;
+
+static mbtk_gpio_state_t gpio_pins[] =
+{
+    {22, FALSE, FALSE},     // IN
+    {33,FALSE,FALSE},
+    {35,FALSE,FALSE},
+    {36,FALSE,FALSE},
+    {34,FALSE,FALSE},
+    {21,FALSE,FALSE},
+    {4,FALSE,FALSE},
+    {123,FALSE,FALSE},
+    {20,FALSE,FALSE},
+    {43,FALSE,FALSE},
+    {13,FALSE,FALSE},
+//    {12,FALSE,FALSE},
+    {14,FALSE,FALSE},
+    {118,FALSE,FALSE},
+//    {19,FALSE,FALSE},
+    {120,FALSE,FALSE},
+    {49,FALSE,FALSE},
+    {50,FALSE,FALSE},
+    {32,FALSE,FALSE},
+    {31,FALSE,FALSE},
+    {51,FALSE,FALSE},
+//    {23,FALSE,FALSE},
+    {24,FALSE,FALSE},
+    {52,FALSE,FALSE},
+    {27,FALSE,FALSE},
+    {28,FALSE,FALSE},
+    {26,FALSE,FALSE},
+    {25,FALSE,FALSE},
+    {5,FALSE,FALSE},
+    {0,FALSE,FALSE},
+    {1,FALSE,FALSE},
+    {2,FALSE,FALSE},
+    {3,FALSE,FALSE},
+    {6,FALSE,FALSE},
+    {7,FALSE,FALSE},
+    {15,FALSE,FALSE},
+    {18,FALSE,FALSE},
+    {16,FALSE,FALSE},
+    {17,FALSE,FALSE},
+    {54,FALSE,FALSE},
+    {53,FALSE,FALSE},
+    {48,FALSE,FALSE},
+    {55,FALSE,FALSE},
+    {58,FALSE,FALSE},
+    {57,FALSE,FALSE},
+    {29,FALSE,FALSE},
+    {30,FALSE,FALSE},
+    {99,FALSE,FALSE},
+    {126,FALSE,FALSE},
+    {125,FALSE,FALSE},
+    {56,FALSE,FALSE},
+    {59,FALSE,FALSE},
+    {117,FALSE,FALSE},
+//    {122,FALSE,FALSE}
+};
+
+int gpio_register_auto_test_out(int *result);
+
+#define MBTK_GPIO_NUM (sizeof(gpio_pins)/sizeof(mbtk_gpio_state_t))
+
+static bool dev_info_inited = FALSE;
+static mbtk_device_info_basic_t info_basic;
+static mbtk_device_info_modem_t info_modem;
+
+static int dev_info_get()
+{
+    if(dev_info_inited) {
+        return 0;
+    }
+    void *handle = dlopen(MBTK_LIB_PATH , RTLD_LAZY);
+    if(handle == NULL)
+    {
+        DBGMSG(MBTK_AT, "dlopen() %s fail : %d", MBTK_LIB_PATH, errno);
+        return -1;
+    }
+
+    mbtk_dev_info_read_func dev_info_read = (mbtk_dev_info_read_func)dlsym(handle, "mbtk_dev_info_read");
+    if(dev_info_read == NULL)
+    {
+        DBGMSG(MBTK_AT, "dlsym(mbtk_dev_info_read) fail : %d", errno);
+        return -1;
+    }
+
+    memset(&info_basic, 0, sizeof(mbtk_device_info_basic_t));
+    memset(&info_modem, 0, sizeof(mbtk_device_info_modem_t));
+
+    // mbtk_dev_info_read()
+    int result = dev_info_read(MBTK_DEVICE_INFO_ITEM_BASIC, &info_basic, sizeof(mbtk_device_info_basic_t));
+    if(result) {
+        DBGMSG(MBTK_AT, "mbtk_dev_info_read(BASIC) fail.");
+        return -1;
+    }
+
+    result = dev_info_read(MBTK_DEVICE_INFO_ITEM_MODEM, &info_modem, sizeof(mbtk_device_info_modem_t));
+    if(result) {
+        DBGMSG(MBTK_AT, "mbtk_dev_info_read(MODEM) fail.");
+        return -1;
+    }
+
+    dev_info_inited = TRUE;
+    return 0;
+}
+
+static char* band_area_2_str(mbtk_modem_band_area_enum band_area)
+{
+    switch(band_area) {
+        case MBTK_MODEM_BAND_AREA_CN:
+            return "CN";
+        case MBTK_MODEM_BAND_AREA_EU:
+            return "EU";
+        case MBTK_MODEM_BAND_AREA_SA:
+            return "SA";
+        default:
+            return "DEF";
+    }
+}
+
+static int gpio_export(void)
+{
+    int index=0;
+    int file=-1;
+    int result =-1;
+    char pin_index_buffer[5]= {0};
+
+    for(index = 0; index < MBTK_GPIO_NUM; index++)
+    {
+        file = open("/sys/class/gpio/export",O_WRONLY);
+        if(file == -1)
+        {
+            LOG("Open gpio export file fail.");
+            return -1;
+        }
+
+        memset(pin_index_buffer,0,5);
+        sprintf(pin_index_buffer,"%d",gpio_pins[index].gpio);
+        result = write(file,pin_index_buffer,strlen(pin_index_buffer));
+        if(result < 0)
+        {
+            LOG("Gpio[%d] export fail.", gpio_pins[index].gpio);
+            gpio_pins[index].busy = TRUE;
+        }
+        close(file);
+    }
+
+    return 0;
+}
+
+static int gpio_unexport(void)
+{
+    int index=0;
+    int file=-1;
+    int result =-1;
+    char pin_index_buffer[5]= {0};
+
+    for(index = 0; index < MBTK_GPIO_NUM; index++)
+    {
+        if(!gpio_pins[index].busy)
+        {
+            file = open("/sys/class/gpio/unexport",O_WRONLY);
+            if(file == -1)
+            {
+                LOG("Open gpio unexport file fail.");
+                return -1;
+            }
+
+            memset(pin_index_buffer,0,5);
+            sprintf(pin_index_buffer,"%d",gpio_pins[index].gpio);
+            result=write(file,pin_index_buffer,strlen(pin_index_buffer));
+            if(result < 0)
+            {
+                close(file);
+                LOG("Gpio[%d] unexport fail.",gpio_pins[index].gpio);
+                return -1;
+            }
+            close(file);
+        }
+    }
+
+    return 0;
+}
+
+static int gpio_direct_set(char *value,int gpio)
+{
+    char buffer[50]= {0};
+    int file =-1;
+    int result =-1;
+
+    memset(buffer,0,50);
+    sprintf(buffer,"/sys/class/gpio/gpio%d/direction", gpio);
+    file = open(buffer, O_WRONLY);
+    if(file == -1)
+    {
+        LOG("Open gpio[%d] direct fail.", gpio);
+        return -1;
+    }
+
+    result = write(file,value,strlen(value));
+    if(result != strlen(value))
+    {
+        LOG("Set gpio[%d] direct fail.", gpio);
+        close(file);
+        return -1;
+    }
+    close(file);
+
+    return 0;
+}
+
+static int gpio_value_get(int gpio)
+{
+    char buffer[50];
+    char path[10];
+    int file =-1;
+    int result =-1;
+    int value;
+
+    memset(path,0,50);
+    memset(buffer,0,10);
+    sprintf(path,"/sys/class/gpio/gpio%d/value", gpio);
+    file = open(path,O_RDONLY);
+    if(file == -1)
+    {
+        LOG("Open gpio[%d] fail.", gpio);
+        return -1;
+    }
+    result = read(file,buffer,5);
+    if(result <= 0)
+    {
+        LOG("Get gpio[%d] value fail", gpio);
+        close(file);
+        return -1;
+    }
+    close(file);
+    value = atoi(buffer);
+    return value;
+}
+
+static int gpio_value_set(int value, int gpio)
+{
+    char buffer[50]= {0};
+    int file =-1;
+    int result =-1;
+
+    memset(buffer,0,50);
+    sprintf(buffer,"/sys/class/gpio/gpio%d/value", gpio);
+    file = open(buffer,O_WRONLY);
+    if(file == -1)
+    {
+        LOG("Open gpio[%d] value fail.", gpio);
+        return -1;
+    }
+    if(value == 0) {
+        result = write(file,"0",1);
+    } else {
+        result = write(file,"1",1);
+    }
+    if(result != 1)
+    {
+        LOG("Set gpio[%d] value fail.", gpio);
+        close(file);
+        return -1;
+    }
+    close(file);
+
+    return 0;
+}
+
+//type:0 value 0
+//type:1 value 1
+//type:2 direction "out"
+//type:3 direction "in"
+
+static int one_gpio_export(int gpio, int type)
+{
+    int index=0;
+    int file=-1;
+    int file1=-1;
+    int result =-1;
+    char pin_index_buffer[5]= {0};
+    char buffer[50]= {0};
+    int ret =0;
+
+    file = open("/sys/class/gpio/export",O_WRONLY);
+    if(file == -1)
+    {
+        LOG("Open gpio export file fail.");
+        return -1;
+    }
+
+    memset(buffer,0,50);
+    sprintf(buffer,"/sys/class/gpio/gpio%d", gpio);
+    file1 = open(buffer,O_RDONLY);
+    if(file1 != -1)
+    {
+        //file is created
+    }
+    else{ // create gpio
+        memset(pin_index_buffer,0,5);
+        sprintf(pin_index_buffer,"%d",gpio);
+        result = write(file,pin_index_buffer,strlen(pin_index_buffer));
+        if(result < 0)
+        {
+            ATRESP(IND_REQ_HANDLE , ATCI_RESULT_CODE_NULL, 0, "Gpio export fail");
+            LOG("Gpio[%d] export fail.", gpio);
+            return -1;
+        }
+    }
+
+    close(file);
+
+
+    switch(type)
+    {
+        case 0 :
+        {
+            ret = gpio_value_set(0, gpio);
+            break;
+        }
+        case 1:
+        {
+            ret = gpio_value_set(1, gpio);
+            break;
+        }
+        case 2:
+        {
+            ret = gpio_direct_set("out", gpio);
+            break;
+        }
+        case 3:
+        {
+            ret = gpio_direct_set("in", gpio);
+            break;
+        }
+        default:
+        {
+            break;
+        }
+    }
+
+
+    return ret;
+}
+
+
+static int gpio_test(void)
+{
+    int index = 0;
+    int fail_count = 0;
+    gpio_export();
+
+    gpio_direct_set("in", gpio_pins[0].gpio);
+    //set all gpio low level start
+    for(index = 1; index < MBTK_GPIO_NUM; index++)
+    {
+        if(!gpio_pins[index].busy)
+        {
+            gpio_direct_set("out", gpio_pins[index].gpio);
+            gpio_value_set(0, gpio_pins[index].gpio);
+        }
+    }
+
+    if(gpio_value_get(gpio_pins[0].gpio) != 0)
+    {
+        LOG("gpio_test set all gpio level[%d] fail", gpio_pins[0].gpio);
+        gpio_unexport();
+        return -1;
+    }
+    //set all gpio low level end
+
+#if 1
+    for(index = 1; index < MBTK_GPIO_NUM; index++)
+    {
+        if(!gpio_pins[index].busy)
+        {
+            gpio_value_set(1, gpio_pins[index].gpio);
+            if(gpio_value_get(gpio_pins[index].gpio) == 1 && gpio_value_get(gpio_pins[0].gpio) == 1)
+            {
+                gpio_pins[index].state = TRUE;
+            }
+            else
+            {
+                LOG("gpio[%d] input not match output level [1]", gpio_pins[index].gpio);
+                gpio_pins[index].state = FALSE;
+                fail_count++;
+                continue;
+            }
+        }
+    }
+
+    if(fail_count > 0) {
+        gpio_unexport();
+        return fail_count;
+    }
+
+    for(index = 1; index < MBTK_GPIO_NUM; index++)
+    {
+        if(!gpio_pins[index].busy)
+        {
+            gpio_value_set(0, gpio_pins[index].gpio);
+            if(gpio_value_get(gpio_pins[index].gpio) == 0 && gpio_value_get(gpio_pins[0].gpio) == 0)
+            {
+                gpio_pins[index].state = TRUE;
+            }
+            else
+            {
+                LOG("gpio[%d] input not match output level [0]", gpio_pins[index].gpio);
+                gpio_pins[index].state = FALSE;
+                fail_count++;
+                continue;
+            }
+        }
+    }
+
+    gpio_unexport();
+#endif
+    return fail_count;
+}
+
+static int gpio_test2(void)
+{
+    int index=0;
+    int value=0;
+    int fail_count = 0;
+    //export all test gpio
+    gpio_export();
+
+
+    //set main control gpio in
+    gpio_direct_set("in", gpio_pins[0].gpio);
+    for(index = 1; index < MBTK_GPIO_NUM; index++)
+    {
+        gpio_direct_set("out",gpio_pins[index].gpio);
+        gpio_value_set(1, gpio_pins[index].gpio);
+    }
+
+    if(gpio_value_get(gpio_pins[0].gpio) != 1)
+    {
+        LOG("gpio_test set all gpio level[%d] fail", gpio_pins[0].gpio);
+        gpio_unexport();
+        return -1;
+    }
+
+    //set all gpio value as 0
+    for(index = 1; index < MBTK_GPIO_NUM; index++)
+    {
+        gpio_value_set(0, gpio_pins[index].gpio);
+    }
+
+    //set gpio direct in except main control gpio
+    for(index = 1; index < MBTK_GPIO_NUM; index++)
+    {
+        gpio_direct_set("in",gpio_pins[index].gpio);
+    }
+
+    //set main control gpio out
+    gpio_direct_set("out",gpio_pins[0].gpio);
+    gpio_value_set(1,gpio_pins[0].gpio);
+    for(index = 1; index < MBTK_GPIO_NUM; index++)
+    {
+        value = -1;
+        value=gpio_value_get(gpio_pins[index].gpio);
+        if(1==value)
+        {
+            gpio_pins[index].state = TRUE;
+        }
+        else
+        {
+            LOG("gpio[%d] input not match output level [0]", gpio_pins[index].gpio);
+            gpio_pins[index].state = FALSE;
+            fail_count++;
+            continue;
+        }
+    }
+    //unexport gpio
+    gpio_unexport();
+
+    return fail_count;
+//set main
+}
+
+
+uint64 partion_space_get(const char *path)
+{
+    unsigned long long totle = 0;
+    unsigned long long blocksize = 0;
+    struct statfs diskInfo;
+
+    if(path == NULL){
+        return 0;
+    }
+    memset(&diskInfo, 0, sizeof(diskInfo));
+
+    if(statfs(path, &diskInfo)){
+        LOG("statfs() fail - %d.", errno);
+        return 0;
+    }
+    blocksize = diskInfo.f_bsize;
+    LOG("path=%s [totle=%lld MB] :f_type= %lld, f_bsize=%lld, f_blocks=%lld, f_bfree=%lld, f_bavail%lld\n", path,totle,
+	diskInfo.f_type, diskInfo.f_bsize,diskInfo.f_blocks,diskInfo.f_bfree, diskInfo.f_bavail);
+
+    // MSDOS_SUPER_MAGIC     0x4d44
+    if((diskInfo.f_type & 0x0ffff) == MSDOS_SUPER_MAGIC) {
+        totle = (diskInfo.f_blocks * blocksize) >> 20;
+        return totle;
+    } else {
+        LOG("Unknow fs type : %x", diskInfo.f_type);
+        return 0;
+    }
+}
+
+static unsigned int shell_at_handle;
+static void shell_cb_func(char *buf,int buf_size)
+{
+    if(buf && buf_size > 0)
+    {
+        char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
+        snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX, "+MSHELL: %d\r\n%s\r\n",
+                 buf_size, buf);
+        //MBTK_FUNC(log_hex)("+MSHELL", buf, buf_size);
+        ATRESP(shell_at_handle, ATCI_RESULT_CODE_NULL, 0, resp_buf);
+    }
+}
+
+int metis_strptime(char *str_time)
+{
+    struct tm stm;
+    char dateTime[30];
+    struct timeval tv;
+    if( strptime(str_time, "%Y-%m-%d %H:%M:%S",&stm) != NULL)
+    {
+        printf("success\n");
+    }
+    else{
+        printf("error\n");
+        return -1;
+    }
+
+//    printf("设置系统时间前的时间是:\n");
+//    system("date");
+    time_t _t = mktime(&stm);
+//    stime(&_t);
+    tv.tv_sec = _t;
+//    tv.tv_usec = USEC(pnew_time_packet->transmit_timestamp.fine);
+    settimeofday(&tv, NULL);
+
+    printf("设置系统时间HOU的时间是:\n");
+//    system("date");
+
+    return 0;
+}
+
+extern int mbtk_time_type;
+
+#if 0
+static void gpio_timer_alrm_func(int signo)
+{
+    LOG("TIMEOUT : %d", signo);
+    if(SIGALRM == signo) {
+        gpio_test_usable = true;
+        LOG("gpio_test_usable has reset to true.");
+    }
+}
+#else
+static void* gpio_thread_func(void *arg)
+{
+    sleep(1);
+    gpio_test_usable = true;
+    LOG("gpio_test_usable has reset to true.");
+    return NULL;
+}
+#endif
+#ifdef MBTK_DATA_MODE_SUPPORT
+static void data_mode_callback_cb(const char *data, int data_len)
+{
+    LOG("DATA - %d:%s", data_len, data);
+}
+#endif
+
+utlReturnCode_T MBTK_AT_MTEST_PROCESS(const utlAtParameterOp_T op,
+                                      const char *command_name_p,
+                                      const utlAtParameterValue_P2c parameter_values_p,
+                                      const size_t num_parameters,
+                                      const char *info_text_p,
+                                      unsigned int *xid_p,
+                                      void *arg_p)
+{
+    UNUSEDPARAM(command_name_p);
+    UNUSEDPARAM(num_parameters);
+    UNUSEDPARAM(info_text_p);
+
+    utlReturnCode_T ret = utlSUCCESS;
+    TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
+    unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index);
+    char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
+    unsigned int svc_id = 0;
+    *xid_p = At_handle;
+
+    const static int arg2_len_max = 10;
+    static int arg1 = 0;
+    static char arg2[MBTK_AT_RESP_LEN_MAX];
+
+    LOG("MBTK_AT_MTEST_PROCESS enter with command_op [%s]", op2str(op));
+
+    switch(op)
+    {
+        case TEL_EXT_GET_CMD :
+        {
+            sprintf(resp_buf, "%s : %d,\"%s\"\r\n", command_name_p, arg1, arg2);
+            ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
+            break;
+        }
+        case TEL_EXT_SET_CMD :
+        {
+            if(!getExtValue(parameter_values_p, 0, &arg1, 0, 1, 0))
+            {
+                ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+                break;
+            }
+
+            int len = 0;
+            memset(arg2, 0x0, MBTK_AT_RESP_LEN_MAX);
+            if(!getExtString(parameter_values_p, 1, arg2, arg2_len_max, &len, "test"))
+            {
+                ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+                break;
+            }
+
+            ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL);
+            break;
+        }
+        case TEL_EXT_ACTION_CMD :
+        {
+            // ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, "ACTION_OK");
+#ifdef MBTK_DATA_MODE_SUPPORT
+            ret = mbtk_data_mode_enter(sAtp_index, data_mode_callback_cb);
+#else
+			ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, "ACTION_OK");
+#endif
+            break;
+        }
+
+        default:
+        {
+            break;
+        }
+    }
+
+    return ret;
+
+}
+
+
+utlReturnCode_T MBTK_AT_MINFO_PROCESS(const utlAtParameterOp_T op,
+                                       const char *command_name_p,
+                                       const utlAtParameterValue_P2c parameter_values_p,
+                                       const size_t num_parameters,
+                                       const char *info_text_p,
+                                       unsigned int *xid_p,
+                                       void *arg_p)
+{
+    UNUSEDPARAM(command_name_p);
+    UNUSEDPARAM(num_parameters);
+    UNUSEDPARAM(info_text_p);
+
+    utlReturnCode_T ret = utlFAILED;
+    TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
+    unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index);
+    *xid_p = at_handle;
+
+    LOG("%s enter with command_op [%s]", command_name_p, op2str(op));
+
+    switch(op)
+    {
+        case TEL_EXT_ACTION_CMD :
+        {
+            char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
+            if(!dev_info_get()) {
+                snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX,
+                    "Revision:%s\r\n"
+                    "Custom_Model:%s\r\n"
+                    "Module_Type:%s\r\n",
+                    strlen(info_basic.revision_out) > 0 ? info_basic.revision_out: "Unknown",
+                    strlen(info_basic.project_cust) > 0 ? info_basic.project_cust: "Unknown",
+                    band_area_2_str(info_modem.band_area));
+            } else {
+                snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX,
+                    "Revision:%s\r\n"
+                    "Custom_Model:%s\r\n"
+                    "Module_Type:%s\r\n",
+                    "Unknown", "Unknown", "Unknown");
+            }
+            ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
+            break;
+        }
+        default:
+        {
+            break;
+        }
+    }
+
+    return ret;
+}
+
+utlReturnCode_T MBTK_AT_SYSTIME_PROCESS(const utlAtParameterOp_T op,
+                                      const char *command_name_p,
+                                      const utlAtParameterValue_P2c parameter_values_p,
+                                      const size_t num_parameters,
+                                      const char *info_text_p,
+                                      unsigned int *xid_p,
+                                      void *arg_p)
+{
+    UNUSEDPARAM(command_name_p);
+    UNUSEDPARAM(num_parameters);
+    UNUSEDPARAM(info_text_p);
+
+    utlReturnCode_T ret = utlSUCCESS;
+    TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
+    unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index);
+    char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
+    unsigned int svc_id = 0;
+    *xid_p = At_handle;
+
+    const static int arg2_len_max = 10;
+    static int arg1 = 0;
+
+    printf("MBTK_AT_SYSTIME_PROCESS enter with command_op [%s]", op2str(op));
+
+    switch(op)
+    {
+        case TEL_EXT_GET_CMD :
+        {
+            char time_type[10] = {0};
+            property_get("persist.mbtk.time_type", time_type, "0");
+            mbtk_time_type = atoi(time_type);
+            sprintf(resp_buf, "%s: %d\r\n", command_name_p, mbtk_time_type);
+            ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
+            break;
+        }
+        case TEL_EXT_SET_CMD :
+        {
+            if(!getExtValue(parameter_values_p, 0, &arg1, 0, 2, 0))
+            {
+                ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+                break;
+            }
+
+            if(num_parameters > 1) {
+    		    const static int cmd_len_max = MBTK_AT_RESP_LEN_MAX;
+                static char time_str[MBTK_AT_RESP_LEN_MAX];
+                int len = 0;
+                memset(time_str, 0x0, MBTK_AT_RESP_LEN_MAX);
+                if(!getExtString(parameter_values_p, 1, time_str, cmd_len_max, &len, ""))
+                {
+                    ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+                    LOG("Get CMD Fail.");
+                    break;
+                }
+
+                if(strlen(time_str) > 0)
+                {
+                    ret = metis_strptime(time_str);
+                }
+            }
+
+            mbtk_time_type = arg1;
+            char type_str[10] = {0};
+            sprintf(type_str, "%d", mbtk_time_type);
+            property_set("persist.mbtk.time_type", type_str);
+            if(ret < 0)
+            {
+                ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+            }
+            else
+            {
+                ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL);
+            }
+
+			break;
+        }
+        default:
+        {
+            break;
+        }
+    }
+    return ret;
+}
+
+utlReturnCode_T MBTK_AT_MTESTF_PROCESS(const utlAtParameterOp_T op,
+                                       const char *command_name_p,
+                                       const utlAtParameterValue_P2c parameter_values_p,
+                                       const size_t num_parameters,
+                                       const char *info_text_p,
+                                       unsigned int *xid_p,
+                                       void *arg_p)
+{
+    UNUSEDPARAM(command_name_p);
+    UNUSEDPARAM(num_parameters);
+    UNUSEDPARAM(info_text_p);
+
+    utlReturnCode_T ret = utlSUCCESS;
+    TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
+    unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index);
+    char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
+    unsigned int svc_id = 0;
+    *xid_p = At_handle;
+
+    const static int arg2_len_max = 10;
+    static int arg1 = 0;
+    static char arg2[MBTK_AT_RESP_LEN_MAX];
+
+    LOG("MBTK_AT_MTESTF_PROCESS enter with command_op [%s]", op2str(op));
+
+    switch(op)
+    {
+        case TEL_EXT_GET_CMD :
+        {
+            sprintf(resp_buf, "%s : %d,\"%s\"\r\n", command_name_p, arg1, arg2);
+            ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
+            break;
+        }
+        case TEL_EXT_SET_CMD :
+        {
+            if(!getExtValue(parameter_values_p, 0, &arg1, 0, 1, 0))
+            {
+                ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+                break;
+            }
+
+            int len = 0;
+            memset(arg2, 0x0, MBTK_AT_RESP_LEN_MAX);
+            if(!getExtString(parameter_values_p, 1, arg2, arg2_len_max, &len, "test"))
+            {
+                ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+                break;
+            }
+
+            ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL);
+            break;
+        }
+        case TEL_EXT_TEST_CMD :
+        {
+            ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, "+MTESTF=(0,1),\"\"");
+            break;
+        }
+        case TEL_EXT_ACTION_CMD :
+        {
+            ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, "ACTION_OK");
+            break;
+        }
+
+        default:
+        {
+            break;
+        }
+    }
+
+    return ret;
+
+}
+
+
+utlReturnCode_T MBTK_AT_MSHELL_PROCESS(const utlAtParameterOp_T op,
+                                       const char *command_name_p,
+                                       const utlAtParameterValue_P2c parameter_values_p,
+                                       const size_t num_parameters,
+                                       const char *info_text_p,
+                                       unsigned int *xid_p,
+                                       void *arg_p)
+{
+    UNUSEDPARAM(command_name_p);
+    UNUSEDPARAM(num_parameters);
+    UNUSEDPARAM(info_text_p);
+
+    utlReturnCode_T ret = utlFAILED;
+    TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
+    shell_at_handle = MAKE_AT_HANDLE(sAtp_index);
+    *xid_p = shell_at_handle;
+
+    LOG("MBTK_AT_MSHELL_PROCESS enter with command_op [%s]", op2str(op));
+
+    switch(op)
+    {
+        case TEL_EXT_SET_CMD :
+        {
+            const static int cmd_len_max = MBTK_AT_RESP_LEN_MAX;
+            static char cmd[MBTK_AT_RESP_LEN_MAX];
+            int len = 0;
+            memset(cmd, 0x0, MBTK_AT_RESP_LEN_MAX);
+            if(!getExtString(parameter_values_p, 0, cmd, cmd_len_max, &len, ""))
+            {
+                ret = ATRESP(shell_at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+                LOG("Get CMD Fail.");
+                break;
+            }
+
+            //if(strlen(cmd) > 0 && mbtk_cmd_line_ex(cmd, shell_cb_func))
+            if(strlen(cmd) > 0 && MBTK_FUNC(mbtk_cmd_line_ex)(cmd, shell_cb_func))
+            {
+                ret = ATRESP(shell_at_handle, ATCI_RESULT_CODE_OK, 0, NULL);
+            }
+            else
+            {
+                LOG("CMD length error.");
+                break;
+            }
+            break;
+        }
+        default:
+        {
+            break;
+        }
+    }
+
+    return ret;
+
+}
+
+utlReturnCode_T MBTK_AT_ISLKVRSCAN_PROCESS(const utlAtParameterOp_T op,
+        const char *command_name_p,
+        const utlAtParameterValue_P2c parameter_values_p,
+        const size_t num_parameters,
+        const char *info_text_p,
+        unsigned int *xid_p,
+        void *arg_p)
+{
+    UNUSEDPARAM(command_name_p);
+    UNUSEDPARAM(num_parameters);
+    UNUSEDPARAM(info_text_p);
+
+    utlReturnCode_T ret = utlFAILED;
+    TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
+    unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index);
+    *xid_p = at_handle;
+
+    LOG("MBTK_AT_ISLKVRSCAN_PROCESS enter with command_op [%s]", op2str(op));
+
+#ifndef MBTK_BUILD_TIME
+#define MBTK_BUILD_TIME "Unknown"
+#endif
+
+    switch(op)
+    {
+        case TEL_EXT_ACTION_CMD :
+        {
+            char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
+            if(!dev_info_get()) {
+                snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX, "Version: %s\r\nBuild time: %s\r\n",
+                     strlen(info_basic.revision_out) > 0 ? info_basic.revision_out: "Unknown",
+                     strlen(info_basic.build_time) > 0 ? info_basic.build_time: "Unknown");
+            } else {
+                snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX, "Version: %s\r\nBuild time: %s\r\n",
+                     "Unknown", "Unknown");
+            }
+            ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
+            break;
+        }
+        default:
+        {
+            break;
+        }
+    }
+
+    return ret;
+
+}
+
+utlReturnCode_T MBTK_AT_SDTEST_PROCESS(const utlAtParameterOp_T op,
+                                       const char *command_name_p,
+                                       const utlAtParameterValue_P2c parameter_values_p,
+                                       const size_t num_parameters,
+                                       const char *info_text_p,
+                                       unsigned int *xid_p,
+                                       void *arg_p)
+{
+    UNUSEDPARAM(command_name_p);
+    UNUSEDPARAM(num_parameters);
+    UNUSEDPARAM(info_text_p);
+
+    utlReturnCode_T ret = utlFAILED;
+    TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
+    unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index);
+    *xid_p = at_handle;
+
+    LOG("%s enter with command_op [%s]", command_name_p, op2str(op));
+
+    switch(op)
+    {
+        case TEL_EXT_ACTION_CMD :
+        {
+            // SDVOLUME:xxxMB
+            // OK
+            // /mnt/mmcblk0p1
+            #if (defined(MBTK_PROJECT_L508_X6) || defined(MBTK_PROJECT_T108) || defined(MBTK_PROJECT_L509) || defined(MBTK_PROJECT_L508))
+            int i =0 ;
+            uint64 size = 0;
+            for(i = 0; i < 3; i++)
+            {
+                if(i == 0)
+                {
+                    size = partion_space_get("/sdcard");
+                }
+                else if(i == 1)
+                {
+                    size = partion_space_get("/system/etc/www/webdav/sdcard");
+                }
+                else
+                {
+                    system("mkfs.vfat -F 32 /dev/mmcblk0");
+                    system("mount -t vfat /dev/mmcblk0 /mnt");
+                    size = partion_space_get("/mnt");
+                }
+
+                if(size > 0)
+                {
+                    LOG("[SDTEST] i = %d, size = %d", i, size);
+                    break;
+                }
+
+                size = 0;
+            }
+            #else
+            uint64 size = partion_space_get("/mnt/mmcblk0p1");
+            #endif
+            char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
+            if(size > 0) {
+                snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX, "SDVOLUME:%lldMB\r\n", size);
+            } else {
+                snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX, "SDVOLUME:0MB\r\n");
+            }
+            ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
+            break;
+        }
+        default:
+        {
+            break;
+        }
+    }
+
+    return ret;
+}
+
+
+utlReturnCode_T MBTK_AT_SPKTEST_PROCESS(const utlAtParameterOp_T op,
+                                        const char *command_name_p,
+                                        const utlAtParameterValue_P2c parameter_values_p,
+                                        const size_t num_parameters,
+                                        const char *info_text_p,
+                                        unsigned int *xid_p,
+                                        void *arg_p)
+{
+    UNUSEDPARAM(command_name_p);
+    UNUSEDPARAM(num_parameters);
+    UNUSEDPARAM(info_text_p);
+
+    utlReturnCode_T ret = utlFAILED;
+    TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
+    unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index);
+    *xid_p = at_handle;
+
+    LOG("MBTK_AT_SPKTEST_PROCESS enter with command_op [%s]", op2str(op));
+
+    switch(op)
+    {
+        case TEL_EXT_ACTION_CMD :
+        {
+            // SDVOLUME:MB
+            // OK
+            char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
+
+            mbtk_at_play(NULL);
+
+            snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX, "Audio spk test.\r\nBuild time: %s\r\n",
+                     MBTK_BUILD_TIME);
+            ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
+
+            break;
+        }
+        default:
+        {
+            break;
+        }
+    }
+
+    return ret;
+}
+
+utlReturnCode_T MBTK_AT_MICTEST_PROCESS(const utlAtParameterOp_T op,
+                                        const char *command_name_p,
+                                        const utlAtParameterValue_P2c parameter_values_p,
+                                        const size_t num_parameters,
+                                        const char *info_text_p,
+                                        unsigned int *xid_p,
+                                        void *arg_p)
+{
+    UNUSEDPARAM(command_name_p);
+    UNUSEDPARAM(num_parameters);
+    UNUSEDPARAM(info_text_p);
+
+    utlReturnCode_T ret = utlFAILED;
+    TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
+    unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index);
+    *xid_p = at_handle;
+
+    LOG("MBTK_AT_MICTEST_PROCESS enter with command_op [%s]", op2str(op));
+
+    switch(op)
+    {
+        case TEL_EXT_ACTION_CMD :
+        {
+            // SDVOLUME:MB
+            // OK
+            char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
+
+            mbtk_at_rec(NULL);
+            snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX, "Audio record test.\r\nBuild time: %s\r\n",
+                     MBTK_BUILD_TIME);
+            ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
+            break;
+        }
+        default:
+        {
+            break;
+        }
+    }
+
+    return ret;
+}
+
+utlReturnCode_T MBTK_AT_REVTEST_PROCESS(const utlAtParameterOp_T op,
+                                        const char *command_name_p,
+                                        const utlAtParameterValue_P2c parameter_values_p,
+                                        const size_t num_parameters,
+                                        const char *info_text_p,
+                                        unsigned int *xid_p,
+                                        void *arg_p)
+{
+    UNUSEDPARAM(command_name_p);
+    UNUSEDPARAM(num_parameters);
+    UNUSEDPARAM(info_text_p);
+
+    utlReturnCode_T ret = utlFAILED;
+    TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
+    unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index);
+    *xid_p = at_handle;
+    char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
+    int arg1 = 0;
+
+    static bool loopback_running = FALSE;
+
+    LOG("MBTK_AT_REVTEST_PROCESS enter with command_op [%s]", op2str(op));
+
+    switch(op)
+    {
+        case TEL_EXT_GET_CMD :
+        {
+            sprintf(resp_buf, "%s : %d\r\n", command_name_p, arg1);
+            ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
+            break;
+        }
+        case TEL_EXT_SET_CMD :
+        {
+            if(!getExtValue(parameter_values_p, 0, &arg1, 0, 1, 0))
+            {
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+                break;
+            }
+            #if (defined(MBTK_PROJECT_L508_X6) || defined(MBTK_PROJECT_T108))
+            if(arg1 == 1)
+            {
+                system("ubus call audio_if loopback_enable '{\"param0\":1}'");
+            }
+            else
+            {
+                system("ubus call audio_if loopback_disable");
+            }
+            #else
+            LOG("MBTK_AT_REVTEST_PROCESS arg1 [%d]", arg1);
+            mbtk_at_loopback(arg1);
+            //sprintf(resp_buf, "%s : ,\"%s\"\r\n", command_name_p, "TEL_EXT_SET_CMD");
+            #endif
+            ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, NULL);
+            break;
+        }
+        case TEL_EXT_ACTION_CMD :
+        {
+            if(!loopback_running) {
+                #if (defined(MBTK_PROJECT_L508_X6) || defined(MBTK_PROJECT_T108))
+                system("ubus call audio_if loopback_enable '{\"param0\":1}'");
+                #else
+                mbtk_at_loopback(1);
+                #endif
+                loopback_running = TRUE;
+            } else {
+                #if (defined(MBTK_PROJECT_L508_X6) || defined(MBTK_PROJECT_T108))
+                system("ubus call audio_if loopback_disable");
+                #else
+                mbtk_at_loopback(0);
+                #endif
+                loopback_running = FALSE;
+            }
+            //snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX, "Audio loopback test.\r\nBuild time: %s\r\n",
+            //         MBTK_BUILD_TIME);
+            ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, NULL);
+            break;
+        }
+        default:
+        {
+            break;
+        }
+    }
+
+    return ret;
+}
+
+utlReturnCode_T MBTK_AT_GPIOTEST_PROCESS(const utlAtParameterOp_T op,
+        const char *command_name_p,
+        const utlAtParameterValue_P2c parameter_values_p,
+        const size_t num_parameters,
+        const char *info_text_p,
+        unsigned int *xid_p,
+        void *arg_p)
+{
+    UNUSEDPARAM(command_name_p);
+    UNUSEDPARAM(num_parameters);
+    UNUSEDPARAM(info_text_p);
+
+    utlReturnCode_T ret = utlFAILED;
+    TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
+    unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index);
+    int gnss_support = 0;
+    *xid_p = at_handle;
+
+    LOG("MBTK_AT_GPIOTEST_PROCESS enter with command_op [%s]", op2str(op));
+
+    switch(op)
+    {
+        case TEL_EXT_SET_CMD :
+        {
+            if(!getExtValue(parameter_values_p, 0, &gnss_support, 0, 1, 0))
+            {
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+                break;
+            }
+        }
+        case TEL_EXT_ACTION_CMD :
+        {
+            if(gpio_test_usable) {
+                gpio_test_usable = false;
+            } else { // GPIO test is busy.
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_SUPPRESS, 0, NULL);
+                break;
+            }
+
+#if 1
+			int test_result[MAX_GPIO_TEST_NUM];
+			memset(test_result,0,sizeof(test_result));
+            int result = mbtk_at_gpio((bool)gnss_support, test_result);
+            if(result < 0)
+            {
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, "GPIO TEST FAIL\r\n");
+            }
+            else if(result == 0) {
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, "ALL GPIO TEST PASS\r\n");
+            }
+            else
+            {
+                char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
+                int index;
+                sprintf(resp_buf, "GPIOTEST Fail %02d PINs:", result);
+                for(index = 0; index < result &&index < MAX_GPIO_TEST_NUM; index++)
+                {
+                    sprintf(resp_buf + strlen(resp_buf), "%03d,", test_result[index]);
+                }
+                resp_buf[strlen(resp_buf) - 1] = '\r';
+                resp_buf[strlen(resp_buf)] = '\n';
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
+            }
+#else
+            int fail_count = gpio_test();
+            if(fail_count < 0) {
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, "GPIO TEST FAIL\r\n");
+            } else if(fail_count == 0){
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, "ALL GPIO TEST PASS\r\n");
+            } else {
+                char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
+                int index;
+                sprintf(resp_buf, "GPIOTEST Fail %02d PINs:", fail_count);
+                for(index = 0; index < MBTK_GPIO_NUM; index++)
+                {
+                    if(!gpio_pins[index].state) {
+                        sprintf(resp_buf + strlen(resp_buf), "%03d,", gpio_pins[index].gpio);
+                    }
+                }
+                resp_buf[strlen(resp_buf) - 1] = '\r';
+                resp_buf[strlen(resp_buf)] = '\n';
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
+            }
+#endif
+
+            // Set gpio_test_usable to true after 1s.
+#if 0
+            signal(SIGALRM, gpio_timer_alrm_func);
+            struct itimerval val;
+            // Only time
+            val.it_interval.tv_sec  = 0;
+            val.it_interval.tv_usec = 0;
+            // Time
+            val.it_value.tv_sec  = 1;
+            val.it_value.tv_usec = 0;
+            if (setitimer(ITIMER_REAL, &val, NULL) == -1)
+            {
+                LOG("setitimer fail.[errno - %d]",errno);
+            }
+#else
+            pthread_t gpio_thread_id;
+            if (pthread_create(&gpio_thread_id, NULL, gpio_thread_func, NULL) != 0)
+            {
+                LOG("%s errno: %d (%s)",__func__, errno, strerror(errno));
+            }
+#endif
+            break;
+        }
+        default:
+        {
+            break;
+        }
+    }
+
+    return ret;
+}
+
+utlReturnCode_T MBTK_AT_ADCGETV_PROCESS(const utlAtParameterOp_T op,
+                                        const char *command_name_p,
+                                        const utlAtParameterValue_P2c parameter_values_p,
+                                        const size_t num_parameters,
+                                        const char *info_text_p,
+                                        unsigned int *xid_p,
+                                        void *arg_p)
+{
+    UNUSEDPARAM(command_name_p);
+    UNUSEDPARAM(num_parameters);
+    UNUSEDPARAM(info_text_p);
+
+    utlReturnCode_T ret = utlFAILED;
+    TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
+    unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index);
+    char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
+    int arg1 = 0;
+    *xid_p = at_handle;
+
+    LOG("MBTK_AT_ADCGETV_PROCESS enter with command_op [%s]", op2str(op));
+
+    switch(op)
+    {
+        case TEL_EXT_ACTION_CMD :
+        {
+            // SDVOLUME:MB
+            // OK
+            snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX, "ADC Version: %s\r\nBuild time: %s\r\n",
+                     MBTK_DEVICES_REVISION, MBTK_BUILD_TIME);
+            ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
+            break;
+        }
+        case TEL_EXT_SET_CMD :
+        {
+            int adc_ret;
+            if(!getExtValue(parameter_values_p, 0, &arg1, 0, 2, 0))
+            {
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+                break;
+            }
+            adc_ret = mbtk_at_adc(arg1);
+            LOG("MBTK_AT_ADC_PROCESS adc [%d]", adc_ret);
+            sprintf(resp_buf, "%s:%d,%d\r\n", command_name_p, arg1, adc_ret);
+            ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
+            break;
+        }
+        default:
+        {
+            break;
+        }
+    }
+
+    return ret;
+}
+
+utlReturnCode_T MBTK_AT_RGMIITEST_PROCESS(const utlAtParameterOp_T op,
+                                        const char *command_name_p,
+                                        const utlAtParameterValue_P2c parameter_values_p,
+                                        const size_t num_parameters,
+                                        const char *info_text_p,
+                                        unsigned int *xid_p,
+                                        void *arg_p)
+{
+    UNUSEDPARAM(command_name_p);
+    UNUSEDPARAM(num_parameters);
+    UNUSEDPARAM(info_text_p);
+
+    utlReturnCode_T ret = utlFAILED;
+    TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
+    unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index);
+    *xid_p = at_handle;
+
+    LOG("MBTK_AT_RGMIITEST_PROCESS enter with command_op [%s]", op2str(op));
+
+    switch(op)
+    {
+        case TEL_EXT_ACTION_CMD :
+        {
+            #if defined(MBTK_PROJECT_T108)
+            int result = -1;
+            int rgmii_test_num = 0;
+            char buf[50] = {0};
+            static char rgmii_flag = 0;
+            //mbtk_mdio("eth0", 0, 0x9800, 0xc834);
+            //mbtk_mdio("eth0", 0,  0x0, 0xa000);
+            for(rgmii_test_num = 0; rgmii_test_num < 3; rgmii_test_num++)
+            {
+                if(!rgmii_flag)
+                {
+                    system("/bin/mbtk_mdio eth0 0x9800 0xc834");
+                    system("/bin/mbtk_mdio eth0 0x0 0xa000");
+                }
+                result = mbtk_rgmii_loopback();
+                if(result < 0)
+                {
+                    //
+                }
+                else
+                {
+                    memcpy(buf, "+RGMIITEST: phy loopback ok", strlen("+RGMIITEST: phy loopback ok"));
+                    ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, buf);
+                    rgmii_flag = 1;
+                    break;
+                }
+            }
+
+            if(result < 0)
+            {
+                memcpy(buf, "+RGMIITEST: phy loopback fail", strlen("+RGMIITEST: phy loopback fail"));
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, buf);
+            }
+            break;
+            #endif
+        }
+        default:
+        {
+            ret = ATRESP( at_handle, ATCI_RESULT_CODE_CME_ERROR, CME_OPERATION_NOT_SUPPORTED, NULL);
+            break;
+        }
+    }
+
+    return ret;
+}
+
+utlReturnCode_T MBTK_AT_MGPSC_PROCESS(const utlAtParameterOp_T op,
+                                        const char *command_name_p,
+                                        const utlAtParameterValue_P2c parameter_values_p,
+                                        const size_t num_parameters,
+                                        const char *info_text_p,
+                                        unsigned int *xid_p,
+                                        void *arg_p)
+{
+    UNUSEDPARAM(command_name_p);
+    UNUSEDPARAM(num_parameters);
+    UNUSEDPARAM(info_text_p);
+
+    utlReturnCode_T ret = utlFAILED;
+    TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
+    unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index);
+    char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
+    int arg1 = 0;
+    *xid_p = at_handle;
+
+    LOG("MBTK_AT_MGPSC_PROCESS enter with command_op [%s]", op2str(op));
+
+    switch(op)
+    {
+        case TEL_EXT_SET_CMD :
+        {
+            int gnss_ret;
+            if(!getExtValue(parameter_values_p, 0, &arg1, 0, 11, 0))
+            {
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+                break;
+            }
+#if 1
+            if (arg1 == 5 || arg1 == 1 || arg1 ==0)
+            {
+                if (1 == arg1)
+                {
+                    gnss_ret = mbtk_mgpsc_set(arg1);
+                    if (gnss_ret < 0)
+                    {
+                        ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: init fail.\r\n");
+                    }
+                    else
+                    {
+                        ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, "+GPS: init success.\r\n");
+                    }
+                }
+                else if (arg1 == 5)
+                {
+                    ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, NULL);
+                }
+                else
+                {
+                    gnss_ret = mbtk_mgpsc_set(arg1);
+                    if (gnss_ret < 0)
+                    {
+                        ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: deinit fail.\r\n");
+                    }
+                    else
+                    {
+                        ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, "+GPS: deinit success.\r\n");
+                    }                }
+            }
+            else
+            {
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+                break;
+            }
+#else
+            if(1 == arg1 || 11 == arg1 || 10 == arg1 || 9 == arg1)
+                gnss_ret = MBTK_FUNC(mbtk_at_gnss)(arg1, at_gnss_handler_function);
+            else if (6 == arg1)
+                gnss_ret = at_gnss_firmware_update();
+            else
+                gnss_ret = MBTK_FUNC(mbtk_at_gnss)(arg1, NULL);
+
+            LOG("%s gnss [%d]", __FUNCTION__, gnss_ret);
+            sprintf(resp_buf, "%s:%d,%d\r\n", command_name_p, arg1, gnss_ret);
+            ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
+#endif
+
+            break;
+        }
+        default:
+        {
+            break;
+        }
+    }
+
+    return ret;
+}
+
+utlReturnCode_T MBTK_AT_CGNETLED_PROCESS(const utlAtParameterOp_T op,
+                                        const char *command_name_p,
+                                        const utlAtParameterValue_P2c parameter_values_p,
+                                        const size_t num_parameters,
+                                        const char *info_text_p,
+                                        unsigned int *xid_p,
+                                        void *arg_p)
+{
+    UNUSEDPARAM(command_name_p);
+    UNUSEDPARAM(num_parameters);
+    UNUSEDPARAM(info_text_p);
+
+    utlReturnCode_T ret = utlFAILED;
+    TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
+    unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index);
+    *xid_p = at_handle;
+
+    LOG("MBTK_AT_CGNETLED_PROCESS enter with command_op [%s]", op2str(op));
+    switch(op)
+    {
+        case TEL_EXT_SET_CMD :
+        {
+            int led_switch;
+            if(!getExtValue(parameter_values_p, 0, &led_switch, 0, 1, 0))
+            {
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+                break;
+            }
+
+            if(led_switch == 0 || led_switch == 1) {
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, NULL);
+            }
+            break;
+        }
+        default:
+        {
+            break;
+        }
+    }
+
+    return ret;
+}
+
+utlReturnCode_T MBTK_AT_SYSSLEEP_PROCESS(const utlAtParameterOp_T op,
+                                        const char *command_name_p,
+                                        const utlAtParameterValue_P2c parameter_values_p,
+                                        const size_t num_parameters,
+                                        const char *info_text_p,
+                                        unsigned int *xid_p,
+                                        void *arg_p)
+{
+    UNUSEDPARAM(command_name_p);
+    UNUSEDPARAM(num_parameters);
+    UNUSEDPARAM(info_text_p);
+
+    utlReturnCode_T ret = utlFAILED;
+    TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
+    unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index);
+    *xid_p = at_handle;
+
+    TelAtParserID origParserId = *(TelAtParserID *)arg_p;
+
+    LOG("MBTK_AT_SYSSLEEP_PROCESS enter with command_op [%s]", op2str(op));
+    switch(op)
+    {
+        case TEL_EXT_SET_CMD:
+        case TEL_EXT_ACTION_CMD:
+        {
+            // [ -e /sys/class/devfreq/devfreq-ddr/polling_interval ] && {
+            //    echo 50 > /sys/class/devfreq/devfreq-ddr/polling_interval
+            // }
+
+            // [ -e /sys/power/autosleep ] && {
+            //    echo booting 8000000000 > /sys/power/wake_lock
+            //    echo mem > /sys/power/autosleep
+            // }
+
+            //close GPS set gpio 21/118: out / 0
+            int result = -1;
+            result = mbtk_system_sleep();
+            if(result != 0)
+            {
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+            }
+            else
+            {
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, NULL);
+            }
+#if 0
+            int ubus_ret = 0;
+            ubus_ret = invoke_reply_data_cb(origParserId, "gps", "gnss_deinit", NULL, (ubus_data_handler_t *)gps_usr_callback_hdl, &at_handle, 4000);
+            if(ubus_ret < 0)
+            {
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_SUPPRESS, 0, "BUSY");
+                break;
+            }
+            else if(ubus_ret > 0)
+            {
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+                break;
+            }
+#ifdef MBTK_PROJECT_L508
+            system("echo 0 > /sys/class/gpio/gpio119/value");
+#else
+#ifdef MBTK_PROJECT_PN1803
+            system("echo 0 > /sys/class/gpio/gpio119/value");
+#else
+#ifdef MBTK_PROJECT_L509
+            system("echo 0 > /sys/class/gpio/gpio120/value");
+#endif
+#endif
+#endif
+
+#ifdef MBTK_PROJECT_L508_X6
+            //close Ldo6
+            system("i2cset -y -f 2 0x31 0x18 0x0f");
+            //GPS_WAKE_HOST to GPIO
+            system("hwacc w 0xd401e198 0x1040");
+            //HOST_WAKE_GPS to GPIO
+            //system("hwacc w 0xd401e0c0 0x1040");
+            //gpio34 to GPIO
+            #if 1
+            system("hwacc w 0xd401e164 0x1040");
+			system("hwacc w 0xd401e166 0x1040");
+			system("hwacc w 0xd401e1b4 0x1040");
+
+            system("hwacc w 0xd401e2ec 0xa441");
+            system("hwacc w 0xd401e2f0 0xa441");
+            system("hwacc w 0xd401e2f4 0xa441");
+            system("hwacc w 0xd401e2f8 0xa441");
+            system("hwacc w 0xd401e2fc 0xa441");
+            system("hwacc w 0xd401e300 0xa441");
+
+            if(one_gpio_export(117, 2))
+            {
+                LOG("GPIO SET ERROR.");
+            }
+            if(one_gpio_export(117, 0))
+            {
+                LOG("GPIO SET ERROR.");
+            }
+			if(one_gpio_export(119, 2))
+            {
+                LOG("GPIO SET ERROR.");
+            }
+            if(one_gpio_export(119, 0))
+            {
+                LOG("GPIO SET ERROR.");
+            }
+
+
+            if(one_gpio_export(127, 2))
+            {
+                LOG("GPIO SET ERROR.");
+            }
+            if(one_gpio_export(127, 0))
+            {
+                LOG("GPIO SET ERROR.");
+            }
+			 if(one_gpio_export(34, 2))
+            {
+                LOG("GPIO SET ERROR.");
+            }
+            if(one_gpio_export(34, 0))
+            {
+                LOG("GPIO SET ERROR.");
+            }
+			 if(one_gpio_export(33, 2))
+            {
+                LOG("GPIO SET ERROR.");
+            }
+            if(one_gpio_export(33, 0))
+            {
+                LOG("GPIO SET ERROR.");
+            }
+		    if(one_gpio_export(54, 2))
+            {
+                LOG("GPIO SET ERROR.");
+            }
+            if(one_gpio_export(54, 0))
+            {
+                LOG("GPIO SET ERROR.");
+            }
+
+            #endif
+#endif
+
+#ifdef MBTK_PROJECT_T108
+
+#else
+            if(one_gpio_export(21, 2))
+            {
+                LOG("GPIO SET ERROR.");
+            }
+            if(one_gpio_export(21, 0))
+            {
+                LOG("GPIO SET ERROR.");
+            }
+            if(one_gpio_export(118, 2))
+            {
+                LOG("GPIO SET ERROR.");
+            }
+            if(one_gpio_export(118, 0))
+            {
+                LOG("GPIO SET ERROR.");
+            }
+#endif
+            // echo off > /sys/devices/mbtk-dev-op.10/gps_power && echo mem > /sys/power/autosleep
+            // echo 1 > /sys/devices/asr-rfkill.0/pwr_ctrl && sleep 2 && echo 0 > /sys/devices/asr-rfkill.0/pwr_ctrl
+
+            if(!access("/sys/power/autosleep", W_OK))
+                system("echo mem > /sys/power/autosleep");
+            else
+                LOG("/sys/power/autosleep can not write.");
+            ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, NULL);
+#endif
+            break;
+        }
+        default:
+        {
+            break;
+        }
+    }
+
+    return ret;
+}
+
+static int port_config(mbtk_port_type_enum type, mbtk_port_mode_enum mode) {
+
+    char type_buff[32] = {0};
+    char mode_buff[32] = {0};
+    switch(type)
+    {
+        case MBTK_PORT_TYPE_UART1:
+            strcpy(type_buff, "persist.mbtk.dev_ttyS1");
+            break;
+        case MBTK_PORT_TYPE_USB1:
+            strcpy(type_buff, "persist.mbtk.dev_ttyGS0");
+            break;
+        case MBTK_PORT_TYPE_USB2:
+            strcpy(type_buff, "persist.mbtk.dev_ttymodem0");
+            break;
+        default:
+            return -1;
+    }
+    switch(mode)
+    {
+        case MBTK_PORT_MODE_AT:
+            strcpy(mode_buff, "at");
+            break;
+        case MBTK_PORT_MODE_ADB:
+            strcpy(mode_buff, "adb");
+            break;
+        case MBTK_PORT_MODE_CUSTOM:
+            strcpy(mode_buff, "custom");
+            break;
+        default:
+            return -1;
+    }
+    return property_set(type_buff, mode_buff);
+}
+
+utlReturnCode_T MBTK_AT_MPORTCFG_PROCESS(const utlAtParameterOp_T op,
+                                        const char *command_name_p,
+                                        const utlAtParameterValue_P2c parameter_values_p,
+                                        const size_t num_parameters,
+                                        const char *info_text_p,
+                                        unsigned int *xid_p,
+                                        void *arg_p)
+{
+    UNUSEDPARAM(command_name_p);
+    UNUSEDPARAM(num_parameters);
+    UNUSEDPARAM(info_text_p);
+
+    utlReturnCode_T ret = utlFAILED;
+    TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
+    unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index);
+    *xid_p = at_handle;
+    char resp_buf[1024] = {0};
+
+    LOG("MBTK_AT_MPORTCFG_PROCESS enter with command_op [%s]", op2str(op));
+    switch(op)
+    {
+        case TEL_EXT_SET_CMD:
+		{
+            int arg;
+            if(!getExtValue(parameter_values_p, 0, &arg, 0, 2, 0))
+            {
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+                break;
+            }
+            mbtk_port_type_enum type = (mbtk_port_type_enum)arg;
+            if(!getExtValue(parameter_values_p, 1, &arg, 0, 2, 0))
+            {
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+                break;
+            }
+            mbtk_port_mode_enum mode = (mbtk_port_mode_enum)arg;
+
+            if(port_config(type, mode)) {
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+            } else {
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, NULL);
+            }
+
+            break;
+		}
+        case TEL_EXT_GET_CMD :
+        {
+            int len = 0;
+            char port_config[32] = {0};
+            property_get("persist.mbtk.dev_ttyS1", port_config, "at");
+            if(!strcmp(port_config, "adb")) {
+                len += sprintf(resp_buf + len, "%s : %d,%d\r\n", command_name_p, MBTK_PORT_TYPE_UART1, MBTK_PORT_MODE_ADB);
+            } else if(!strcmp(port_config, "custom")) {
+                len += sprintf(resp_buf + len, "%s : %d,%d\r\n", command_name_p, MBTK_PORT_TYPE_UART1, MBTK_PORT_MODE_CUSTOM);
+            } else {
+                len += sprintf(resp_buf + len, "%s : %d,%d\r\n", command_name_p, MBTK_PORT_TYPE_UART1, MBTK_PORT_MODE_AT);
+            }
+
+            memset(port_config, 0, 32);
+            property_get("persist.mbtk.dev_ttyGS0", port_config, "at");
+            if(!strcmp(port_config, "adb")) {
+                len += sprintf(resp_buf + len, "%s : %d,%d\r\n", command_name_p, MBTK_PORT_TYPE_USB1, MBTK_PORT_MODE_ADB);
+            } else if(!strcmp(port_config, "custom")) {
+                len += sprintf(resp_buf + len, "%s : %d,%d\r\n", command_name_p, MBTK_PORT_TYPE_USB1, MBTK_PORT_MODE_CUSTOM);
+            } else {
+                len += sprintf(resp_buf + len, "%s : %d,%d\r\n", command_name_p, MBTK_PORT_TYPE_USB1, MBTK_PORT_MODE_AT);
+            }
+
+            memset(port_config, 0, 32);
+            property_get("persist.mbtk.dev_ttymodem0", port_config, "at");
+            if(!strcmp(port_config, "adb")) {
+                len += sprintf(resp_buf + len, "%s : %d,%d\r\n", command_name_p, MBTK_PORT_TYPE_USB2, MBTK_PORT_MODE_ADB);
+            } else if(!strcmp(port_config, "custom")) {
+                len += sprintf(resp_buf + len, "%s : %d,%d\r\n", command_name_p, MBTK_PORT_TYPE_USB2, MBTK_PORT_MODE_CUSTOM);
+            } else {
+                len += sprintf(resp_buf + len, "%s : %d,%d\r\n", command_name_p, MBTK_PORT_TYPE_USB2, MBTK_PORT_MODE_AT);
+            }
+
+            ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
+            break;
+        }
+        default:
+        {
+            break;
+        }
+    }
+
+    return ret;
+}
+
+utlReturnCode_T MBTK_AT_MURCECHO_PROCESS(const utlAtParameterOp_T op,
+                                        const char *command_name_p,
+                                        const utlAtParameterValue_P2c parameter_values_p,
+                                        const size_t num_parameters,
+                                        const char *info_text_p,
+                                        unsigned int *xid_p,
+                                        void *arg_p)
+{
+    UNUSEDPARAM(command_name_p);
+    UNUSEDPARAM(num_parameters);
+    UNUSEDPARAM(info_text_p);
+
+    utlReturnCode_T ret = utlFAILED;
+    TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
+    unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index);
+    *xid_p = At_handle;
+    char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
+
+    static int arg1 = 0;
+
+    LOG("MBTK_AT_MTEST_PROCESS enter with command_op [%s]", op2str(op));
+
+    switch(op)
+    {
+        case TEL_EXT_GET_CMD :
+        {
+            sprintf(resp_buf, "%s : %d\r\n", command_name_p, mbtk_urc_enable);
+            ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
+            break;
+        }
+        case TEL_EXT_SET_CMD :
+        {
+            if(!getExtValue(parameter_values_p, 0, &arg1, 0, 1, 0))
+            {
+                ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+                break;
+            }
+
+            mbtk_urc_enable = (bool)arg1;
+
+            ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL);
+            break;
+        }
+        default:
+        {
+            break;
+        }
+    }
+
+    return ret;
+}
+
+RETURNCODE_T  MBTK_AT_READVER_PROCESS(            const utlAtParameterOp_T        op,
+        const char                      *command_name_p,
+        const utlAtParameterValue_P2c   parameter_values_p,
+        const size_t                    num_parameters,
+        const char                      *info_text_p,
+        unsigned int                    *xid_p,
+        void                            *arg_p)
+{
+
+    UNUSEDPARAM(command_name_p);
+	UNUSEDPARAM(parameter_values_p);
+	UNUSEDPARAM(num_parameters);
+	UNUSEDPARAM(info_text_p);
+
+    /*
+     *  Put parser index into the variable
+     */
+        RETURNCODE_T      rc = INITIAL_RETURN_CODE;
+        CiReturnCode          ret = CIRC_FAIL;
+        UINT32                atHandle = MAKE_AT_HANDLE(* (TelAtParserID *) arg_p);
+
+        *xid_p = atHandle;
+    //  DBGMSG("%s: atHandle = %d.\n", __FUNCTION__, atHandle);
+
+    /*
+     * process operation
+     */
+    switch ( op )
+    {
+        case TEL_EXT_ACTION_CMD: /* AT*READVER */
+            {
+                char tmpBuf[512];
+#if 0
+                sprintf(tmpBuf, "*READVER: \r\nrelease_version:%s\r\nrelease_time:%s\r\n", SYSTEM_RELEASE_NAME, SYSTEM_RELEASE_CREATION_DATE);
+#else
+                {
+                    char rel_version[128] = {0};
+                    char sdk[64] = {0};
+                    char rel_date[64] = {0};
+                    char dsp_version[128]={0};
+                    char dsp_date[64]={0};
+                    char rf_version[128] = {0};
+                    int num = 0;
+
+                    char internalRevisionId[400 + 1] = {0};
+                    char buildTimeStr[100 + 1] = {0};
+
+                    //GetDspFWVersionAndDate(dsp_version1,dsp_date1);
+                    //p_string = GetRFBinFWVersion();
+                    //p_string2 = GetRFBinFWDate();
+                    property_get("dev.cp.rel.revision", rel_version, "NULL");
+                    property_get("dev.cp.dsp.revision", dsp_version, "NULL");
+                    property_get("dev.cp.rf.revision", rf_version, "NULL");
+		            property_get("dev.cp.rel.time", rel_date, "NULL");
+                    property_get("dev.cp.dsp.time", dsp_date, "NULL");
+
+                    #if 1
+                    if(strncmp(rel_version, "NULL", strlen("NULL")) != 0)
+                    {
+                        char *p1 = NULL;
+                        p1 = strstr(rel_version, "SDK");
+                        if(p1 != NULL)
+                        {
+                            memcpy(sdk, p1, strlen(p1));
+                            p1 = strstr(sdk, "_");
+                            if(p1 != NULL)
+                            {
+                                *p1 = '\0';
+                            }
+                        }
+                        else
+                        {
+                            strcpy(sdk, "NULL");
+                        }
+                    }
+                    else
+                    {
+                        strcpy(sdk, "NULL");
+                    }
+                    #endif
+
+                    sprintf(tmpBuf, "*READVER: \r\nRelease_Version: %s (SDK %s)\r\nRelease_Time: %s\r\n(DSP: %s %s)\r\n(RF: %s %s)\r\n(HW: %s by %s)\r\n",
+                        rel_version,sdk,rel_date,
+                        dsp_version,dsp_date,
+                        rf_version,"NULL",
+                        "NULL","NULL");
+                }
+#endif
+                ret = ATRESP( atHandle, ATCI_RESULT_CODE_OK, 0, tmpBuf);
+                break;
+            }
+
+
+        default:
+                ret = ATRESP( atHandle, ATCI_RESULT_CODE_CME_ERROR, CME_OPERATION_NOT_SUPPORTED, NULL );
+            break;
+    }
+
+
+    rc = HANDLE_RETURN_VALUE(ret);
+    return(rc);
+}
+
+utlReturnCode_T MBTK_AT_CGDRT_PROCESS(const utlAtParameterOp_T op,
+                                        const char *command_name_p,
+                                        const utlAtParameterValue_P2c parameter_values_p,
+                                        const size_t num_parameters,
+                                        const char *info_text_p,
+                                        unsigned int *xid_p,
+                                        void *arg_p)
+{
+    UNUSEDPARAM(command_name_p);
+    UNUSEDPARAM(num_parameters);
+    UNUSEDPARAM(info_text_p);
+
+    utlReturnCode_T ret = utlFAILED;
+    TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
+    unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index);
+    *xid_p = At_handle;
+    char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
+
+    static int mode = 0;
+    static int cert = 0;
+
+    LOG("MBTK_AT_MTEST_PROCESS enter with command_op [%s]", op2str(op));
+
+    switch(op)
+    {
+        case TEL_EXT_GET_CMD :
+        {
+            ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
+            break;
+        }
+        case TEL_EXT_SET_CMD :
+        {
+            if(!getExtValue(parameter_values_p, 0, &mode, 0, 139, 0))
+            {
+                ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+                break;
+            }
+
+            if(!getExtValue(parameter_values_p, 1, &cert, 0, 1, 0))
+            {
+                ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+                break;
+            }
+
+
+             if(cert)  //out
+             {
+                 ret = one_gpio_export(mode, 2);
+             }
+             else   //in
+             {
+                 ret = one_gpio_export(mode, 3);
+             }
+
+
+             if(ret)
+             {
+                 ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+             }
+             else
+             {
+                 ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL);
+             }
+
+            break;
+        }
+        default:
+        {
+            break;
+        }
+    }
+
+    return ret;
+}
+
+utlReturnCode_T MBTK_AT_CGSETV_PROCESS(const utlAtParameterOp_T op,
+                                        const char *command_name_p,
+                                        const utlAtParameterValue_P2c parameter_values_p,
+                                        const size_t num_parameters,
+                                        const char *info_text_p,
+                                        unsigned int *xid_p,
+                                        void *arg_p)
+{
+    UNUSEDPARAM(command_name_p);
+    UNUSEDPARAM(num_parameters);
+    UNUSEDPARAM(info_text_p);
+
+    utlReturnCode_T ret = utlFAILED;
+    TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
+    unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index);
+    *xid_p = At_handle;
+    char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
+
+    static int mode = 0;
+    static int cert = 0;
+
+    LOG("MBTK_AT_MTEST_PROCESS enter with command_op [%s]", op2str(op));
+
+    switch(op)
+    {
+        case TEL_EXT_SET_CMD :
+        {
+            if(!getExtValue(parameter_values_p, 0, &mode, 0, 139, 0))
+            {
+                ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+                break;
+            }
+
+            if(!getExtValue(parameter_values_p, 1, &cert, 0, 1, 0))
+            {
+                ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+                break;
+            }
+
+             if(cert) //hight
+             {
+                 ret = one_gpio_export(mode, 1);
+             }
+             else   //low
+             {
+                 ret = one_gpio_export(mode, 0);
+             }
+
+
+             if(ret)
+             {
+                 ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+             }
+             else
+             {
+                 ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL);
+             }
+
+            break;
+        }
+        default:
+        {
+            break;
+        }
+    }
+
+    return ret;
+}
+
+
+utlReturnCode_T MBTK_AT_MDUMP_PROCESS(const utlAtParameterOp_T op,
+                                        const char *command_name_p,
+                                        const utlAtParameterValue_P2c parameter_values_p,
+                                        const size_t num_parameters,
+                                        const char *info_text_p,
+                                        unsigned int *xid_p,
+                                        void *arg_p)
+{
+    UNUSEDPARAM(command_name_p);
+    UNUSEDPARAM(num_parameters);
+    UNUSEDPARAM(info_text_p);
+
+    utlReturnCode_T ret = utlFAILED;
+    TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
+    unsigned int at_handle = MAKE_AT_HANDLE(sAtp_index);
+    char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
+    int arg1 = 0;
+    *xid_p = at_handle;
+
+    LOG("MBTK_AT_MDUMP_PROCESS enter with command_op [%s]", op2str(op));
+
+    switch(op)
+    {
+        case TEL_EXT_GET_CMD :
+        {
+            char dump[10];
+            memset(dump, 0, 10);
+            property_get("persist.mbtk.dump", dump, "0");
+            snprintf(resp_buf, MBTK_AT_RESP_LEN_MAX, "+MDUMP: %d\r\n", atoi(dump));
+            ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
+            break;
+        }
+        case TEL_EXT_SET_CMD :
+        {
+            int adc_ret;
+            if(!getExtValue(parameter_values_p, 0, &arg1, 0, 1, 0))
+            {
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+                break;
+            }
+            char dump[10];
+            memset(dump, 0, 10);
+            if(arg1 == 1) {
+                memcpy(dump, "1", 1);
+            } else {
+                memcpy(dump, "0", 1);
+            }
+            if(property_set("persist.mbtk.dump", dump))
+            {
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
+            } else {
+                ret = ATRESP(at_handle, ATCI_RESULT_CODE_OK, 0, NULL);
+            }
+            break;
+        }
+        default:
+        {
+            break;
+        }
+    }
+
+    return ret;
+}
+
+