diff --git a/mbtk/libql_lib_v2/Makefile b/mbtk/libql_lib_v2/Makefile
new file mode 100755
index 0000000..43259aa
--- /dev/null
+++ b/mbtk/libql_lib_v2/Makefile
@@ -0,0 +1,51 @@
+BUILD_ROOT = $(shell pwd)/..
+include $(BUILD_ROOT)/Make.defines
+
+LOCAL_PATH=$(BUILD_ROOT)/libql_lib_v2
+
+INC_DIR +=
+
+LIB_DIR +=
+
+LIBS += -llog -lubus -lubox -lblobmsg_json -lrilutil -lmbtk_lib -lmbtk_ril -lmbtk_fota -lmbtk_http -lmbtk_factory -lmbtk_audio
+
+CFLAGS += -shared -Wl,-shared,-Bsymbolic
+
+DEFINE +=
+
+MY_FILES_PATH:=$(LOCAL_PATH)/src
+#ifeq ($(CONFIG_MBTK_QL_SUPPORT),y)
+#MY_FILES_PATH += $(LOCAL_PATH)/ql
+#endif
+
+#ifeq ($(CONFIG_MBTK_PLATFORM),linux)
+#MY_FILES_PATH += $(LOCAL_PATH)/platform/linux
+#endif
+
+#MY_FILES_SUFFIX:=%.c %.cpp
+#My_All_Files := $(foreach src_path,$(MY_FILES_PATH), $(shell find "$(src_path)" -type f))
+#MY_SRC_LIST  := $(filter $(MY_FILES_SUFFIX),$(My_All_Files))
+#MY_SRC_LIST  := $(MY_SRC_LIST:$(LOCAL_PATH)/%=%)
+
+LOCAL_SRC_FILES = $(wildcard src/*.c) $(wildcard src/*.cpp)
+$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+
+OBJS = $(patsubst %.c, %.o, $(patsubst %.cpp, %.o, $(LOCAL_SRC_FILES)))
+$(info OBJS = $(OBJS))
+
+dtarget := $(OUT_DIR)/lib/libql_lib.so
+
+all: $(dtarget)
+
+$(dtarget): $(OBJS)
+	$(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $(OBJS) -o $@
+
+%.o:%.c
+	$(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cpp
+	$(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+clean:
+	rm -f $(OBJS) $(dtarget)
+
diff --git a/mbtk/libql_lib_v2/src/ql_adc.c b/mbtk/libql_lib_v2/src/ql_adc.c
new file mode 100755
index 0000000..812427e
--- /dev/null
+++ b/mbtk/libql_lib_v2/src/ql_adc.c
@@ -0,0 +1,12 @@
+#include "mbtk_adc.h"
+#include "ql/ql_adc.h"
+
+int ql_adc_show(Enum_QADC qadc)
+{
+    if(qadc == ADC0 || qadc == ADC1) {
+        return mbtk_adc_get((mbtk_adc_enum)qadc);
+    } else {
+        return -1;
+    }
+}
+
diff --git a/mbtk/libql_lib_v2/src/ql_atc.c b/mbtk/libql_lib_v2/src/ql_atc.c
new file mode 100755
index 0000000..cd1cf49
--- /dev/null
+++ b/mbtk/libql_lib_v2/src/ql_atc.c
@@ -0,0 +1,43 @@
+#include "mbtk_at.h"
+/*******************************************************
+* @method: ql_atc_init
+* @Description: initialize environment variables.
+* @param: void
+* @return:
+         success: return 0
+         error: return !0
+********************************************************/
+int ql_atc_init()
+{
+    return mbtk_at_init();
+}
+
+/*******************************************************
+* @method: ql_atc_release
+* @Description: release environment variables.
+* @param: void
+* @return:
+         success: return 0
+         error: return !0
+********************************************************/
+int ql_atc_release()
+{
+    return mbtk_at_deinit();
+}
+
+/*******************************************************
+* @method: ql_atc_send
+* @Description: send at command(synchronous)
+                use this api should first call init api and finish call release api
+* @param:
+         cmd: at command
+         resp: at return value
+         len: response value length
+* @return:
+         success: return 0
+         error: return !0
+********************************************************/
+int ql_atc_send(char* cmd, char* resp, int resp_len)
+{
+    return mbtk_at_send(cmd, resp, resp_len);
+}
diff --git a/mbtk/libql_lib_v2/src/ql_audio.c b/mbtk/libql_lib_v2/src/ql_audio.c
new file mode 100755
index 0000000..d95ca9e
--- /dev/null
+++ b/mbtk/libql_lib_v2/src/ql_audio.c
@@ -0,0 +1,875 @@
+
+#include "ql/ql_audio.h"
+#include "mbtk_log.h"
+#include "mbtk_audio2.h"
+
+typedef enum {
+    AUDIO_PLAY_STATE_STOP,
+    AUDIO_PLAY_STATE_RUNNING,
+    AUDIO_PLAY_STATE_PAUSE
+} audio_play_state_enum;
+
+#define AUDIO_HANDLE 1
+#define WAV_PLAY_BUFF 1024
+
+#ifdef MBTK_AF_SUPPORT
+static mbtk_audio_handle player_hdl = NULL;
+static int player_hdl_1 = AUDIO_HANDLE;
+static _cb_onRecorder record_cb_fun = NULL;
+static int Samprate = 8000;
+#endif
+
+static int sample_rate = 8000;
+static int play_handle = AUDIO_HANDLE;
+static _cb_onPlayer play_cb_func = NULL;
+static _cb_onRecorder recorder_cb_fun = NULL;
+static int is_running = 0;
+static audio_play_state_enum play_state = AUDIO_PLAY_STATE_STOP;
+static int play_exit = 1;
+
+static void recorder_cb_func(void *data, uint32 data_len)
+{
+    if(recorder_cb_fun) {
+        recorder_cb_fun(AUD_RECORDER_START, (unsigned char*)data, data_len);
+    }
+}
+
+static int play_stream(unsigned char* pData, unsigned int length)
+{
+    int rc, len, frames = 0;
+    int result = 0;
+
+    play_state = AUDIO_PLAY_STATE_RUNNING;
+    play_exit = 0;
+    int data_send = 0;
+
+    if (mbtk_audio_pcm_play_start()) {
+        printf("%s: error opening output device.", __FUNCTION__);
+        return -1;
+    }
+
+    if(pData && length > 0) {
+        while (play_state != AUDIO_PLAY_STATE_STOP) {
+            if(play_state == AUDIO_PLAY_STATE_RUNNING) {
+                if (data_send >= length) {
+                    LOGE("%s: Read pcm stream end.", __FUNCTION__);
+                    break;
+                }
+
+                if(length - data_send > WAV_PLAY_BUFF) {
+                    len = WAV_PLAY_BUFF;
+                } else {
+                    len = length - data_send;
+                }
+
+                if((rc = mbtk_audio_pcm_play_data_send(pData + data_send, len)) != len) {
+                    LOGE("Send data %d/%d", rc, len);
+                    result = -1;
+                    goto thread_end;
+                }
+
+                data_send += len;
+
+                LOGD("%s: No.%d frame playback", __FUNCTION__, ++frames);
+            } else {
+                usleep(200000);
+            }
+        }
+    } else {
+        result = -1;
+    }
+
+    play_state = AUDIO_PLAY_STATE_STOP;
+
+
+thread_end:
+    mbtk_audio_pcm_play_stop();
+    play_exit = 1;
+    LOGD("%s: finished pcm playback.", __FUNCTION__);
+    return result;
+}
+
+static int play_by_fd(int fd, int offset)
+{
+    int rc, len, frames = 0;
+    int result = 0;
+    char buf[WAV_PLAY_BUFF];
+
+    play_state = AUDIO_PLAY_STATE_RUNNING;
+    if(play_cb_func)
+        play_cb_func(play_handle , AUDIO_PLAY_STATE_RUNNING);
+    play_exit = 0;
+    if(fd > 0) {
+        if(offset > 0) {
+            lseek(fd, offset, SEEK_SET);
+        }
+        
+        if (mbtk_audio_pcm_play_start()) {
+            printf("%s: error opening output device.", __FUNCTION__);
+            return -1;
+        }
+
+        
+        while (play_state != AUDIO_PLAY_STATE_STOP) {
+            if(play_state == AUDIO_PLAY_STATE_RUNNING) {
+                memset(buf, 0x00, sizeof(buf));
+                len = read(fd, buf, WAV_PLAY_BUFF);
+                if (len == -1) {
+                    LOGE("%s: error reading from file", __FUNCTION__);
+                    result = -1;
+                    goto thread_end;
+                }
+
+                if (len == 0) {
+                    /* reached EOF */
+                    LOGE("%s: Read wav file end.", __FUNCTION__);
+                    break;
+                }
+
+                if((rc = mbtk_audio_pcm_play_data_send(buf, len)) < len) {
+                    LOGE("Send data %d/%d", rc, len);
+                    result = -1;
+                    goto thread_end;
+                }
+
+                LOGD("%s: No.%d frame playback", __FUNCTION__, ++frames);
+            } else {
+                usleep(200000);
+            }
+        }
+    } else {
+        result = -1;
+    }
+
+    play_state = AUDIO_PLAY_STATE_STOP;
+    if(play_cb_func)
+        play_cb_func(play_handle , AUDIO_PLAY_STATE_STOP);
+
+thread_end:
+    mbtk_audio_pcm_play_stop();
+    play_exit = 1;
+    LOGD("%s: finished pcm playback.", __FUNCTION__);
+    return result;
+}
+
+/*****************************************************************
+* Function:     Ql_AudPlayer_Open
+*
+* Description:
+*               Open audio play device, and specify the callback function.
+*               This function can be called twice to play different audio sources.
+*
+* Parameters:
+*               device  : a string that specifies the PCM device.
+*                         NULL, means the audio will be played on the default PCM device.
+*
+*                         If you want to mixedly play audio sources, you can call this
+*                         API twice with specifying different PCM device.
+*                         The string devices available:
+*                            "hw:0,0"  (the default play device)
+*                            "hw:0,13" (this device can mix audio and TTS)
+*                            "hw:0,14"
+*
+*		        cb_func : callback function for audio player.
+*                         The results of all operations on audio player
+*                         are informed in callback function.
+*
+* Return:
+*               pcm device handle on success
+*               -1 for failure
+*****************************************************************/
+int Ql_AudPlayer_Open(char* device, _cb_onPlayer cb_func)
+{
+#ifdef MBTK_AF_SUPPORT
+    player_hdl = mbtk_audio_open_new(MBTK_AUTIO_TYPE_OUT, 1, Samprate, cb_func);
+    if(player_hdl == NULL)
+    {
+        return -1;
+    }
+    else
+    {
+        return player_hdl_1 = AUDIO_HANDLE;
+    }
+#else
+    if(is_running || mbtk_audio_pcm_init()) {
+        return -1;
+    } else {
+        play_cb_func = cb_func;
+        is_running = 1;
+        return play_handle;
+    }
+#endif
+}
+
+/*========================================================================
+  FUNCTION:  Ql_AudPlayer_Play
+=========================================================================*/
+/** @brief
+    This function writes pcm data to pcm device to play.
+
+    @param[in] hdl, the handle returned by Ql_AudPlayer_Open().
+    @param[in] pData, pointer to the start address of pcm data.
+    @param[in] length, the length of pcm data.
+
+    @return
+    on success, the return value is the number of bytes to play
+    on failure, the return value is -1;
+
+    @dependencies
+    Ql_AudPlayer_Open() must be first called successfully.
+*/
+/*=======================================================================*/
+int Ql_AudPlayer_Play(int hdl, unsigned char* pData, unsigned int length)
+{
+#ifdef MBTK_AF_SUPPORT
+    if(hdl != player_hdl_1 || player_hdl == NULL){
+        LOGE("Handle error : %d", hdl);
+        return -1;
+    }
+    return mbtk_audio_play_stream_new((void *)player_hdl, pData, length,50);
+
+#else
+    if(!is_running || hdl != play_handle) {
+        LOGE("Handle error : %d", hdl);
+        return -1;
+    }
+
+    return play_stream(pData, length);
+#endif
+}
+
+/*========================================================================
+  FUNCTION:  Ql_AudPlayer_PlayFrmFile
+=========================================================================*/
+/** @brief
+    This function plays the pcm data from the specified file.
+
+    @param[in] hdl, the handle returned by Ql_AudPlayer_Open().
+    @param[in] fd, a file descriptor that contains pcm data.
+               Note:
+                 the file offset should be set to the start position of pcm
+                 data region, which means you should move the file offset
+                 skipping the file header (such as wave header, amr header).
+    @param[in] offset, file offset. Please set it to -1 if no need to use.
+
+    @return
+       0 on success
+      -1 on failure
+
+    @dependencies
+    Ql_AudPlayer_Open() must be first called successfully.
+*/
+/*=======================================================================*/
+
+int  Ql_AudPlayer_PlayFrmFile(int hdl, int fd, int offset)
+{
+#ifdef MBTK_AF_SUPPORT
+    if(hdl != player_hdl_1 || player_hdl == NULL){
+        LOGE("Handle error : %d", hdl);
+        return -1;
+    }
+
+    return mbtk_audio_play_file_new((void *)player_hdl, fd, offset);
+
+#else
+    if(!is_running || hdl != play_handle) {
+        LOGE("Handle error : %d", hdl);
+        return -1;
+    }
+
+    return play_by_fd(fd, offset);
+#endif
+}
+
+//
+// Function:  Ql_AudPlayer_Pause
+//
+// Description:
+//   Pause playing.
+// @param hdl:
+//   Handle received from Ql_AudPlayer_Open().
+int  Ql_AudPlayer_Pause(int hdl)
+{
+    if(!is_running || hdl != play_handle) {
+        LOGE("Handle error : %d", hdl);
+        return -1;
+    }
+
+    play_state = AUDIO_PLAY_STATE_PAUSE;
+
+    while(!play_exit) {
+        usleep(10000);
+    }
+
+    return 0;
+}
+
+//
+// Function:  Ql_AudPlayer_Resume
+//
+// Description:
+//   Resume playing.
+// @param hdl:
+//   Handle received from Ql_AudPlayer_Open().
+int  Ql_AudPlayer_Resume(int hdl)
+{
+    if(!is_running || hdl != play_handle) {
+        LOGE("Handle error : %d", hdl);
+        return -1;
+    }
+
+    play_state = AUDIO_PLAY_STATE_RUNNING;
+
+    while(!play_exit) {
+        usleep(10000);
+    }
+    return 0;
+}
+
+//
+// Function:  Ql_AudPlayer_Stop
+//
+// Description:
+//   Stop playing audio
+// hdl:
+//   Handle received from Ql_AudPlayer_Open().
+void Ql_AudPlayer_Stop(int hdl)
+{
+    if(!is_running || hdl != play_handle) {
+        LOGE("Handle error : %d", hdl);
+        return;
+    }
+
+    play_state = AUDIO_PLAY_STATE_STOP;
+
+    while(!play_exit) {
+        usleep(10000);
+    }
+}
+
+//
+// Function:  Ql_AudPlayer_Close
+//
+// Description:
+//   Close player, and free the resource.
+// @param hdl:
+//   Handle received from Ql_AudPlayer_Open().
+void Ql_AudPlayer_Close(int hdl)
+{
+#ifdef MBTK_AF_SUPPORT
+    if(hdl != player_hdl_1 || player_hdl == NULL){
+        LOGE("Handle error : %d", hdl);
+        return -1;
+    }
+
+    mbtk_audio_close_new((void *)player_hdl);
+    player_hdl_1 = 0;
+
+#else
+    if(!is_running || hdl != play_handle) {
+        LOGE("Handle error : %d", hdl);
+        return;
+    }
+    play_state = AUDIO_PLAY_STATE_STOP;
+
+    while(!play_exit) {
+        usleep(10000);
+    }
+
+    is_running = 0;
+    mbtk_audio_pcm_deinit();
+#endif
+}
+
+
+int Ql_AudPlayer_set_LessDataThreshold(int hdl, unsigned short threshSize)
+{
+
+    return 0;
+}
+
+int Ql_AudPlayer_get_freeSpace(int hdl)
+{
+
+    return 0;
+}
+
+
+/*****************************************************************
+* Function:     Ql_AudRecorder_Open
+*
+* Description:
+*               Open audio record device, and specify the callback function.
+*
+* Parameters:
+*               device  : not used. MUST be NULL.
+*
+*		        cb_func : callback function for audio player.
+*                         The results of all operations on audio recorder
+*                         are informed in callback function.
+*
+* Return:
+*               pcm device handle
+*               -1 for failure
+*****************************************************************/
+int  Ql_AudRecorder_Open(char* device, _cb_onRecorder cb_fun)
+{
+    if(is_running || mbtk_audio_pcm_init()) {
+        return -1;
+    } else {
+        is_running = 1;
+        recorder_cb_fun = cb_fun;
+        return play_handle;
+    }
+}
+
+//
+// Function:  Ql_AudRecorder_StartRecord
+//
+// Description:
+//   Start to record.
+//   The record data is output in _cb_onRecorder.
+//
+// Return:
+//            0 on success
+//            -1 on failure
+int  Ql_AudRecorder_StartRecord(void)
+{
+    if(!is_running) {
+        LOGE("No open device.");
+        return -1;
+    }
+
+    return mbtk_audio_pcm_recorder_start(recorder_cb_func);
+}
+
+//
+// Function:  Ql_AudRecorder_Pause
+//
+// Description:
+//   Pause recording
+int  Ql_AudRecorder_Pause(void)
+{
+    if(!is_running) {
+        LOGE("No open device.");
+        return -1;
+    }
+
+    return mbtk_audio_pcm_recorder_pause();
+}
+
+//
+// Function:  Ql_AudRecorder_Resume
+//
+// Description:
+//   Resume recording
+int  Ql_AudRecorder_Resume(void)
+{
+    if(!is_running) {
+        LOGE("No open device.");
+        return -1;
+    }
+
+    return mbtk_audio_pcm_recorder_resume();
+}
+
+//
+// Function:  Ql_AudRecorder_Stop
+//
+// Description:
+//   Stop recording
+void Ql_AudRecorder_Stop(void)
+{
+    if(!is_running) {
+        LOGE("No open device.");
+        return;
+    }
+
+    mbtk_audio_pcm_recorder_stop();
+}
+
+//
+// Function:  Ql_AudRecorder_Close
+//
+// Description:
+//   Close recorder, and free the resource
+void Ql_AudRecorder_Close(void)
+{
+    if(!is_running) {
+        LOGE("No open device.");
+        return;
+    }
+
+    is_running = 0;
+    mbtk_audio_pcm_deinit();
+}
+
+//
+// Function:  Ql_clt_set_mixer_value
+//
+// Description:
+//   Close recorder, and free the resource
+boolean Ql_clt_set_mixer_value(const char *device, int count, const char *value)
+{
+
+    return FALSE;
+}
+
+
+int Ql_AudTone_Open(char* device, _cb_onPlayer cb)//cb not support now
+{
+    return 0;
+}
+
+int Ql_AudTone_Start(int hdl, struct Ql_TonePara *para)
+{
+    return 0;
+}
+
+void Ql_AudTone_Stop(int hdl)
+{
+
+}
+
+void Ql_AudTone_Close(int hdl)
+{
+
+}
+
+
+//****************QL Codec API************************//
+
+//
+// Function:  Ql_AudCodec_Set_ALC5616_DRCAGC
+//
+// Description:
+//   Set ALC5616 DRC/AGC configuration
+int Ql_AudCodec_Set_ALC5616_DRCAGC(const char *i2c, struct Ql_ALC5616_DRCAGC *cfg)
+{
+    return 0;
+}
+
+//
+// Function:   Ql_Update_wav_size
+//
+// Description:
+//   update wav format file size in the header
+// @param fd:
+//   wav file discriptor
+// @param size:
+//   wav file size to update
+int Ql_Update_wav_size(int fd, int size)
+{
+    return 0;
+}
+
+//add by grady, 2018-5-29
+/*
+ * describe : this function is use to open pcm device
+ * paras    :
+ *        device : this should be fix to hw:0,0
+ *        flags ; pcm play flags
+ *        rate: sample rate
+ *        channels  : audio channal 1 or 2
+ *        format: format to play or record, 16bit line,MP3
+ *        hostless: if there is no file it is true
+ * return    :
+ *        pcm : pcm handle, use can use this handle to read write data
+ */
+struct pcm *quec_pcm_open(char *device, unsigned flags, unsigned rate, unsigned channels, unsigned format, unsigned hostless)
+{
+    return NULL;
+}
+
+/*
+ * describe : this function is use to close pcm handle
+ * paras    :
+ *        pcm : pcm handle to close
+ * return    :
+ */
+int quec_pcm_close(struct pcm *pcm )
+{
+    return 0;
+}
+
+/*
+ * describe : this function is use to read pcm buffer
+ * paras    :
+ *        pcm : pcm handle to write date
+ *        buffer: data buffer
+ *        lenth: data length
+ * return    :
+ */
+int quec_read_pcm(struct pcm *pcm, void * buffer, int length)
+{
+
+    return 0;
+}
+
+/*
+ * describe : this function is use to get pcm buffer lenth
+ * paras    :
+ *        lenth: data length
+ * return
+ *        buffer length
+ */
+int quec_get_pem_buffer_len(struct pcm *pcm)
+{
+
+    return 0;
+}
+
+void dtmf_cb1(char dtmf)
+{
+    printf("%s:%c\n", __FUNCTION__, dtmf);
+}
+
+/**
+ * @brief Set RX DSP Gain
+ * @details
+ *      Gain support [-36,12] dB
+ *
+ * @param gain
+ *      DSP gain
+ */
+
+int Ql_Rxgain_Set(int value)
+{
+#ifdef MBTK_AF_SUPPORT
+    int volume =0;
+    if(value < -36 || value > 13)
+    {
+        volume = 0;
+    }
+    else
+    {
+        volume = value;
+    }
+
+    if(player_hdl==NULL)
+       return 0;
+
+    char databuf[1025]={0};
+    memcpy(databuf, "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ", 1024);
+
+    mbtk_audio_play_stream_new(player_hdl, databuf, 1024, volume);
+    return 0;
+#else
+    mbtk_dsp_gain_set(1, value);
+    return 0;
+#endif
+    return 0;
+}
+
+
+/** Ql_Playback_Samprate_Set
+ * @brief Set Playback PCM Samprate
+ * @details
+ *      0 for NB 1 for WB
+ *
+ * @param samprate
+ *      samprate for PCM playback,default value is PCM NB
+ */
+int Ql_Playback_Samprate_Set(int samprate)
+{
+    printf("samprate is %d \n",samprate);
+    if(samprate == 1)
+    {
+        sample_rate = 16000;
+        mbtk_audio_pcm_sample_rate_set(MBTK_AUDIO_SAMPLE_RATE_16000);
+    }
+    else{
+        mbtk_audio_pcm_sample_rate_set(MBTK_AUDIO_SAMPLE_RATE_8000);
+        sample_rate = 8000;
+    }
+
+    return 0;
+}
+
+int Ql_Mp3_To_Wav(const char *wavpath, char *mp3path)
+{
+    return 0;
+}
+
+int Ql_Mp3_To_Play(char *mp3path, int hdl,int sample_rate)
+{
+    return 0;
+}
+
+//add by grady, 2018-6-2
+/*
+ * describe : this function is use to open mixer device
+ * paras        :
+ *              device: mixer device
+ * return
+ *              mixer handle
+ */
+struct mixer *quec_mixer_open(const char *device)
+{
+
+    return NULL;
+}
+
+/*
+ * describe : this function is use to close mixer device
+ * paras        :
+ *              mixer: mixer handle
+ * return
+ *              none
+ */
+void quec_mixer_close(struct mixer *mixer)
+{
+
+
+}
+
+/*
+ * describe : this function is use to get mixer devie control
+ * paras        :
+ *              mixer: mixer handle
+ *              name: mixer device
+ *              index: mixer index
+ * return
+ *              mixer control
+ */
+struct mixer_ctl *quec_mixer_get_control(struct mixer *mixer, const char *name, unsigned index)
+{
+
+    return NULL;
+}
+
+/*
+ * describe : this function is use to set mulvalues
+ * paras        :
+ *              mixer: mixer handle
+ *              count: count
+ *              argv: data
+ * return       :
+ *
+ */
+int quec_mixer_ctl_mulvalues(struct mixer_ctl *ctl, int count, char ** argv)
+{
+
+    return 0;
+}
+
+
+//end grady
+
+/*****************************************************************
+* Function:     Ql_AudPlayer_OpenExt
+*
+* Description:
+*               expend function from Ql_AudPlayer_OpenExt
+*               Open audio play device, and specify the callback function.
+*               This function can be called twice to play different audio sources.
+*
+* Parameters:
+*               device  : a string that specifies the PCM device.
+*                         NULL, means the audio will be played on the default PCM device.
+*
+*                         If you want to mixedly play audio sources, you can call this
+*                         API twice with specifying different PCM device.
+*                         The string devices available:
+*                            "hw:0,0"  (the default play device)
+*                            "hw:0,13" (this device can mix audio and TTS)
+*                            "hw:0,14"
+*
+*		        cb_func : callback function for audio player.
+*                         The results of all operations on audio player
+*                         are informed in callback function.
+*
+*               flags   : pcm flags, eg: PCM_MMAP, PCM_NMMAP.
+*
+*               channels: pcm sample channels.
+*
+*               rate    : pcm sample rate.
+*
+*               format  : pcm sample fromat
+*
+* Return:
+*               pcm device handle
+*               NULL, fail
+*****************************************************************/
+int Ql_AudPlayer_OpenExt(
+            char *dev,
+            _cb_onPlayer cb_fun,
+            int flags,
+            int channels,
+            int rate,
+            int format)
+{
+    return 0;
+}
+
+/*****************************************************************
+* Function:     Ql_AudRecorder_Open
+*
+* Description:
+*               Open audio record device, and specify the callback function.
+*
+* Parameters:
+*               device  : not used. MUST be NULL.
+*
+*		        cb_func : callback function for audio player.
+*                         The results of all operations on audio recorder
+*                         are informed in callback function.
+*
+*               flags   : pcm flags, eg: PCM_MMAP, PCM_NMMAP.
+*
+*               channels: pcm sample channels.
+*
+*               rate    : pcm sample rate.
+*
+*               format  : pcm sample fromat
+*
+* Return:
+*               pcm device handle
+*               NULL, fail
+*****************************************************************/
+int Ql_AudRecorder_OpenExt(
+            char *dev,
+            _cb_onRecorder cb_fun,
+            int flags,
+            int channels,
+            int rate,
+            int format)
+{
+
+
+    return 0;
+}
+
+/*
+* Function:     uac enable
+*
+* Description:
+*               uac enable
+*
+* Parameters:
+*               none
+* Return:
+*               TURE or FALSE
+*/
+int ql_uac_enable(void)
+{
+
+    return 0;
+}
+
+/*
+* Function:     uac disable
+*
+* Description:
+*               uac disable
+*
+* Parameters:
+*               none
+* Return:
+*               TURE or FALSE
+*/
+int ql_uac_disable(void)
+{
+
+    return 0;
+}
diff --git a/mbtk/libql_lib_v2/src/ql_call.c b/mbtk/libql_lib_v2/src/ql_call.c
new file mode 100755
index 0000000..700f93d
--- /dev/null
+++ b/mbtk/libql_lib_v2/src/ql_call.c
@@ -0,0 +1,821 @@
+/**
+ *   \file ql_call.c
+ *   \brief A Documented file.
+ *
+ *  Detailed description
+ *   \Author:  js.wang<js.wang@mobiletek.cn>
+ *   \Version: 1.0.0
+ *   \Date: 2022-01-18
+ */
+#include "ql/ql_mcm_call.h"
+#include <telephony/ril.h>
+#include <telephony/ril_ext.h>
+#include "ql/ql_mcm.h"
+#include "rilutil.h"
+#include "mbtk_log.h"
+
+// #define DEBUG 1
+
+#ifdef DEBUG
+	#define mbtk_call_log(...)                    printf(__VA_ARGS__)
+#else
+	#define mbtk_call_log(...)
+#endif
+
+struct ql_call_ubus_t
+{
+    struct ubus_context     *ctx;
+
+    /* RIL */
+    struct ubus_subscriber 	ril_ind_event;
+    uint32_t	 		    ril_subscriber_id;
+    uint32_t	 		    ril_request_id;
+    uint8_t	 		        auto_answer;
+    uint32_t                answer_time;
+    pthread_t  call_status_pthread;
+    ql_mcm_voice_calls_state_t  call_state;
+    QL_VoiceCall_CommonStateHandlerFunc_t _voice_call_common_state_handler;
+    QL_VoiceCall_StateHandlerFunc_t   _voice_call_state_handler;
+};
+
+const char *RIL_MessageMap[] =
+{
+        "RIL_CALL_ACTIVE",       //0,
+        "RIL_CALL_HOLDING",      //1,
+        "RIL_CALL_DIALING",      //2,    /* MO call only */
+        "RIL_CALL_ALERTING",     //3,    /* MO call only */
+        "RIL_CALL_INCOMING",     //4,    /* MT call only */
+        "RIL_CALL_WAITING",      //5,    /* MT call only */
+        "RIL_CALL_OFFERING",     //6,    /* MT call offering (call setup) */
+        "RIL_CALL_DISCONNECTING",//7,    /* call in disconnect procedure */
+        "RIL_CALL_DISCONNECTED"  //8,    /* call is disconnected */
+};
+static struct ql_call_ubus_t *ql_call_ubus = NULL;
+static void ql_voice_call_answer(struct uloop_timeout *timeout);
+static struct uloop_timeout voice_call_answer_timeout =
+{
+    .cb = ql_voice_call_answer,
+};
+
+static void ql_voice_call_answer(struct uloop_timeout *timeout)
+{
+    QL_Voice_Call_Answer(ql_call_ubus, 0);
+    // uloop_timeout_set(timeout, 2000);
+    return;
+}
+
+int ql_call_handle_ril_ind(struct ubus_context *ctx, unsigned int rilid, unsigned int rilerror, char *data, int data_len)
+{
+	UNUSED(data_len);
+	UNUSED(ctx);
+
+    int datalen = 0, callID = 0;
+	int ret = 0;
+
+	if (rilerror) {
+		return -1;
+	}
+
+	mbtk_call_log("call_handle_ril_ind: rcv %d\n", rilid);
+
+	 switch(rilid)
+	 {
+		case RIL_UNSOL_ECALLDATA:								//+ecalldata
+			// ecallHandleEcalldata(data);
+			break;
+
+		case RIL_UNSOL_ECALLONLY:								//+ecallonly
+			// ecallHandleEcallonly(data);
+			break;
+
+        case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED_EXT: /*"CC" 1510*/
+        {
+            RIL_Call *rilCall = (RIL_Call *)data;
+            callID = rilCall->index;
+
+            mbtk_call_log("%s: id %d=RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED_EXT (len=%d) (state=%s), call index=%d\n",
+                    __FUNCTION__, rilid, datalen, RIL_MessageMap[(int)rilCall->state], callID);
+
+            mbtk_call_log("Received from Ril, name=%s, num=%s\n", rilCall->name, rilCall->number);
+            ql_call_ubus->call_state.calls_len = 1;
+            ql_call_ubus->call_state.calls[0].call_id;
+            memcpy(ql_call_ubus->call_state.calls[0].number, rilCall->number, strlen(rilCall->number));
+            ql_call_ubus->call_state.calls[0].state = rilCall->state;
+            switch (rilCall->state)
+            {
+                //Call connected,  for MO & MT both
+                case RIL_CALL_ACTIVE:
+                    mbtk_call_log("%s, RIL_CALL_ACTIVE, call index=%d connected!!\n", __FUNCTION__, callID);
+                    ql_call_ubus->call_state.calls[0].state = E_QL_MCM_VOICE_CALL_STATE_ACTIVE;
+                    break;
+
+                //MT call only
+                case RIL_CALL_INCOMING:
+                    mbtk_call_log("%s, RIL_CALL_INCOMING!!\n", __FUNCTION__);
+                    ql_call_ubus->call_state.calls[0].state = E_QL_MCM_VOICE_CALL_STATE_INCOMING;
+                    if(!ql_call_ubus->auto_answer)
+                    {
+                        mbtk_call_log("%s, auto_answer:%d!!\n", __FUNCTION__, ql_call_ubus->answer_time);
+                        uloop_timeout_set(&voice_call_answer_timeout, ql_call_ubus->answer_time);
+                    }
+                    break;
+
+                //MO call only
+                case RIL_CALL_ALERTING:
+                    mbtk_call_log("%s, RIL_CALL_ALERTING, call index=%d alerting!!\n", __FUNCTION__, callID);
+                    ql_call_ubus->call_state.calls[0].state = E_QL_MCM_VOICE_CALL_STATE_ALERTING;
+                    break;
+
+                case RIL_CALL_WAITING:  //MT call only
+                    mbtk_call_log("%s, RIL_CALL_WAITING, call index=%d alerting!!\n", __FUNCTION__, callID);
+                    ql_call_ubus->call_state.calls[0].state = E_QL_MCM_VOICE_CALL_STATE_WAITING;
+                    break;
+
+                case RIL_CALL_DISCONNECTED:
+                    mbtk_call_log("%s, RIL_CALL_DISCONNECTED, call index=%d disconnected!!\n", __FUNCTION__, callID);
+                    ql_call_ubus->call_state.calls[0].state = E_QL_MCM_VOICE_CALL_STATE_END;
+                    break;
+
+                case RIL_CALL_HOLDING:
+                    ql_call_ubus->call_state.calls[0].state = E_QL_MCM_VOICE_CALL_STATE_HOLDING;
+                    mbtk_call_log("%s, RIL_CALL_HOLDING, call index=%d hold!!\n", __FUNCTION__, callID);
+                    break;
+
+                case RIL_CALL_DIALING:  //MO call only
+                    ql_call_ubus->call_state.calls[0].state = E_QL_MCM_VOICE_CALL_STATE_DIALING;
+                    mbtk_call_log("%s, RIL_CALL_DIALING, call index=%d hold!!\n", __FUNCTION__, callID);
+                    break;
+                case RIL_CALL_OFFERING:
+                case RIL_CALL_DISCONNECTING:
+                default:
+                    printf("%s, state=%s ignored!!\n", __FUNCTION__, RIL_MessageMap[(int)rilCall->state]);
+                    ql_call_ubus->call_state.calls[0].state = E_QL_MCM_VOICE_CALL_STATE_END;
+                    break;
+            }
+            if(ql_call_ubus->_voice_call_common_state_handler && ql_call_ubus)
+            {
+                ql_call_ubus->_voice_call_common_state_handler(E_QL_MCM_VOICE_CALL_IND, &ql_call_ubus->call_state, sizeof(ql_mcm_voice_call_ind));
+            }
+        }
+        break;
+        case RIL_UNSOL_CALL_NO_CARRIER_EXT: /*"CC" 1511*/
+            mbtk_call_log("%s: id %d=RIL_UNSOL_CALL_NO_CARRIER_EXT (len=%d)\n",
+                    __FUNCTION__, rilid, datalen);
+            ql_call_ubus->call_state.calls[0].state = E_QL_MCM_VOICE_CALL_STATE_END;
+            if(ql_call_ubus->_voice_call_common_state_handler && ql_call_ubus)
+            {
+                ql_call_ubus->_voice_call_common_state_handler(E_QL_MCM_VOICE_CALL_IND, &ql_call_ubus->call_state, sizeof(ql_mcm_voice_call_ind));
+            }
+            break;
+
+        case RIL_UNSOL_CALL_RING: /*"CC" 1018*/
+            printf("%s: id %d=RIL_UNSOL_CALL_RING (len=%d), ignored!!\n",
+                    __FUNCTION__, rilid, datalen);
+            break;
+
+        case RIL_UNSOL_DISCONNECT_CALLID: /*"CC" 1538*/
+            callID = *(int *)data;
+            ql_call_ubus->call_state.calls[0].state = E_QL_MCM_VOICE_CALL_STATE_END;
+            mbtk_call_log("%s: id %d=RIL_UNSOL_DISCONNECT_CALLID (len=%d), call index=%d!\n",
+                        __FUNCTION__, rilid, datalen, *(int *)data);
+            break;
+		default:
+			break;
+	 }
+
+	 return ret;
+}
+static void ql_call_requset_cb(struct ubus_request *req, int type, struct blob_attr *msg)
+{
+    unsigned int requestid;
+    unsigned int rilerrno;
+    void *response = NULL;
+    int responselen;
+    int ret = 0;
+
+    ret = rilutil_parseResponse(msg, &requestid, &rilerrno, &response, &responselen);
+    if(ret)
+    {
+        fprintf(stderr, "parse blob error\n");
+        goto done;
+    }
+
+    if(rilerrno)
+    {
+        // RIL_REQUEST_RELEASE_CALL
+        fprintf(stderr, "unsolicited id %d, error code %d\n", requestid, rilerrno);
+        goto done;
+    }
+
+    //process response here
+
+done:
+    if(response)
+        rilutil_freeResponseData(requestid, response, responselen);
+
+    return;
+}
+
+int ql_call_subscriber_cb(struct ubus_context *ctx, struct ubus_object *obj,
+			    struct ubus_request_data *req, const char *method, struct blob_attr *msg)
+{
+	UNUSED(ctx);
+	UNUSED(obj);
+	UNUSED(req);
+	UNUSED(method);
+
+	unsigned int requestid = 0;
+	unsigned int rilerrno = 0;
+	void *response = NULL;
+	int responselen = 0;
+	int ret = 0;
+
+	ret = rilutil_parseResponse(msg, &requestid, &rilerrno, &response, &responselen);
+	if (ret)
+		goto end;
+
+	mbtk_call_log("call_subscriber_cb: rcv %d\n", requestid);
+
+    ql_call_handle_ril_ind(ctx, requestid, rilerrno, response, responselen);
+
+end:
+	if (response)
+		rilutil_freeResponseData(requestid,response,responselen);
+
+	return 0;
+}
+
+void ql_call_subscriber_remove_cb(struct ubus_context *ctx, struct ubus_subscriber *obj, uint32_t id)
+{
+	UNUSED(ctx);
+	UNUSED(obj);
+	UNUSED(id);
+	mbtk_call_log("ql_call_subscriber_remove_cb\n");
+}
+
+static void ql_call_register_ril(void* hdl)
+{
+    static struct ubus_request req;
+    struct ql_call_ubus_t *voice_call_ubus = (struct ql_call_ubus_t *)hdl;
+    int ret;
+
+    if(hdl == NULL || ql_call_ubus == NULL)
+    {
+        printf("ARG error or not inited.");
+        return -1;
+    }
+    pthread_detach(pthread_self());
+	ret = ubus_register_subscriber(voice_call_ubus->ctx, &voice_call_ubus->ril_ind_event);
+	if (ret) {
+		printf("call_daemon: Failed to add ecall_subscriber: %s\n", ubus_strerror(ret));
+        return ret;
+    }
+
+	voice_call_ubus->ril_ind_event.cb = ql_call_subscriber_cb;
+	voice_call_ubus->ril_ind_event.remove_cb = ql_call_subscriber_remove_cb;
+
+	//register for CC ind
+	if (ubus_lookup_id(voice_call_ubus->ctx, "ril.unsol.cc", &voice_call_ubus->ril_subscriber_id)) {
+		printf("call_daemon: Failed to look up ril.unsol.cc object\n");
+        return ret;
+	}
+
+	ubus_subscribe(voice_call_ubus->ctx, &voice_call_ubus->ril_ind_event, voice_call_ubus->ril_subscriber_id);
+	mbtk_call_log("call_daemon: subscribe ril.unsol.cc object ok\n");
+    mbtk_call_log("%s!\n", __FUNCTION__);
+    while(1)
+    {
+        uloop_run();
+        printf("%s uloop_run done!\n", __FUNCTION__);
+    }
+    pthread_exit(NULL);
+}
+/* Init voice module and return h_voice, this should be called before any other APIs */
+int QL_Voice_Call_Client_Init(voice_client_handle_type *ph_voice)
+{
+    int id;
+    // Set call handle.
+    //*ph_voice = 1;
+    if(ph_voice == NULL)
+    {
+        printf("ARG error or has inited.");
+        return -1;
+    }
+    ql_call_ubus = malloc(sizeof(struct ql_call_ubus_t));
+    if(NULL == ql_call_ubus)
+    {
+        printf("malloc memory error\n");
+    }
+    memset(ql_call_ubus, 0, sizeof(struct ql_call_ubus_t));
+    uloop_init();
+
+    ql_call_ubus->ctx = ubus_connect(NULL);
+    if(!ql_call_ubus->ctx)
+    {
+        printf("Failed to connect to ubus");
+        goto out;
+    }
+
+    ubus_add_uloop(ql_call_ubus->ctx);
+
+    if (ubus_lookup_id(ql_call_ubus->ctx, "ril", &ql_call_ubus->ril_request_id)) {
+    	fprintf(stderr, "%s, Failed to look up test object\n", __FUNCTION__);
+    	return -1;
+    }
+    ql_call_ubus->auto_answer = E_QL_MCM_VOICE_AUTO_ANSWER_DISABLE;
+    ql_call_ubus->call_state.calls[0].state = E_QL_MCM_VOICE_CALL_STATE_END;
+    pthread_create(&ql_call_ubus->call_status_pthread, NULL, (void *)ql_call_register_ril, (void *)ql_call_ubus);
+    *ph_voice = ql_call_ubus;
+
+    return 0;
+out:
+    //uloop_done();
+
+    return 0;
+}
+
+/* DeInit voice module and release resources, this should be called at last */
+int QL_Voice_Call_Client_Deinit(voice_client_handle_type h_voice)
+{
+    int ret;
+    struct ql_call_ubus_t *voice_call_ubus = (struct ql_call_ubus_t *)h_voice;
+    // Free handle.
+
+    if(h_voice == NULL || ql_call_ubus == NULL)
+    {
+        LOGE("ARG error or not inited.");
+        printf("ARG error or not inited.");
+        return -1;
+    }
+    ret = pthread_cancel(voice_call_ubus->call_status_pthread);
+    mbtk_call_log("kill pthread : %d \n", ret);
+    pthread_join(voice_call_ubus->call_status_pthread, NULL);
+    do{
+        ret = pthread_kill(voice_call_ubus->call_status_pthread, 0);
+        mbtk_call_log("kill pthread: %d \n", ret);
+        if(ret == ESRCH)
+            printf("The specified thread does not exist or has terminated\n");
+        else if(ret == EINVAL)
+            printf("Useless signal\n");
+        else
+            mbtk_call_log("The thread exists\n");
+        usleep(100000);
+    }while(0 == ret);
+    free(h_voice);
+    ql_call_ubus = NULL;
+    uloop_done();
+    ubus_free(voice_call_ubus->ctx);
+    return 0;
+}
+
+/* Add callback function, if any call state changed, handlerPtr will be called to notify App */
+int QL_Voice_Call_AddStateHandler(voice_client_handle_type h_voice,
+                                  QL_VoiceCall_StateHandlerFunc_t   handlerPtr,
+                                  void*                             contextPtr)
+{
+    static struct ubus_request req;
+    struct ql_call_ubus_t *voice_call_ubus = (struct ql_call_ubus_t *)h_voice;
+    int ret;
+
+    if(h_voice == NULL || ql_call_ubus == NULL)
+    {
+        printf("ARG error or not inited.");
+        return -1;
+    }
+    ret = pthread_kill(voice_call_ubus->call_status_pthread, 0);
+    mbtk_call_log("kill pthread: %d \n", ret);
+    if(ret == ESRCH)
+        mbtk_call_log("The specified thread does not exist or has terminated\n");
+    else if(ret == EINVAL)
+        printf("Useless signal\n");
+    else
+        mbtk_call_log("The thread exists\n");
+    if(voice_call_ubus->ril_subscriber_id)
+    {
+        voice_call_ubus->_voice_call_state_handler = handlerPtr;
+    }
+    else
+    {
+        printf("%s error!!\n", __func__);
+        return -1;
+    }
+
+    return 0;
+}
+
+/* Remove callback function, won't receive any notify anymore */
+int QL_Voice_Call_RemoveStateHandler(voice_client_handle_type        h_voice)
+{
+	struct ql_call_ubus_t *voice_call_ubus = (struct ql_call_ubus_t *)h_voice;
+
+    if(h_voice == NULL || ql_call_ubus == NULL)
+    {
+        LOGE("ARG error or not inited.");
+        return -1;
+    }
+    voice_call_ubus->_voice_call_state_handler = NULL;
+
+    return 0;
+}
+
+
+/* Add callback function, if any call state changed, handlerPtr will be called to notify App */
+int QL_Voice_Call_AddCommonStateHandler(voice_client_handle_type h_voice,
+                                  QL_VoiceCall_CommonStateHandlerFunc_t   handlerPtr)
+{
+    static struct ubus_request req;
+    struct ql_call_ubus_t *voice_call_ubus = (struct ql_call_ubus_t *)h_voice;
+    int ret;
+
+    if(h_voice == NULL || ql_call_ubus == NULL)
+    {
+        LOGE("ARG error or not inited.");
+        return -1;
+    }
+    ret = pthread_kill(voice_call_ubus->call_status_pthread, 0);
+    mbtk_call_log("kill pthread: %d \n", ret);
+    if(ret == ESRCH)
+        mbtk_call_log("The specified thread does not exist or has terminated\n");
+    else if(ret == EINVAL)
+        printf("Useless signal\n");
+    else
+        mbtk_call_log("The thread exists\n");
+    if(voice_call_ubus->ril_subscriber_id)
+    {
+        voice_call_ubus->_voice_call_common_state_handler = handlerPtr;
+    }
+    else
+    {
+        printf("%s error!!\n", __func__);
+        return -1;
+    }
+
+
+    return 0;
+}
+
+/* Remove callback function, won't receive any notify anymore */
+int QL_Voice_Call_RemoveCommonStateHandler(voice_client_handle_type          h_voice)
+{
+	struct ql_call_ubus_t *voice_call_ubus = (struct ql_call_ubus_t *)h_voice;
+
+    if(h_voice == NULL || ql_call_ubus == NULL)
+    {
+        LOGE("ARG error or not inited.");
+        return -1;
+    }
+    voice_call_ubus->_voice_call_common_state_handler = NULL;
+
+    return 0;
+}
+
+
+/* Start call and return call_id, this can be used in the later */
+int QL_Voice_Call_Start(voice_client_handle_type    h_voice,
+                        E_QL_VCALL_ID_T             simId,
+                        char*                       phone_number,   ///< [IN] Destination identifier for the voice
+                        int                         *call_id)      ///< [OUT] call id
+{
+    static struct ubus_request req;
+    struct ql_call_ubus_t *voice_call_ubus = (struct ql_call_ubus_t *)h_voice;
+    static struct blob_buf b;
+    int id, ret;
+	RIL_Dial dial_data;
+
+    if(h_voice == NULL || ql_call_ubus == NULL)
+    {
+        printf("ARG error or not inited.");
+        return -1;
+    }
+    if(voice_call_ubus->call_state.calls[0].state == E_QL_MCM_VOICE_CALL_STATE_ACTIVE ||
+       voice_call_ubus->call_state.calls[0].state == E_QL_MCM_VOICE_CALL_STATE_INCOMING ||
+       voice_call_ubus->call_state.calls[0].state == E_QL_MCM_VOICE_CALL_STATE_ALERTING)
+    {
+        printf("A call already exists, Voice Call incoming or active!!\n");
+        return -1;
+    }
+    memset(&dial_data, 0, sizeof(RIL_Dial));
+    dial_data.address = phone_number;
+    printf("call number %s\n", dial_data.address);
+    if (ubus_lookup_id(ql_call_ubus->ctx, "ril", &ql_call_ubus->ril_request_id)) {
+    	fprintf(stderr, "%s, Failed to look up test object\n", __FUNCTION__);
+    	return -1;
+    }
+    rilutil_makeRequestBlob(&b, RIL_REQUEST_DIAL, &dial_data, 0);
+    ret = ubus_invoke(voice_call_ubus->ctx, voice_call_ubus->ril_request_id, "ril_request", b.head, ql_call_requset_cb, 0,0);
+    if(ret != 0)
+    {
+        printf("sim_get_imsi,ubus_invoke Failed %s\n", ubus_strerror(ret));
+        return E_QL_ERROR_GENERIC;
+    }
+
+    return 0;
+}
+
+/* End call of call_id, which returned by QL_Voice_Call_Start or callback func register via QL_Voice_Call_AddStateHandler */
+int QL_Voice_Call_End(voice_client_handle_type    h_voice,
+                      int                         call_id)        ///< [IN] call id, return by QL_Voice_Start
+{
+    static struct ubus_request req;
+    static struct blob_buf b;
+    int ret;
+    struct ql_call_ubus_t *voice_call_ubus = (struct ql_call_ubus_t *)h_voice;
+
+    if(h_voice == NULL || ql_call_ubus == NULL)
+    {
+        printf("ARG error or not inited.");
+        return -1;
+    }
+    mbtk_call_log("Voice Call State:%s, %d\n", voice_call_ubus->call_state.calls[0].number, voice_call_ubus->call_state.calls[0].state);
+    if(voice_call_ubus->call_state.calls[0].state != E_QL_MCM_VOICE_CALL_STATE_ACTIVE &&
+       voice_call_ubus->call_state.calls[0].state != E_QL_MCM_VOICE_CALL_STATE_INCOMING &&
+       voice_call_ubus->call_state.calls[0].state != E_QL_MCM_VOICE_CALL_STATE_ALERTING)
+    {
+        printf("No Voice Call incoming or active!!\n");
+        return -1;
+    }
+    //use rilutil's API, just a example
+    rilutil_makeRequestBlob(&b, RIL_REQUEST_RELEASE_CALL, NULL, 0);
+    ret = ubus_invoke(voice_call_ubus->ctx, voice_call_ubus->ril_request_id, "ril_request", b.head, ql_call_requset_cb, 0,0);
+    if(ret != 0)
+    {
+        printf("sim_get_imsi,ubus_invoke Failed %s", ubus_strerror(ret));
+        return E_QL_ERROR_GENERIC;
+    }
+    return 0;
+}
+
+/* Answer the call of call_id, which returned by callback func register via QL_Voice_Call_AddStateHandler */
+int QL_Voice_Call_Answer(voice_client_handle_type    h_voice,
+                         int                         call_id )
+{
+    static struct ubus_request req;
+    static struct blob_buf b;
+    struct ql_call_ubus_t *voice_call_ubus = (struct ql_call_ubus_t *)h_voice;
+    int ret;
+
+    if(h_voice == NULL || ql_call_ubus == NULL)
+    {
+        printf("ARG error or not inited.");
+        return -1;
+    }
+    rilutil_makeRequestBlob(&b, RIL_REQUEST_ANSWER, NULL, 0);
+    ret = ubus_invoke(voice_call_ubus->ctx, voice_call_ubus->ril_request_id, "ril_request", b.head, ql_call_requset_cb, 0,0);
+    if(ret != 0)
+    {
+        printf("ql call, ubus_invoke Failed %s", ubus_strerror(ret));
+        return E_QL_ERROR_GENERIC;
+    }
+    return 0;
+}
+
+int QL_Voice_Call_Hold( voice_client_handle_type    h_voice)
+{
+    static struct ubus_request req;
+    struct ql_call_ubus_t *voice_call_ubus = (struct ql_call_ubus_t *)h_voice;
+    static struct blob_buf b;
+    int ret;
+
+    if(h_voice == NULL || ql_call_ubus == NULL)
+    {
+        printf("ARG error or not inited.");
+        return -1;
+    }
+    rilutil_makeRequestBlob(&b, RIL_REQUEST_HANGUP, NULL, 0);
+    ret = ubus_invoke(voice_call_ubus->ctx, voice_call_ubus->ril_request_id, "ril_request", b.head, ql_call_requset_cb, 0,0);
+    if(ret != 0)
+    {
+        printf("ql call, ubus_invoke Failed %s", ubus_strerror(ret));
+        return E_QL_ERROR_GENERIC;
+    }
+    return 0;
+}
+
+int QL_Voice_Call_UnHold( voice_client_handle_type h_voice)
+{
+
+    return 0;
+}
+
+int QL_Voice_Call_Conference( voice_client_handle_type h_voice)
+{
+    static struct ubus_request req;
+    struct ql_call_ubus_t *voice_call_ubus = (struct ql_call_ubus_t *)h_voice;
+    static struct blob_buf b;
+    int ret;
+
+    if(h_voice == NULL || ql_call_ubus == NULL)
+    {
+        printf("ARG error or not inited.");
+        return -1;
+    }
+    rilutil_makeRequestBlob(&b, RIL_REQUEST_CONFERENCE, NULL, 0);
+    ret = ubus_invoke(voice_call_ubus->ctx, voice_call_ubus->ril_request_id, "ril_request", b.head, ql_call_requset_cb, 0,0);
+    if(ret != 0)
+    {
+        printf("ql call, ubus_invoke Failed %s", ubus_strerror(ret));
+        return E_QL_ERROR_GENERIC;
+    }
+    return 0;
+}
+
+int QL_Voice_Call_EndConference( voice_client_handle_type   h_voice)
+{
+
+    return 0;
+}
+
+int QL_Voice_Call_Ecall(voice_client_handle_type    h_voice,
+                        E_QL_VCALL_ID_T             simId,
+                        char*                       phone_number,
+                        ql_mcm_ecall_info           ecall_info,
+                        int                         *call_id)
+{
+// RIL_REQUEST_SET_CECALL
+// RIL_REQUEST_GET_CECALL
+//         RIL_REQUEST_SET_ECALLONLY
+//         RIL_REQUEST_GET_ECALLONLY
+//         RIL_REQUEST_SET_ECALLREG
+    static struct ubus_request req;
+    struct ql_call_ubus_t *voice_call_ubus = (struct ql_call_ubus_t *)h_voice;
+    static struct blob_buf b;
+    int ret;
+
+    if(h_voice == NULL || ql_call_ubus == NULL)
+    {
+        printf("ARG error or not inited.");
+        return -1;
+    }
+    //use rilutil's API, just a example
+    rilutil_makeRequestBlob(&b, RIL_REQUEST_CONFERENCE, NULL, 0);
+    ret = ubus_invoke(voice_call_ubus->ctx, voice_call_ubus->ril_request_id, "ril_request", b.head, ql_call_requset_cb, 0,0);
+    if(ret != 0)
+    {
+        printf("ql call, ubus_invoke Failed %s", ubus_strerror(ret));
+        return E_QL_ERROR_GENERIC;
+    }
+    return 0;
+}
+
+
+int QL_Voice_Call_SetAutoAnswer(voice_client_handle_type        h_voice,
+                                E_QL_MCM_VOICE_AUTO_ANSWER_T    eAnswerType,
+                                uint32_t                        uAnswerTime)
+{
+    struct ql_call_ubus_t *voice_call_ubus = (struct ql_call_ubus_t *)h_voice;
+
+    if(h_voice == NULL || ql_call_ubus == NULL)
+    {
+        printf("ARG error or not inited.");
+        return -1;
+    }
+    voice_call_ubus->auto_answer = eAnswerType;
+    voice_call_ubus->answer_time = uAnswerTime;
+
+    return 0;
+}
+
+int QL_Voice_Call_Ecall_HangUp(voice_client_handle_type h_voice)
+{
+    return 0;
+}
+
+int QL_Voice_Call_Ecall_UpdateMsd(voice_client_handle_type    h_voice,const char *msd,uint32_t   msd_len)
+{
+    return 0;
+}
+
+//Ecall Push caommand
+int QL_Voice_Call_Ecall_MsdPush(voice_client_handle_type h_voice,
+                                        E_QL_MCM_ECALL_STATE_T *ecall_state)
+{
+    return 0;
+}
+
+//Get Ecall config info
+int QL_Voice_Call_Ecall_GetConfigInfo(voice_client_handle_type h_voice,
+                                        ql_mcm_ecall_config_info *ecall_config)
+{
+//         RIL_REQUEST_SET_ECALLCFG
+//         RIL_REQUEST_GET_ECALLCFG
+    return 0;
+}
+
+int QL_Voice_Call_Ecall_SetConfigInfo(voice_client_handle_type h_voice,
+                                        E_QL_MCM_ECALL_CONFIG_T ecall_config_type,
+                                        uint8_t value)
+{
+    return 0;
+}
+
+//Cancel dial
+int QL_Voice_Call_CancelDial( voice_client_handle_type   h_voice)
+{
+    static struct ubus_request req;
+    static struct blob_buf b;
+    int ret;
+    struct ql_call_ubus_t *voice_call_ubus = (struct ql_call_ubus_t *)h_voice;
+
+    if(h_voice == NULL || ql_call_ubus == NULL)
+    {
+        printf("ARG error or not inited.");
+        return -1;
+    }
+    //use rilutil's API, just a example
+    rilutil_makeRequestBlob(&b, RIL_REQUEST_RELEASE_CALL, NULL, 0);
+    ret = ubus_invoke(voice_call_ubus->ctx, voice_call_ubus->ril_request_id, "ril_request", b.head, ql_call_requset_cb, 0,0);
+    if(ret != 0)
+    {
+        printf("sim_get_imsi,ubus_invoke Failed %s", ubus_strerror(ret));
+        return E_QL_ERROR_GENERIC;
+    }
+    return 0;
+}
+
+//VTS API
+int QL_Voice_Call_Dtmf(voice_client_handle_type h_voice, uint8_t digit, int call_id)
+{
+    static struct ubus_request req;
+    struct ql_call_ubus_t *voice_call_ubus = (struct ql_call_ubus_t *)h_voice;
+    static struct blob_buf b;
+    int ret;
+    char code = digit;
+
+    if(h_voice == NULL || ql_call_ubus == NULL)
+    {
+        printf("ARG error or not inited.");
+        return -1;
+    }
+    rilutil_makeRequestBlob(&b, RIL_REQUEST_DTMF, &code, 0);
+    ret = ubus_invoke(voice_call_ubus->ctx, voice_call_ubus->ril_request_id, "ril_request", b.head, ql_call_requset_cb, 0,0);
+    if(ret != 0)
+    {
+        printf("ql call, ubus_invoke Failed %s", ubus_strerror(ret));
+        return E_QL_ERROR_GENERIC;
+    }
+    return 0;
+}
+
+int QL_Voice_Call_GetCallStatus
+(
+    int                         h_voice,
+    int                         call_id, // If call_id<0, means to get all calls state, or get specified call_id info
+    ql_mcm_voice_calls_state_t  *pt_callstate
+)
+{
+    struct ql_call_ubus_t *voice_call_ubus = (struct ql_call_ubus_t *)h_voice;
+
+    if(h_voice == NULL || ql_call_ubus == NULL)
+    {
+        printf("ARG error or not inited.");
+        return -1;
+    }
+    memcpy((void *)pt_callstate, &voice_call_ubus->call_state, sizeof(ql_mcm_voice_calls_state_t));
+    return 0;
+}
+
+//Set forwarding
+int QL_Voice_Call_SetForwarding
+(
+    int                             h_voice,
+    E_QL_MCM_VOICE_CALL_SERVICE_T   service,
+    E_QL_MCM_VOICE_CALL_FORWARDING_REASON_T  reason,
+    char *number
+)
+{
+
+    return 0;
+}
+
+//Get forwarding status
+int QL_Voice_Call_GetForwardingStatus(
+        int                             h_voice,
+        E_QL_MCM_VOICE_CALL_FORWARDING_REASON_T  reason,
+        ql_mcm_voice_call_forwarding_status_list_t *pt_status)
+{
+
+    return 0;
+}
+
+
+//Set voice call waiting
+int QL_Voice_Call_SetWaiting
+(
+    int                                 h_voice,
+    ql_mcm_voice_call_waiting_service_t e_service
+)
+{
+// RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND
+    return 0;
+}
+
+//Get voice call waiting status
+int QL_Voice_Call_GetWaitingStatus
+(
+    int                                 h_voice,
+    ql_mcm_voice_call_waiting_service_t *pe_service
+)
+{
+
+    return 0;
+}
diff --git a/mbtk/libql_lib_v2/src/ql_cell_locator.c b/mbtk/libql_lib_v2/src/ql_cell_locator.c
new file mode 100755
index 0000000..b36075d
--- /dev/null
+++ b/mbtk/libql_lib_v2/src/ql_cell_locator.c
@@ -0,0 +1,347 @@
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#define LOG_TAG "mbtk_http"
+#include "mbtk_type.h"
+#include "mbtk_http.h"
+#include "mbtk_log.h"
+#include "mbtk_info_api.h"
+#include "ql/ql_cell_locator.h"
+
+
+static int http_handle;
+static int http_session;
+
+static char Server[128]={0};
+static char Token[128] = {0};
+static char Loction[128]={0};
+static int PORT = 0;
+static int locator_timeout = 60;  // 60s for default.
+
+static int mbtk_lbs_http_parse_location(char* buf, int len, char* rspBuf)
+{
+    if(buf != NULL && len != 0)
+    {
+        char* pos0 = NULL;
+        char* pos1 = NULL;
+        char fac[64] = {'\0'};
+        pos0 = strstr(buf, "<info>");
+        if(pos0 != NULL)
+        {
+            pos1 = strstr(pos0 + 1, "</info>");
+            if(pos1 != NULL)
+            {
+                strncpy(fac, pos0 + 6, pos1 - pos0 - 6);
+            }
+            if(strcmp(fac, "OK") == 0)
+            {
+                char* l_pos0 = NULL;
+                char* l_pos1 = NULL;
+                char* type_pos0 = NULL;
+                char* type_pos1 = NULL;
+                char fac_type[64] = {'\0'};
+                type_pos0 = strstr(buf, "<type>");
+                if(type_pos0 != NULL)
+                {
+                    type_pos1 = strstr(type_pos0 + 1, "</type>");
+                    if(type_pos1 != NULL)
+                    {
+                        strncpy(fac_type, type_pos0 + 6, type_pos1 - type_pos0 - 6);
+                        if(strcmp(fac_type, "0") == 0)
+                        {
+                            return -1;
+                        }
+                    }
+                }
+                l_pos0 = strstr(buf, "<location>");
+                if(l_pos0 != NULL)
+                {
+                   l_pos1 = strstr(l_pos0 + 1, "</location>");
+                    if(l_pos1 != NULL)
+                    {
+                        strncpy(rspBuf, l_pos0 + 10, l_pos1 - l_pos0 - 10);
+                    }
+                    return 0;
+                }
+            }
+            else //key error http chunk
+            {
+                printf("info is %s", fac);
+            }
+        }
+    }
+    return -1;
+}
+
+
+
+static void http_data_cb_func1(
+    int session_id, mbtk_http_data_type_enum type,
+    void *data,int data_len)
+{
+    if(type == MBTK_HTTP_DATA_HEADER) {
+        LOGE("Header(%d):%s\n",data_len,(char*)data);
+    } else if(type == MBTK_HTTP_DATA_CONTENT) {
+        LOGE("Data(%d):%s\n",data_len,(char*)data);
+		mbtk_lbs_http_parse_location((char*)data, data_len, Loction);
+    } else {
+        LOGI(">>>>>Complete<<<<<\n");
+    }
+}
+
+
+int ql_cell_locator_init()
+{
+    http_handle = mbtk_http_handle_get(TRUE, http_data_cb_func1);
+    if(http_handle < 0)
+    {
+        LOGE("mbtk_http_handle_get() fail.");
+        return -1;
+    }
+
+	http_session = mbtk_http_session_create(http_handle,HTTP_OPTION_GET,HTTP_VERSION_1_1);
+    if(http_session < 0)
+    {
+        LOGE("mbtk_http_session_create() fail.");
+        return -1;
+    }
+
+	return 0;
+}
+
+
+int ql_cell_locator_release()
+{
+    if(mbtk_http_handle_free(http_handle))
+    {
+        LOGE("mbtk_http_handle_free() fail.");
+        return -1;
+    }
+
+	return 0;
+}
+
+/*-----------------------------------------------------------------------------------------------*/
+/**
+  @brief set locator query server and port, server length must be less than 255 bytes.
+  @param[in] server the query server ip address
+  @param[in] port the query server port
+  @return if success return 0, else return -1
+  */
+/*-----------------------------------------------------------------------------------------------*/
+int ql_cell_locator_set_server(const char *server, unsigned short port)
+{
+	if(server == NULL)
+	{
+		return -1;
+	}
+
+	memset(Server, 0, sizeof(Server));
+	memcpy(Server, server, strlen(server));
+	PORT = port;
+
+	return 0;
+}
+
+/*-----------------------------------------------------------------------------------------------*/
+/**
+  @brief set locator query timeout, the value must between 1-300 [seconds]
+  @param[in] timeout value of query timeout
+  @return if success return 0, else return -1
+  */
+/*-----------------------------------------------------------------------------------------------*/
+int ql_cell_locator_set_timeout(unsigned short timeout)
+{
+    locator_timeout = timeout;
+	return 0;
+}
+
+
+/*-----------------------------------------------------------------------------------------------*/
+/**
+  @brief set locator query token, token length must be 16 bytes. the token Used to verify that
+         the client accessing the service is valid.
+  @param[in] token string of token which want to be setted.
+  @param[in] length of token string.
+  @return if success return 0, else return -1
+  */
+/*-----------------------------------------------------------------------------------------------*/
+int ql_cell_locator_set_token(const char *token, int len)
+{
+	if(token == NULL && (strlen(token) != len) && len > 128)
+	{
+		return -1;
+	}
+
+	memset(Token, 0, sizeof(token));
+	memcpy(Token, token, strlen(token));
+
+	return 0;
+}
+
+/*-----------------------------------------------------------------------------------------------*/
+/**
+  @brief perform cell locator query
+  @param[out] resp include query result or set the error_msg and error_code
+  @return if success return 0, else return -1
+  */
+/*-----------------------------------------------------------------------------------------------*/
+int ql_cell_locator_perform(ql_cell_resp *resp)
+{
+
+    int ret = 0;
+    int ret1 = 0;
+
+    char url[1024] = {0};
+    char imei[50] ={0};
+    char cellinfo[512] = {0};
+    char *p = cellinfo;
+    	int i =0;
+    int mcc,mnc,tac,ci,rsrp;
+
+    mbtk_info_handle_t* info_handle = mbtk_info_handle_get();
+    if(!info_handle)
+    {
+        return -1;
+    }
+
+    mbtk_imei_get(info_handle, imei);
+
+    list_node_t* cell_list = NULL;
+    int type, err;
+    int CellId;
+    err = mbtk_cell_get(info_handle, &type, &cell_list);
+    if(err || cell_list == NULL) {
+        printf("Error : %d\n", err);
+    }
+    else
+    {
+        list_first(cell_list);
+        mbtk_cell_info_t* cell = (mbtk_cell_info_t*) list_next(cell_list);
+        if(cell)
+        { // Current server cell.
+            switch(type)
+            {
+                case 0:
+                    LOGE("GSM : mcc=%d, mnc=%d, lac=%d, ci=%d, arfcn=%d, bsic=%d\n",cell->value5, cell->value6,cell->value1, cell->value2, cell->value3, cell->value4);
+                    mcc = cell->value5;
+                    mnc = cell->value6;
+                    tac = cell->value1;
+                    ci = cell->value2;
+                    rsrp = 30;
+                    break;
+                case 1:
+                    LOGE("UMTS : lac=%d, ci=%d, arfcn=%d\n", cell->value1, cell->value2, cell->value3);
+                    break;
+                case 2:
+                    LOGE("LTE : tac=%d, PCI=%d, dlEuarfcn=%d, ulEuarfcn=%d, band=%d, mcc=%d, mnc=%d ,cid=%d, rsrp=%d\n",
+                    cell->value1, cell->value2, cell->value3, cell->value4, cell->value5,cell->value6, cell->value7, cell->value8,cell->value9);
+//// LTE server cell: tac, PCI, dlEuarfcn, ulEuarfcn, band, mcc, mnc ,cid, rsrp
+                    mcc = cell->value6;
+                    mnc = cell->value7;
+                    tac = cell->value1;
+                    ci = cell->value10;
+                    rsrp = cell->value9;
+
+                    //	LOGE(cellinfo,"&bts=%X,%X,%d,%d,%d&nearbts=",mcc,mnc,tac,ci,rsrp-140);
+                    //	LOGE("cellinfo:%s\n", cellinfo);
+
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        sprintf(cellinfo,"&bts=%X,%X,%d,%d,%d&nearbts=",mcc,mnc,tac,ci,rsrp-140);
+        while ((cell = (mbtk_cell_info_t*) list_next(cell_list)))
+        {
+            switch(type)
+            {
+                case 0:
+                    LOGE("CELL : %d, %d, %d, %d, %d", cell->value1, cell->value2, cell->value3, cell->value4, cell->value5);
+                    if(i < 3)
+                    {
+                        sprintf(p+strlen(p),"%X,%X,%d,%d,%d|",cell->value5,cell->value6,cell->value1,cell->value2,29-140);
+                        i++;
+                    }
+                    break;
+                case 1:
+                    LOGE("CELL : lac=%d, ci=%d, arfcn=%d\n", cell->value1, cell->value2, cell->value3);
+                    break;
+                case 2:
+                    CellId = cell->value5;
+                //    if(CellId > 0 && cell->value5 != -1)
+                    if(CellId > 0 )
+                    {
+                        if(i < 3)
+                        {
+                            sprintf(p+strlen(p),"%X,%X,%d,%d,%d|",mcc,mnc,tac,cell->value5,cell->value3-140);
+                            i++;
+                        }
+                    }
+                    LOGE("CELL : phyCellId=%d, euArfcn=%d, rsrp=%d, rsrq=%d, cellId:%d\n", cell->value1, cell->value2, cell->value3, cell->value4, cell->value5);
+                    break;
+                default:
+                    break;
+           }
+        }
+    }
+    list_free(cell_list);
+
+    sprintf(url,"http://%s:%d/position?accesstype=0&imei=%s&cdma=0%s&output=xml&key=%s",\
+            Server, PORT, imei,cellinfo, Token);
+
+
+    memset(Loction, 0, sizeof(Loction));
+
+
+    if(mbtk_http_session_url_set(http_handle, http_session, url)) {
+        LOGE("mbtk_http_session_url_set() fail.\n");
+        return -1;
+    }
+
+    const mbtk_http_session_t* session = mbtk_http_session_get(http_handle, http_session);
+    LOGI("HTTP:%d,%s,%d,%s\n",session->option,session->host,session->port,session->uri);
+
+
+    mbtk_http_session_head_add(http_handle, http_session, "Connection", "KeepAlive");
+
+
+    if(mbtk_http_session_start(http_handle, http_session)) {
+        LOGE("mbtk_http_session_start() fail.\n");
+        return -1;
+    }
+
+    if(strlen(Loction))
+    {
+        char Lon[20] ={0};
+        char Lat[20] = {0};
+        char *lon = Loction;
+        char *lat = strstr(Loction, ",");
+        if(lat != NULL )
+        {
+            memcpy(Lon, Loction, lat- lon);
+
+            lat++;
+            memcpy(Lat, lat, strlen(lat));
+
+            sscanf((char*)Lon,"%lf",&resp->lon);
+            sscanf((char*)Lat,"%lf",&resp->lat);
+        }
+
+    }
+
+//    printf("lon:%f, lat:%f\n", resp->lon, resp->lat);
+//	printf("\nloction:%s\n", Loction);
+
+	return 0;
+}
+
+
+
+
+
diff --git a/mbtk/libql_lib_v2/src/ql_common.c b/mbtk/libql_lib_v2/src/ql_common.c
new file mode 100755
index 0000000..70d0ad3
--- /dev/null
+++ b/mbtk/libql_lib_v2/src/ql_common.c
@@ -0,0 +1,21 @@
+#include <stdlib.h>
+#include "ql/ql_common.h"
+
+void Ql_Powerdown(int mode)
+{
+    switch (mode)
+        {
+        case 1:
+            system("halt");
+            break;
+        case 2:
+            system("reboot");
+            break;
+        default:
+            printf("mode error");
+        }
+
+    return ;
+
+}
+
diff --git a/mbtk/libql_lib_v2/src/ql_data_call.c b/mbtk/libql_lib_v2/src/ql_data_call.c
new file mode 100755
index 0000000..218e14b
--- /dev/null
+++ b/mbtk/libql_lib_v2/src/ql_data_call.c
@@ -0,0 +1,658 @@
+#include "ql/DSI_ConnectManager.h"
+#include "mbtk_info_api.h"
+#include <fcntl.h>
+
+extern mbtk_info_handle_t* ql_info_handle;
+extern int ql_info_handle_num;
+static bool inited = FALSE;
+
+typedef struct
+{
+    bool active;
+    uint8 cid;
+    int ip_type;
+    char user[128];
+    char pass[128];
+    QL_DSI_AUTH_PREF_T auth;
+} apn_info;
+
+// 2 - 7
+static apn_info ql_apn_info[9]={0};
+static int mbtk_interval_sec = 0;
+static nw_status_cb ql_net_status_cb = NULL;
+static ex_conn_status_cb ql_net_ex_status_cb = NULL;
+static int now_cid = 0;
+
+void ql_wan_net_state_change_cb(const void* data, int data_len)
+{
+    uint8 *net_data = NULL;
+    net_data = (uint8 *)data;
+
+    if(*net_data > 100 && *net_data < 200)
+    {
+        int cid;
+        cid = *net_data;
+        cid = cid - 100;
+        ql_apn_info[cid].active = FALSE;//close
+        if(ql_net_ex_status_cb != NULL)
+        {
+            ql_net_ex_status_cb(cid, ql_apn_info[cid].ip_type, CONNECT_DISCON, 0);
+        }
+    }
+    else if(*net_data > 200)
+    {
+        int cid;
+        cid = *net_data;
+        cid = cid - 200;
+        ql_apn_info[cid].active = TRUE;//open
+    }
+    else
+    {
+        if(ql_net_status_cb != NULL)
+        {
+            ql_net_status_cb(*net_data);
+
+            if(*net_data == 25 || *net_data == 26 || *net_data == 27)
+            {
+                ql_net_status_cb(CONNECT_CONSUCCESS);
+            }
+        }
+
+        if(ql_net_ex_status_cb != NULL)
+        {
+            if(*net_data == 1)
+            {
+                ql_net_ex_status_cb(now_cid, ql_apn_info[now_cid].ip_type, CONNECT_CONSUCCESS, 0);
+            }
+        }
+    }
+
+}
+
+int ql_wan_init(void)
+{
+    if(!inited && ql_info_handle == NULL)
+    {
+        ql_info_handle = mbtk_info_handle_get();
+        if(ql_info_handle)
+        {
+            ql_info_handle_num++;
+            inited = TRUE;
+            mbtk_pdp_state_change_cb_reg(ql_info_handle, ql_wan_net_state_change_cb);
+
+            //return 0;
+        } else {
+            LOGE("mbtk_info_handle_get() fail.");
+            return -1;
+        }
+    } else {
+        if(!inited) {
+            ql_info_handle_num++;
+            inited = TRUE;
+            mbtk_pdp_state_change_cb_reg(ql_info_handle, ql_wan_net_state_change_cb);
+        }
+        //return 0;
+    }
+
+    mbtk_apn_info_t apns[10] = {0};
+    int apn_num = MBTK_APN_CID_MAX;
+    int ret = mbtk_apn_get(ql_info_handle, &apn_num, apns);
+    if(ret != 0)
+    {
+        LOGD("mbtk_apn_get ret = %d",ret);
+    }
+    else
+    {
+        int i;
+        int profile_idx;
+        for(i=0;i<MBTK_APN_CID_MAX;i++)
+        {
+            if(apns[i].cid > 0 && apns[i].cid <= MBTK_APN_CID_MAX)
+            {
+                profile_idx = apns[i].cid;
+                if(apns[i].ip_type == MBTK_IP_TYPE_IPV4V6) // IPV4V6
+                    ql_apn_info[profile_idx].ip_type = 0;
+                else if(apns[i].ip_type == MBTK_IP_TYPE_IP) // IPV4
+                    ql_apn_info[profile_idx].ip_type = 1;
+                else if(apns[i].ip_type == MBTK_IP_TYPE_IPV6) // IPV6
+                    ql_apn_info[profile_idx].ip_type = 2;
+                else
+                    ql_apn_info[profile_idx].ip_type = 0;
+            }
+        }
+    }
+    return 0;
+}
+
+int ql_wan_release(void)
+{
+    if(ql_info_handle)
+    {
+        LOGD("ql_info_handle_num = %d", ql_info_handle_num);
+        if(ql_info_handle_num == 1) { // 最后一个引用，可释放。
+            int ret = mbtk_info_handle_free(&ql_info_handle);
+            if(ret) {
+                LOGE("mbtk_info_handle_free() fail.");
+                return -1;
+            }
+            else
+            {
+                ql_info_handle_num = 0;
+                ql_info_handle = NULL;
+                return 0;
+            }
+        } else {
+            ql_info_handle_num--;
+            return 0;
+        }
+    }
+    else
+    {
+        LOGE("DATA handle not inited.");
+        return -1;
+    }
+}
+/*
+*Set data call over time.
+*/
+int ql_wan_set_autoconnect(int auto_status, int interval_sec)
+{
+    if(auto_status == 0)                    //不开启失败重连
+        mbtk_interval_sec = 0;
+    else                                    //开启失败重连等待时间
+    {
+        if(interval_sec <= 0)
+            mbtk_interval_sec = interval_sec;
+        else
+            mbtk_interval_sec = 5; // 默认为5s
+    }
+    return 0;
+}
+
+#ifdef MBTK_AF_SUPPORT
+int mbtk_route_config(int profile_idx)
+{
+    char buf[1024] = {0};
+    char dns[128] = {0};
+    int offset = 0;
+    int fd = -1;
+    mbtk_ipv4_info_t ipv4;
+    mbtk_ipv6_info_t ipv6;
+    sprintf(buf, "route add default dev ccinet%d", profile_idx -1);
+    system(buf);
+
+    int ret = mbtk_data_call_state_get(ql_info_handle, profile_idx, &ipv4, &ipv6);
+    if(ret != 0)
+        return -1;
+    else
+    {
+        memset(buf, 0x0, 1024);
+        memset(dns, 0x0, 128);
+        offset = sprintf(buf, "search lan\n");
+        if(ipv4.valid)
+        {
+            if(inet_ntop(AF_INET, &(ipv4.PrimaryDNS), dns, 32) == NULL) {
+                LOGD("PrimaryDNS error.");
+            } else {
+                LOGD("PrimaryDNS : %s", dns);
+            }
+            offset += sprintf(buf + offset, "nameserver %s\n", dns);
+            memset(dns, 0x0, 128);
+            if(inet_ntop(AF_INET, &(ipv4.SecondaryDNS), dns, 32) == NULL) {
+                LOGD("SecondaryDNS error.");
+            } else {
+                LOGD("SecondaryDNS : %s", dns);
+            }
+            offset += sprintf(buf + offset, "nameserver %s\n", dns);
+        }
+        if(ipv6.valid)
+        {
+            memset(dns, 0x0, 128);
+			if(ipv6_2_str(&(ipv6.PrimaryDNS), dns))
+            {
+				LOGD("PrimaryDNS error.");
+			} else {
+				LOGD("PrimaryDNS : %s", dns);
+			}
+            offset += sprintf(buf + offset, "nameserver %s\n", dns);
+            memset(dns, 0x0, 128);
+			if(ipv6_2_str(&(ipv6.SecondaryDNS), dns))
+            {
+				LOGD("SecondaryDNS error.");
+			} else {
+				LOGD("SecondaryDNS : %s", dns);
+			}
+            offset += sprintf(buf + offset, "nameserver %s\n", dns);
+        }
+
+        if(offset > 0)
+        {
+            fd = open("/tmp/resolv.conf", O_WRONLY | O_TRUNC);
+            if(fd < 0)
+            {
+                LOGD("mbtk_route_config : open fail.");
+                return -1;
+            }
+
+            ret = write(fd, buf, offset);
+            if(ret < 0)
+            {
+                LOGD("mbtk_route_config : write fail.");
+            }
+
+            close(fd);
+        }
+    }
+
+    return 0;
+}
+#endif
+
+int ql_wan_start_ex(int profile_idx, int op, ex_conn_status_cb nw_cb)
+{
+    int ret = -1;
+    int count = 0;
+    if(ql_info_handle == NULL)
+    {
+        return -1;
+    }
+
+    ql_net_ex_status_cb = nw_cb;
+    ql_net_status_cb = NULL;
+    now_cid = profile_idx;
+    if(profile_idx < MBTK_APN_CID_MIN || profile_idx > MBTK_APN_CID_MAX)
+    {
+        LOGD("ql_wan_start_ex() cid out of range.");
+#if 0
+        if(ql_net_ex_status_cb)
+            ql_net_ex_status_cb(profile_idx, ql_apn_info[profile_idx].ip_type ,PDP_CID_EXIST_FAIL, 0);
+#endif
+        return -1;
+    }
+
+    //ql_netw_status_cb(ql_apn_info[profile_idx].cid);
+    if(op == 0)
+    {
+        ret = ql_wan_stop(profile_idx);
+        goto exit;
+    }
+
+#if 0
+    if(ql_apn_info[profile_idx].active)
+    {
+        if(ql_net_ex_status_cb)
+            ql_net_ex_status_cb(profile_idx, ql_apn_info[profile_idx].ip_type, PDP_CID_EXIST_FAIL, 0);
+        return -1;
+    }
+#endif
+
+    if(ql_net_ex_status_cb) {
+        ql_net_ex_status_cb(profile_idx, ql_apn_info[profile_idx].ip_type, CONNECT_DIAL_IMMEDIATELY, 0);
+        ql_net_ex_status_cb(profile_idx, ql_apn_info[profile_idx].ip_type, CONNECT_CONNING, 0);
+    }
+    
+data_call_continue:
+    ret = mbtk_data_call_start(ql_info_handle, profile_idx, 0, op == 3 ? TRUE : FALSE, 0);
+    if(ret != 0)
+    {
+        if(mbtk_interval_sec <= 0)
+        {
+            if(ql_net_ex_status_cb)
+                ql_net_ex_status_cb(profile_idx, ql_apn_info[profile_idx].ip_type, CONNECT_DISCON, 0);
+            return ret;
+        }
+        else
+        {
+            if(count >= 5)
+                goto exit;
+            sleep(mbtk_interval_sec);
+            count++;
+            if(ql_net_ex_status_cb)
+                ql_net_ex_status_cb(profile_idx, ql_apn_info[profile_idx].ip_type, CONNECT_REDIAL, 0);
+            goto data_call_continue;
+        }
+        LOGD("mbtk_data_call_start() fail.");
+    }
+    else
+    {
+        //ql_apn_info[8].cid=profile_idx;
+        //ql_netw_status_cb(CONNECT_CONSUCCESS);
+#ifdef MBTK_AF_SUPPORT
+        if(profile_idx == 1)
+        {
+            mbtk_route_config(profile_idx);
+            
+        }
+#endif
+        LOGD("mbtk_data_call_start() success.");
+    }
+exit:
+    return ret;
+}
+
+
+/*
+* Start data call.
+*/
+int ql_wan_start(int profile_idx, int op, nw_status_cb nw_cb)
+{
+    int ret = -1;
+    int count = 0;
+    if(ql_info_handle == NULL)
+    {
+        return -1;
+    }
+
+    ql_net_status_cb = nw_cb;
+    ql_net_ex_status_cb = NULL;
+    if(profile_idx < MBTK_APN_CID_MIN || profile_idx > MBTK_APN_CID_MAX)
+    {
+        ql_net_status_cb(PDP_ERROR_UNSPECIFIED);
+        return -1;
+    }
+
+    //ql_netw_status_cb(ql_apn_info[profile_idx].cid);
+    if(op == 0)
+    {
+        ret = ql_wan_stop(profile_idx);
+        goto exit;
+    }
+
+    if(ql_apn_info[profile_idx].active)
+    {
+        ql_net_status_cb(PDP_CID_EXIST_FAIL);
+        return -1;
+    }
+
+    ql_net_status_cb(CONNECT_DIAL_IMMEDIATELY);
+    ql_net_status_cb(CONNECT_CONNING);
+data_call_continue:
+    ret = mbtk_data_call_start(ql_info_handle, profile_idx, 0, op == 3 ? TRUE : FALSE, 0);
+    if(ret != 0)
+    {
+        if(mbtk_interval_sec <= 0)
+        {
+            ql_net_status_cb(CONNECT_DISCON);
+            return ret;
+        }
+        else
+        {
+            if(count >= 5)
+                goto exit;
+            sleep(mbtk_interval_sec);
+            count++;
+            ql_net_status_cb(CONNECT_REDIAL);
+            goto data_call_continue;
+        }
+    }
+    else
+    {
+        //ql_apn_info[8].cid=profile_idx;
+        //ql_netw_status_cb(CONNECT_CONSUCCESS);
+        LOGD("mbtk_data_call_start() success.");
+    }
+exit:
+    return ret;
+}
+
+/*
+* Stop data call.
+*/
+int ql_wan_stop(int profile_idx)
+{
+    int err;
+    if(ql_info_handle == NULL)
+    {
+        return -1;
+    }
+    if(profile_idx < MBTK_APN_CID_MIN || profile_idx > MBTK_APN_CID_MAX)
+    {
+        LOGE("CID error.");
+        return -1;
+    }
+
+#if 0 //mbtk wyq for data_call add "if 0"
+    if(!ql_apn_info[profile_idx].active)
+    {
+        if(ql_net_ex_status_cb)
+            ql_net_ex_status_cb(profile_idx, ql_apn_info[profile_idx].ip_type ,PDP_CID_EXIST_FAIL, 0);
+        if(ql_net_status_cb)
+            ql_net_status_cb(PDP_CID_EXIST_FAIL);
+        return -1;
+    }
+#endif
+    err = mbtk_data_call_stop(ql_info_handle, profile_idx, 15);
+
+    return err;
+}
+
+/*
+* Query data call state.
+*/
+int ql_get_data_call_info(int profile_idx, ql_data_call_info *info)
+{
+    if(ql_info_handle == NULL || info == NULL)
+    {
+        return -1;
+    }
+    if(profile_idx < MBTK_APN_CID_MIN || profile_idx > MBTK_APN_CID_MAX)
+    {
+        LOGE("CID error.");
+        return -1;
+    }
+    mbtk_ipv4_info_t ipv4;
+    mbtk_ipv6_info_t ipv6;
+    memset(info, 0, sizeof(ql_data_call_info));
+    int ret = mbtk_data_call_state_get(ql_info_handle, profile_idx, &ipv4, &ipv6);
+    if(ret != 0)
+        return -1;
+    else
+    {
+        info->profile_idx = profile_idx;
+        if(ipv4.valid)
+        {
+            info->ip_type = 1; // IPV4
+            info->v4.state = 1;
+            sprintf(info->v4.addr.name, "ccinet%d", profile_idx - 1);
+            if(inet_ntop(AF_INET, &(ipv4.IPAddr), info->v4.addr.ip, 32) == NULL) {
+                LOGD("IP error.");
+            } else {
+                LOGD("IP : %s", info->v4.addr.ip);
+            }
+            if(inet_ntop(AF_INET, &(ipv4.PrimaryDNS), info->v4.addr.pri_dns, 32) == NULL) {
+                LOGD("PrimaryDNS error.");
+            } else {
+                LOGD("PrimaryDNS : %s", info->v4.addr.pri_dns);
+            }
+            if(inet_ntop(AF_INET, &(ipv4.SecondaryDNS), info->v4.addr.sec_dns, 32) == NULL) {
+                LOGD("SecondaryDNS error.");
+            } else {
+                LOGD("SecondaryDNS : %s", info->v4.addr.sec_dns);
+            }
+        }
+        if(ipv6.valid)
+        {
+            info->ip_type = 2; // IPV6
+            info->v6.state = 1;
+            sprintf(info->v6.addr.name, "ccinet%d", profile_idx - 1);
+			if(ipv6_2_str(&(ipv6.IPV6Addr), info->v6.addr.ip))
+            {
+				LOGD("IP error.");
+			} else {
+				LOGD("IP : %s", info->v6.addr.ip);
+			}
+			if(ipv6_2_str(&(ipv6.PrimaryDNS), info->v6.addr.pri_dns))
+            {
+				LOGD("PrimaryDNS error.");
+			} else {
+				LOGD("PrimaryDNS : %s", info->v6.addr.pri_dns);
+			}
+			if(ipv6_2_str(&(ipv6.SecondaryDNS), info->v6.addr.sec_dns))
+            {
+				LOGD("SecondaryDNS error.");
+			} else {
+				LOGD("SecondaryDNS : %s", info->v6.addr.sec_dns);
+			}
+        }
+        if(ipv4.valid && ipv6.valid)
+            info->ip_type = 0; // IPV4V6
+        if(!ipv4.valid && !ipv6.valid)
+        {
+            info->v4.state = 0;
+            info->v6.state = 0;
+        }
+        return 0;
+    }
+
+}
+
+/*
+* Set specific APN informations.
+*
+* cid : 2-7
+*/
+int ql_wan_setapn(int profile_idx, int ip_type, const char *apn, const char *userName,
+                            const char *password, QL_DSI_AUTH_PREF_T auth)
+{
+    if(ql_info_handle == NULL)
+    {
+        return -1;
+    }
+    if(profile_idx < MBTK_APN_CID_MIN || profile_idx > MBTK_APN_CID_MAX)
+    {
+        LOGE("CID error.");
+        return -1;
+    }
+    /*
+     QL_DSI_AUTH_PREF_NULL = 0,         //无认证
+     QL_DSI_AUTH_PREF_ONLY_PAP,         //PAP 认证
+     QL_DSI_AUTH_PREF_ONLY_CHAP,        //CHAP 认证
+     QL_DSI_AUTH_PREF_BOTH_PAP_CHAP     //PAP 和 CHAP 认证
+    */
+    char mbtk_auth[64]={0};
+    if(auth == QL_DSI_AUTH_PREF_NULL)
+        memcpy(mbtk_auth,"NONE",strlen("NONE")+1);
+    else if(auth == QL_DSI_AUTH_PREF_ONLY_PAP)
+        memcpy(mbtk_auth,"PAP",strlen("PAP")+1);
+    else if(auth == QL_DSI_AUTH_PREF_ONLY_CHAP)
+        memcpy(mbtk_auth,"CHAP",strlen("CHAP")+1);
+    else
+    {
+        LOGD("auth input error!");
+        return -1;
+    }
+
+    memset(&(ql_apn_info[profile_idx]), 0, sizeof(apn_info));
+    ql_apn_info[profile_idx].cid = profile_idx;
+    ql_apn_info[profile_idx].ip_type = ip_type;
+    if(!str_empty(userName) && !str_empty(password)) {
+        memcpy(ql_apn_info[profile_idx].user, userName, strlen(userName));
+        memcpy(ql_apn_info[profile_idx].pass, password, strlen(password));
+        ql_apn_info[profile_idx].auth = auth;
+        LOGD("ql_wan_setapn: %d, %d, %s, %s, %s, %s",profile_idx, ip_type, apn, userName, password, mbtk_auth);
+    } else {
+        LOGD("ql_wan_setapn: %d, %d, %s, NULL, NULL, %s",profile_idx, ip_type, apn, mbtk_auth);
+    }
+
+     /*
+    if(ip_type < 0 || ip_type > 3)
+        ql_netw_status_cb(PDP_UNKNOWN_PDP_ADDRESS_TYPE);
+    */
+    if(ip_type == 0) // IPV4V6
+        ip_type = MBTK_IP_TYPE_IPV4V6;
+    else if(ip_type == 1) // IPV4
+        ip_type = MBTK_IP_TYPE_IP;
+    else if(ip_type == 2) // IPV6
+        ip_type = MBTK_IP_TYPE_IPV6;
+
+    return mbtk_apn_set(ql_info_handle, profile_idx, ip_type, apn, userName, password, mbtk_auth);
+}
+
+/*
+* Get current all APN informations.
+*/
+int __ql_wan_getapn(int profile_idx, int *ip_type, char *apn, int apnLen, char *userName, int userLen, char *password, int pwdLen,int* auth)
+{
+    if(ql_info_handle == NULL || apn == NULL)
+    {
+        return -1;
+    }
+    if(profile_idx < MBTK_APN_CID_MIN || profile_idx > MBTK_APN_CID_MAX)
+    {
+        LOGE("CID error.");
+        return -1;
+    }
+    mbtk_apn_info_t apns[10];
+    int apn_num = MBTK_APN_CID_MAX;
+    int ret = mbtk_apn_get(ql_info_handle, &apn_num, apns);
+    if(ret != 0)
+    {
+        LOGD("mbtk_apn_get ret = %d",ret);
+        return -1;
+    }
+    else
+    {
+        int i;
+        for(i=0;i<MBTK_APN_CID_MAX;i++)
+        {
+            if(apns[i].cid == profile_idx)
+                break;
+        }
+        if(i == MBTK_APN_CID_MAX)
+            return -1;
+        LOGD("cid = %d",i);
+        if(apns[i].ip_type == MBTK_IP_TYPE_IPV4V6) // IPV4V6
+            *ip_type = 0;
+        else if(apns[i].ip_type == MBTK_IP_TYPE_IP) // IPV4
+            *ip_type = 1;
+        else if(apns[i].ip_type == MBTK_IP_TYPE_IPV6) // IPV6
+            *ip_type = 2;
+        else
+            *ip_type = 0;
+
+        if(strlen(apns[i].apn)+1 > apnLen)
+            return -1;
+        else
+            memcpy(apn, apns[i].apn,strlen(apns[i].apn)+1);
+
+        if(strlen(apns[i].user)+1 > userLen)
+            return -1;
+        else
+        {
+            if(strlen(apns[i].user) > 0)
+                memcpy(userName, apns[i].user, strlen(apns[i].user)+1);
+            else
+                memcpy(userName, ql_apn_info[profile_idx].user, strlen(ql_apn_info[profile_idx].user)+1);
+        }
+
+        if(strlen(apns[i].pass)+1 > pwdLen)
+            return -1;
+        else
+        {
+            if(strlen(apns[i].pass) > 0)
+                memcpy(password, apns[i].pass, strlen(apns[i].pass)+1);
+            else
+                memcpy(password, ql_apn_info[profile_idx].pass, strlen(ql_apn_info[profile_idx].pass)+1);
+        }
+
+        if(strlen(apns[i].auth) > 0) {
+            if(strcmp(apns[i].auth, "NONE") == 0)
+                *auth = QL_DSI_AUTH_PREF_NULL;
+            else if(strcmp(apns[i].auth, "PAP") == 0)
+                *auth = QL_DSI_AUTH_PREF_ONLY_PAP;
+            else if(strcmp(apns[i].auth, "CHAP") == 0)
+                *auth = QL_DSI_AUTH_PREF_ONLY_CHAP;
+            else
+            {
+                LOGD("auth error!");
+                return -1;
+            }
+        } else {
+            *auth = ql_apn_info[profile_idx].auth;
+        }
+
+        return 0;
+    }
+}
+
+
diff --git a/mbtk/libql_lib_v2/src/ql_dev_api.c b/mbtk/libql_lib_v2/src/ql_dev_api.c
new file mode 100755
index 0000000..d473ab8
--- /dev/null
+++ b/mbtk/libql_lib_v2/src/ql_dev_api.c
@@ -0,0 +1,179 @@
+//**********************
+#include "ql/ql_dev.h"
+#include "mbtk_type.h"
+#include "mbtk_info_api.h"
+
+//**********************
+
+mbtk_info_handle_t* ql_info_handle = NULL;
+int ql_info_handle_num = 0;
+static bool inited = FALSE;
+
+//**********************
+QL_DEV_ERROR_CODE ql_dev_init()
+{
+    if(!inited && ql_info_handle == NULL)
+    {
+        ql_info_handle = mbtk_info_handle_get();
+        if(ql_info_handle)
+        {
+            ql_info_handle_num++;
+            inited = TRUE;
+            return QL_DEV_SUCCESS;
+        } else {
+            LOGE("mbtk_info_handle_get() fail.");
+            return QL_DEV_GENERIC_FAILURE;
+        }
+    } else {
+        if(!inited) {
+            ql_info_handle_num++;
+            inited = TRUE;
+        }
+        return QL_DEV_SUCCESS;
+    }
+}
+
+QL_DEV_ERROR_CODE ql_dev_release()
+{
+    if(ql_info_handle)
+    {
+        LOGD("ql_info_handle_num = %d", ql_info_handle_num);
+        if(ql_info_handle_num == 1) { // 最后一个引用，可释放。
+            int ret = mbtk_info_handle_free(&ql_info_handle);
+            if(ret) {
+                LOGE("mbtk_info_handle_free() fail.");
+                return QL_DEV_GENERIC_FAILURE;
+            }
+            else
+            {
+                ql_info_handle_num = 0;
+                ql_info_handle = NULL;
+                return QL_DEV_SUCCESS;
+            }
+        } else {
+            ql_info_handle_num--;
+            return QL_DEV_SUCCESS;
+        }
+    }
+    else
+    {
+        LOGE("DEV handle not inited.");
+        return QL_DEV_GENERIC_FAILURE;
+    }
+}
+
+QL_DEV_ERROR_CODE ql_dev_get_imei(char* imei)
+{
+    if(ql_info_handle == NULL || imei == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_DEV_GENERIC_FAILURE;
+    }
+
+    if(mbtk_imei_get(ql_info_handle, imei)) {
+        return QL_DEV_GENERIC_FAILURE;
+    } else {
+        return QL_DEV_SUCCESS;
+    }
+}
+
+QL_DEV_ERROR_CODE ql_dev_get_firmware_version(char* version)
+{
+    if(ql_info_handle == NULL || version == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_DEV_GENERIC_FAILURE;
+    }
+
+    if(mbtk_version_get(ql_info_handle, version)) {
+        return QL_DEV_GENERIC_FAILURE;
+    } else {
+        return QL_DEV_SUCCESS;
+    }
+}
+
+QL_DEV_ERROR_CODE ql_dev_get_model(char* model)
+{
+    if(ql_info_handle == NULL || model == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_DEV_GENERIC_FAILURE;
+    }
+
+    if(mbtk_model_get(ql_info_handle, model)) {
+        return QL_DEV_GENERIC_FAILURE;
+    } else {
+        return QL_DEV_SUCCESS;
+    }
+}
+
+QL_DEV_ERROR_CODE ql_dev_get_sn(char* sn)
+{
+    if(ql_info_handle == NULL || sn == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_DEV_GENERIC_FAILURE;
+    }
+
+    if(mbtk_sn_get(ql_info_handle, sn)) {
+        return QL_DEV_GENERIC_FAILURE;
+    } else {
+        return QL_DEV_SUCCESS;
+    }
+}
+
+QL_DEV_ERROR_CODE ql_dev_set_modem_fun(QL_DEV_MODEM_FUNCTION function, int rst)
+{
+    if(ql_info_handle == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_DEV_GENERIC_FAILURE;
+    }
+    mbtk_modem_info_t modem;
+    modem.rst = rst;
+    switch (function)
+    {
+        case QL_DEV_MODEM_MIN_FUN:
+            modem.fun = MBTK_DEV_MODEM_MIN_FUN;
+            break;
+        case QL_DEV_MODEM_FULL_FUN:
+            modem.fun = MBTK_DEV_MODEM_FULL_FUN;
+            break;
+        case QL_DEV_MODEM_DISABLE_RECEIVE_RF_CIRCUITS:
+            modem.fun = MBTK_DEV_MODEM_DISABLE_RECEIVE_RF_CIRCUITS;
+            break;
+        case QL_DEV_MODEM_DISABLE_TRANSMIT_AND_RECEIVE_RF_CIRCUITS:
+            modem.fun = MBTK_DEV_MODEM_DISABLE_TRANSMIT_AND_RECEIVE_RF_CIRCUITS;
+            break;
+        case QL_DEV_MODEM_DISABLE_SIM:
+            modem.fun = MBTK_DEV_MODEM_DISABLE_SIM;
+            break;
+        case QL_DEV_MODEM_TURN_OFF_FULL_SECONDARY_RECEIVE:
+            modem.fun = MBTK_DEV_MODEM_TURN_OFF_FULL_SECONDARY_RECEIVE;
+            break;
+        default:
+            break;
+    }
+    if(mbtk_set_modem_fun(ql_info_handle, &modem)) {
+        return QL_DEV_GENERIC_FAILURE;
+    } else {
+        return QL_DEV_SUCCESS;
+    }
+}
+
+QL_DEV_ERROR_CODE ql_dev_get_modem_fun(int *function)
+{
+    if(ql_info_handle == NULL || function == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_DEV_GENERIC_FAILURE;
+    }
+
+    if(mbtk_get_modem_fun(ql_info_handle, function)) {
+        return QL_DEV_GENERIC_FAILURE;
+    } else {
+        return QL_DEV_SUCCESS;
+    }
+}
+
+//**********************
diff --git a/mbtk/libql_lib_v2/src/ql_fota.c b/mbtk/libql_lib_v2/src/ql_fota.c
new file mode 100755
index 0000000..eb0afc7
--- /dev/null
+++ b/mbtk/libql_lib_v2/src/ql_fota.c
@@ -0,0 +1,63 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <fcntl.h>
+#include "mbtk_fota.h"
+
+
+int ql_fota_init(fota_callback cb)
+{
+    return mbtk_fota_init(cb);
+}
+
+/*******************************************************************************
+* @brief write firmware package, the firmware package is written in segments.
+         and The result of the write is output by calling the callback function.
+         the firmware package size must less than 32MB
+  @param
+           fname: firmware package file
+    segment_size: the length of once write, recommending 3*1024*1024 bytes
+  @return
+        if success return 0, else return -1
+ *******************************************************************************/
+int ql_fota_fw_write(char* fname, int segment_size)
+{
+    return mbtk_fota_fw_write(fname, segment_size);
+}
+
+
+/*******************************************************************************
+* @brief download firmware by url, and write firmware package, the firmware
+         package is written in segments. The result of the write is output by
+         calling the callback function. the firmware package size must less than
+         32MB
+  @param
+                 url: [IN] the address of download firmware package file, the url
+                           support http or https protocol.
+        segment_size: [IN] the length of once write, recommending 3*1024*1024 bytes
+        conn_timeout: [IN] timeout to connect to the server, if set 0 that means
+                           switch to the default build-in connection timeout(300s)
+    download_timeout: [IN] timeout for download the firmware file. if set 0 that means
+                           it never time out
+  @return
+        if success return 0, else return -1
+ *******************************************************************************/
+int ql_fota_fw_write_by_url(char* url, int segment_size,
+                            int conn_timeout, int download_timeout)
+{
+    return mbtk_fota_fw_write_by_url(url, segment_size,conn_timeout, download_timeout);
+}
+/*******************************************************************************
+* @brief reboot system and clear env
+  @param
+   is_reboot: if set 1, after fota success, reboot system
+  @return
+        if success return 0, else return -1
+ *******************************************************************************/
+int ql_fota_done(int is_reboot)
+{
+    return mbtk_fota_done1(is_reboot);
+}
diff --git a/mbtk/libql_lib_v2/src/ql_gpio.c b/mbtk/libql_lib_v2/src/ql_gpio.c
new file mode 100755
index 0000000..9be2026
--- /dev/null
+++ b/mbtk/libql_lib_v2/src/ql_gpio.c
@@ -0,0 +1,741 @@
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <fcntl.h>
+
+#include "mbtk_log.h"
+#include "mbtk_utils.h"
+#include "ql/ql_gpio.h"
+
+typedef struct {
+    int pin;
+    int gpio;
+} pin_gpio_mmap_s;
+
+#ifdef MBTK_PROJECT_L508
+static pin_gpio_mmap_s pin_gpio_mmap[] = {
+    {PINNAME_GPIO1, -1},            /*PIN-1*/
+    {PINNAME_GPIO2, -1},             /*PIN-2*/
+    {PINNAME_GPIO3, -1},             /*PIN-3*/
+    {PINNAME_GPIO4, -1},             /*PIN-4*/
+    {PINNAME_GPIO5, -1},             /*PIN-5*/
+    {PINNAME_NET_STATUS, -1},        /*PIN-6*/
+    {PINNAME_DBG_RXD, -1},          /*PIN-11*/
+    {PINNAME_DBG_TXD, -1},          /*PIN-12*/
+    {PINNAME_USIM_PRESENCE, 19},    /*PIN-13*/
+    {PINNAME_SD_INT_DET, -1},       /*PIN-23*/
+    {PINNAME_PCM_IN, 28},           /*PIN-24*/
+    {PINNAME_PCM_OUT, 27},          /*PIN-25*/
+    {PINNAME_PCM_SYNC, -1},         /*PIN-26*/
+    {PINNAME_PCM_CLK, -1},          /*PIN-27*/
+    {PINNAME_SDC2_DATA3, 21},       /*PIN-28*/
+    {PINNAME_SDC2_DATA2, -1},       /*PIN-29*/
+    {PINNAME_SDC2_DATA1, 4},       /*PIN-30*/
+    {PINNAME_SDC2_DATA0, -1},       /*PIN-31*/
+    {PINNAME_SDC2_CLK, -1},         /*PIN-32*/
+    {PINNAME_SDC2_CMD, -1},         /*PIN-33*/
+    {PINNAME_SPI_CS_N, -1},         /*PIN-37*/
+    {PINNAME_SPI_MOSI, -1},         /*PIN-38*/
+    {PINNAME_SPI_MISO, -1},         /*PIN-39*/
+    {PINNAME_SPI_CLK, -1},          /*PIN-40*/
+    {PINNAME_I2C_SCL, -1},          /*PIN-41*/
+    {PINNAME_I2C_SDA, -1},          /*PIN-42*/
+    {PINNAME_GPIO20, 20},           /*PIN-45*/
+    {PINNAME_STATUS, 13},           /*PIN-49*/
+    {PINNAME_NETLIGHT, 14},         /*PIN-51*/
+    {PINNAME_GPIO6, -1},            /*PIN-62*/
+    {PINNAME_DCD, -1},              /*PIN-63*/
+    {PINNAME_DTR, -1},              /*PIN-66*/
+    {PINNAME_MAIN_CTS, -1},         /*PIN-64*/
+    {PINNAME_MAIN_RTS, -1},         /*PIN-65*/
+    {PINNAME_MAIN_TXD, -1},         /*PIN-67*/
+    {PINNAME_MAIN_RXD, -1},         /*PIN-68*/
+    {PINNAME_RMII_RXD1, -1},        /*PIN-73*/
+    {PINNAME_RMII_RXCL, -1},        /*PIN-74*/
+    {PINNAME_RMII_CLK, 3},         /*PIN-75*/
+    {PINNAME_RMII_RXD0, 1},        /*PIN-76*/
+    {PINNAME_RMII_TXD0, -1},        /*PIN-77*/
+    {PINNAME_RMII_TXD1, -1},        /*PIN-78*/
+    {PINNAME_RMII_RXD2, -1},        /*PIN-79*/
+    {PINNAME_RMII_TXD2, -1},        /*PIN-80*/
+    {PINNAME_RMII_TX_CTRL, -1},     /*PIN-81*/
+    {PINNAME_RMII_RXD3, -1},        /*PIN-82*/
+    {PINNAME_RMII_TXCL, -1},        /*PIN-83*/
+    {PINNAME_RMII_TXD3, 5},        /*PIN-84*/
+    {PINNAME_WLAN_SLP_CLK, -1},    /*PIN-118*/
+    {PINNAME_RMII_RST, 20},        /*PIN-119*/
+    {PINNAME_RMII_INT, -1},        /*PIN-120*/
+    {PINNAME_RMII_MDIO, 17},       /*PIN-121*/
+    {PINNAME_RMII_MDC, 16},        /*PIN-122*/
+    {PINNAME_PRI_TDI, 117},        /*PIN-123*/
+    {PINNAME_WLAN_PER_EN, 24},     /*PIN-127*/
+    {PINNAME_WLAN_WAKE, 21},       /*PIN-135*/
+    {PINNAME_WLAN_EN, 22},         /*PIN-136*/
+    {PINNAME_GPIO8, -1},            /*PIN-139*/
+};
+#else
+static pin_gpio_mmap_s pin_gpio_mmap[] = {
+    {PINNAME_GPIO1, -1},            /*PIN-1*/
+    {PINNAME_GPIO2, -1},             /*PIN-2*/
+    {PINNAME_GPIO3, -1},             /*PIN-3*/
+    {PINNAME_GPIO4, -1},             /*PIN-4*/
+    {PINNAME_GPIO5, -1},             /*PIN-5*/
+    {PINNAME_NET_STATUS, -1},        /*PIN-6*/
+    {PINNAME_DBG_RXD, -1},          /*PIN-11*/
+    {PINNAME_DBG_TXD, -1},          /*PIN-12*/
+    {PINNAME_USIM_PRESENCE, 19},    /*PIN-13*/
+    {PINNAME_SD_INT_DET, -1},       /*PIN-23*/
+    {PINNAME_PCM_IN, 28},           /*PIN-24*/
+    {PINNAME_PCM_OUT, 27},          /*PIN-25*/
+    {PINNAME_PCM_SYNC, -1},         /*PIN-26*/
+    {PINNAME_PCM_CLK, -1},          /*PIN-27*/
+    {PINNAME_SDC2_DATA3, 21},       /*PIN-28*/
+    {PINNAME_SDC2_DATA2, -1},       /*PIN-29*/
+    {PINNAME_SDC2_DATA1, 4},       /*PIN-30*/
+    {PINNAME_SDC2_DATA0, -1},       /*PIN-31*/
+    {PINNAME_SDC2_CLK, -1},         /*PIN-32*/
+    {PINNAME_SDC2_CMD, -1},         /*PIN-33*/
+    {PINNAME_SPI_CS_N, -1},         /*PIN-37*/
+    {PINNAME_SPI_MOSI, -1},         /*PIN-38*/
+    {PINNAME_SPI_MISO, -1},         /*PIN-39*/
+    {PINNAME_SPI_CLK, -1},          /*PIN-40*/
+    {PINNAME_I2C_SCL, -1},          /*PIN-41*/
+    {PINNAME_I2C_SDA, -1},          /*PIN-42*/
+    {PINNAME_GPIO20, 20},           /*PIN-45*/
+    {PINNAME_STATUS, 13},           /*PIN-49*/
+    {PINNAME_NETLIGHT, 14},         /*PIN-51*/
+    {PINNAME_GPIO6, -1},            /*PIN-62*/
+    {PINNAME_DCD, -1},              /*PIN-63*/
+    {PINNAME_DTR, -1},              /*PIN-66*/
+    {PINNAME_MAIN_CTS, -1},         /*PIN-64*/
+    {PINNAME_MAIN_RTS, -1},         /*PIN-65*/
+    {PINNAME_MAIN_TXD, -1},         /*PIN-67*/
+    {PINNAME_MAIN_RXD, -1},         /*PIN-68*/
+    {PINNAME_RMII_RXD1, -1},        /*PIN-73*/
+    {PINNAME_RMII_RXCL, -1},        /*PIN-74*/
+    {PINNAME_RMII_CLK, 3},         /*PIN-75*/
+    {PINNAME_RMII_RXD0, 1},        /*PIN-76*/
+    {PINNAME_RMII_TXD0, -1},        /*PIN-77*/
+    {PINNAME_RMII_TXD1, -1},        /*PIN-78*/
+    {PINNAME_RMII_RXD2, -1},        /*PIN-79*/
+    {PINNAME_RMII_TXD2, -1},        /*PIN-80*/
+    {PINNAME_RMII_TX_CTRL, -1},     /*PIN-81*/
+    {PINNAME_RMII_RXD3, -1},        /*PIN-82*/
+    {PINNAME_RMII_TXCL, -1},        /*PIN-83*/
+    {PINNAME_RMII_TXD3, 5},        /*PIN-84*/
+    {PINNAME_WLAN_SLP_CLK, -1},    /*PIN-118*/
+    {PINNAME_RMII_RST, 20},        /*PIN-119*/
+    {PINNAME_RMII_INT, -1},        /*PIN-120*/
+    {PINNAME_RMII_MDIO, 17},       /*PIN-121*/
+    {PINNAME_RMII_MDC, 16},        /*PIN-122*/
+    {PINNAME_PRI_TDI, 117},        /*PIN-123*/
+    {PINNAME_WLAN_PER_EN, 24},     /*PIN-127*/
+    {PINNAME_WLAN_WAKE, 21},       /*PIN-135*/
+    {PINNAME_WLAN_EN, 22},         /*PIN-136*/
+    {PINNAME_GPIO8, -1},            /*PIN-139*/
+};
+
+#endif
+
+static int gpio_export(int gpio)
+{
+    int index=0;
+    int file=-1;
+    int result =-1;
+    char pin_index_buffer[5]= {0};
+
+    char buffer[50];
+    memset(buffer,0,50);
+    sprintf(buffer,"/sys/class/gpio/gpio%d/direction", gpio);
+    if(access(buffer , F_OK) == 0)
+    {
+        LOGD("%d has export.", gpio);
+        return 0;
+    }
+
+    file = open("/sys/class/gpio/export",O_WRONLY);
+    if(file == -1)
+    {
+        LOGE("Open gpio export file fail.");
+        return -1;
+    }
+
+    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)
+    {
+        LOGE("Gpio[%d] export fail.", gpio);
+        close(file);
+        return -1;
+    }
+    close(file);
+
+    return 0;
+}
+
+static int gpio_unexport(int gpio)
+{
+    int index=0;
+    int file=-1;
+    int result =-1;
+    char pin_index_buffer[5]= {0};
+    char buffer[50];
+    memset(buffer,0,50);
+    sprintf(buffer,"/sys/class/gpio/gpio%d/direction", gpio);
+    if(access(buffer , F_OK) == -1)
+    {
+        LOGD("%d not export.", gpio);
+        return 0;
+    }
+
+    file = open("/sys/class/gpio/unexport",O_WRONLY);
+    if(file == -1)
+    {
+        LOGE("Open gpio unexport file fail.");
+        return -1;
+    }
+
+    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)
+    {
+        close(file);
+        LOGE("Gpio[%d] unexport fail.", gpio);
+        return -1;
+    }
+    close(file);
+
+    return 0;
+}
+
+static int gpio_direct_get(int gpio, char *value, int value_size)
+{
+    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_RDONLY);
+    if(file == -1)
+    {
+        LOGE("Open gpio[%d] direct fail.", gpio);
+        return -1;
+    }
+
+    memset(value, 0x0, value_size);
+    result = read(file,value,value_size);
+    if(result <= 0)
+    {
+        LOGE("Get gpio[%d] direct fail.", gpio);
+        close(file);
+        return -1;
+    }
+    close(file);
+
+    return 0;
+}
+
+
+static int gpio_direct_set(int gpio, char *value)
+{
+    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)
+    {
+        LOGE("Open gpio[%d] direct fail.", gpio);
+        return -1;
+    }
+
+    result = write(file,value,strlen(value));
+    if(result != strlen(value))
+    {
+        LOGE("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)
+    {
+        LOGE("Open gpio[%d] fail.", gpio);
+        return -1;
+    }
+    result = read(file,buffer,5);
+    if(result <= 0)
+    {
+        LOGE("Get gpio[%d] value fail", gpio);
+        close(file);
+        return -1;
+    }
+    close(file);
+    value = atoi(buffer);
+    return value;
+}
+
+static int gpio_value_set(int gpio, int value)
+{
+    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)
+    {
+        LOGE("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)
+    {
+        LOGE("Set gpio[%d] value fail.", gpio);
+        close(file);
+        return -1;
+    }
+    close(file);
+
+    return 0;
+}
+
+static int pin_2_gpio(Enum_PinName       pin_name)
+{
+#if 0
+    switch(pin_name){
+        case PINNAME_USIM_PRESENCE:    /*PIN-13*/
+            return 19;
+        case PINNAME_PCM_IN:           /*PIN-24*/
+            return 28;
+        case PINNAME_PCM_OUT:          /*PIN-25*/
+            return 27;
+        case PINNAME_RMII_CLK:         /*PIN-75*/
+            return 3;
+        case PINNAME_RMII_RXD0:        /*PIN-76*/
+            return 1;
+        case PINNAME_RMII_RST:          /*PIN-119*/
+            return 20;
+        case PINNAME_RMII_MDIO:         /*PIN-121*/
+            return 17;
+        case PINNAME_RMII_MDC:          /*PIN-122*/
+            return 16;
+        case PINNAME_WLAN_PER_EN:       /*PIN-127*/
+            return 24;
+        case PINNAME_WLAN_WAKE:         /*PIN-135*/
+            return 21;
+        case PINNAME_WLAN_EN:           /*PIN-136*/
+            return 22;
+
+        // Unknown PIN.
+        case PINNAME_GPIO1:             /*PIN-1*/
+        case PINNAME_GPIO2:             /*PIN-2*/
+        case PINNAME_GPIO3:             /*PIN-3*/
+        case PINNAME_GPIO4:             /*PIN-4*/
+        case PINNAME_GPIO5:             /*PIN-5*/
+        case PINNAME_NET_STATUS:        /*PIN-6*/
+        case PINNAME_DBG_RXD:           /*PIN-11*/
+        case PINNAME_DBG_TXD:          /*PIN-12*/
+        case PINNAME_SD_INT_DET:       /*PIN-23*/
+        case PINNAME_PCM_SYNC:         /*PIN-26*/
+        case PINNAME_PCM_CLK:          /*PIN-27*/
+        case PINNAME_SDC2_DATA3:       /*PIN-28*/
+        case PINNAME_SDC2_DATA2:       /*PIN-29*/
+        case PINNAME_SDC2_DATA1:       /*PIN-30*/
+        case PINNAME_SDC2_DATA0:       /*PIN-31*/
+        case PINNAME_SDC2_CLK:         /*PIN-32*/
+        case PINNAME_SDC2_CMD:         /*PIN-33*/
+        case PINNAME_SPI_CS_N:         /*PIN-37*/
+        case PINNAME_SPI_MOSI:         /*PIN-38*/
+        case PINNAME_SPI_MISO:         /*PIN-39*/
+        case PINNAME_SPI_CLK:          /*PIN-40*/
+        case PINNAME_I2C_SCL:          /*PIN-41*/
+        case PINNAME_I2C_SDA:          /*PIN-42*/
+        case PINNAME_GPIO6:            /*PIN-62*/
+        case PINNAME_DCD:              /*PIN-63*/
+        case PINNAME_DTR:              /*PIN-66*/
+        case PINNAME_MAIN_CTS:         /*PIN-64*/
+        case PINNAME_MAIN_RTS:         /*PIN-65*/
+        case PINNAME_MAIN_TXD:         /*PIN-67*/
+        case PINNAME_MAIN_RXD:         /*PIN-68*/
+        case PINNAME_RMII_RXD1:        /*PIN-73*/
+        case PINNAME_RMII_RXCL:        /*PIN-74*/
+        case PINNAME_RMII_TXD0:        /*PIN-77*/
+        case PINNAME_RMII_TXD1:        /*PIN-78*/
+        case PINNAME_RMII_RXD2:        /*PIN-79*/
+        case PINNAME_RMII_TXD2:        /*PIN-80*/
+        case PINNAME_RMII_TX_CTRL:     /*PIN-81*/
+        case PINNAME_RMII_RXD3:        /*PIN-82*/
+        case PINNAME_RMII_TXCL:        /*PIN-83*/
+        case PINNAME_RMII_TXD3:        /*PIN-84*/
+        case PINNAME_WLAN_SLP_CLK:      /*PIN-118*/
+        case PINNAME_RMII_INT:          /*PIN-120*/
+        case PINNAME_GPIO8:             /*PIN-139*/
+        default:
+            LOGE("Unknown PIN : %d", pin_name);
+            return -1;
+    }
+#else
+    int i = 0;
+    while(i < ARRAY_SIZE(pin_gpio_mmap)) {
+        if(pin_name == pin_gpio_mmap[i].pin) {
+            return pin_gpio_mmap[i].gpio;
+        }
+        i++;
+    }
+
+    LOGE("No found PIN : %d", pin_name);
+    return -1;
+#endif
+}
+
+
+/*****************************************************************
+* Function:     Ql_GPIO_Init
+*
+* Description:
+*               This function enables the GPIO function of the specified pin,
+*               and initialize the configurations, including direction,
+*               level and pull selection.
+*
+* Parameters:
+*               pin_name:
+*                   Pin name, one value of Enum_PinName.
+*               dir:
+*                   The initial direction of GPIO, one value of Enum_PinDirection.
+*               level:
+*                   The initial level of GPIO, one value of Enum_PinLevel.
+*               pull_sel:
+*                   Pull selection, one value of Enum_PinPullSel.
+* Return:
+*               RES_OK, this function succeeds.
+*               RES_IO_NOT_SUPPORT, the input GPIO is invalid.
+*               RES_IO_ERR, the function failed
+*               other place. For example this GPIO has been using as EINT.
+*****************************************************************/
+int Ql_GPIO_Init(Enum_PinName       pin_name,
+                 Enum_PinDirection  dir,
+                 Enum_PinLevel      level,
+                 Enum_PinPullSel    pull_sel
+                 )
+{
+    int gpio = pin_2_gpio(pin_name);
+    if(gpio == -1) {
+        return RES_IO_ERROR;
+    }
+    LOGD("PIN-%d => GPIO-%d", pin_name, gpio);
+
+    if(gpio_export(gpio))
+    {
+        LOGE("gpio_export() fail.");
+        return RES_IO_ERROR;
+    }
+
+    if(gpio_direct_set(gpio, dir == PINDIRECTION_IN ? "in" : "out"))
+    {
+        LOGE("gpio_direct_set() fail.");
+        return RES_IO_ERROR;
+    }
+
+    if(dir == PINDIRECTION_OUT){
+        if(gpio_value_set(gpio, level))
+        {
+            LOGE("gpio_value_set() fail.");
+            return RES_IO_ERROR;
+        }
+    }
+    // No support pull mode now.
+
+    return RES_OK;
+}
+
+/*****************************************************************
+* Function:     Ql_GPIO_Base_Init
+*
+* Description:
+*               This function enables the GPIO function of the specified pin.
+*
+* Parameters:
+*               pin_name:
+*                   Pin name, one value of Enum_PinName.
+*
+* Return:
+*               RES_OK, this function succeeds.
+*               RES_IO_NOT_SUPPORT, the input GPIO is invalid.
+*               RES_IO_ERR, the function failed
+*****************************************************************/
+int Ql_GPIO_Base_Init(Enum_PinName pin_name );
+
+/*****************************************************************
+* Function:     Ql_GPIO_SetLevel
+*
+* Description:
+*               This function sets the level of the specified GPIO.
+*
+* Parameters:
+*               pin_name:
+*                   Pin name, one value of Enum_PinName.
+*               level:
+*                   The initial level of GPIO, one value of Enum_PinLevel.
+* Return:
+*               RES_OK, this function succeeds.
+*               RES_IO_NOT_SUPPORT, the input GPIO is invalid.
+*               RES_IO_ERR, the function failed
+*               other place. For example this GPIO has been using as EINT.
+*****************************************************************/
+int Ql_GPIO_SetLevel(Enum_PinName pin_name, Enum_PinLevel level)
+{
+    int gpio = pin_2_gpio(pin_name);
+    if(gpio == -1) {
+        return RES_IO_ERROR;
+    }
+    LOGD("PIN-%d => GPIO-%d", pin_name, gpio);
+
+    if(gpio_value_set(gpio, level)) {
+        LOGE("gpio_value_set() fail.");
+        return RES_IO_ERROR;
+    } else {
+        return RES_OK;
+    }
+}
+
+/*****************************************************************
+* Function:     Ql_GPIO_GetLevel
+*
+* Description:
+*               This function gets the level of the specified GPIO.
+*
+* Parameters:
+*               pin_name:
+*                   Pin name, one value of Enum_PinName.
+* Return:
+*               The level value of the specified GPIO, which is
+*               nonnegative integer.
+*               RES_IO_NOT_SUPPORT, the input GPIO is invalid.
+*****************************************************************/
+int Ql_GPIO_GetLevel(Enum_PinName pin_name)
+{
+    int gpio = pin_2_gpio(pin_name);
+    if(gpio == -1) {
+        return RES_IO_ERROR;
+    }
+    LOGD("PIN-%d => GPIO-%d", pin_name, gpio);
+
+    return gpio_value_get(gpio);
+}
+
+/*****************************************************************
+* Function:     Ql_GPIO_SetDirection
+*
+* Description:
+*               This function sets the direction of the specified GPIO.
+*
+* Parameters:
+*               pin_name:
+*                   Pin name, one value of Enum_PinName.
+*               dir:
+*                   The initial direction of GPIO, one value of Enum_PinDirection.
+* Return:
+*               RES_OK, this function succeeds.
+*               RES_IO_NOT_SUPPORT, the input GPIO is invalid.
+*               RES_IO_ERR, the function failed
+*               other place. For example this GPIO has been using as EINT.
+*****************************************************************/
+int Ql_GPIO_SetDirection(Enum_PinName pin_name, Enum_PinDirection dir)
+{
+    int gpio = pin_2_gpio(pin_name);
+    if(gpio == -1) {
+        return RES_IO_ERROR;
+    }
+    LOGD("PIN-%d => GPIO-%d", pin_name, gpio);
+
+    if(gpio_direct_set(gpio, dir == PINDIRECTION_IN ? "in" : "out")) {
+        LOGE("gpio_direct_set() fail.");
+        return RES_IO_ERROR;
+    } else {
+        return RES_OK;
+    }
+}
+
+/*****************************************************************
+* Function:     Ql_GPIO_GetDirection
+*
+* Description:
+*               This function gets the direction of the specified GPIO.
+*
+* Parameters:
+*               pin_name:
+*                   Pin name, one value of Enum_PinName.
+* Return:
+*               0  INPUT
+*               1  OUTPUT
+*               RES_IO_NOT_SUPPORT, the input GPIO is invalid.
+*               other place. For example this GPIO has been using as EINT.
+*****************************************************************/
+int Ql_GPIO_GetDirection(Enum_PinName pin_name)
+{
+    char buff[10];
+    int gpio = pin_2_gpio(pin_name);
+    if(gpio == -1) {
+        return RES_IO_ERROR;
+    }
+    LOGD("PIN-%d => GPIO-%d", pin_name, gpio);
+
+    if(gpio_direct_get(gpio, buff, 10)) {
+        LOGE("gpio_direct_get() fail.");
+        return RES_IO_NOT_SUPPORT;
+    } else {
+        if(strncmp(buff, "in",2) == 0) {
+            return PINDIRECTION_IN;
+        } else if(strncmp(buff, "out",3) == 0) {
+            return PINDIRECTION_OUT;
+        } else {
+            return RES_IO_NOT_SUPPORT;
+        }
+    }
+}
+
+/*****************************************************************
+* Function:     Ql_GPIO_SetPullSelection
+*
+* Description:
+*               This function sets the pull selection of the specified GPIO.
+*
+* Parameters:
+*               pin_name:
+*                   Pin name, one value of Enum_PinName.
+*               Enum_PinPullSel:
+*                   Pull selection, one value of Enum_PinPullSel.
+* Return:
+*               RES_OK, this function succeeds.
+*               RES_IO_NOT_SUPPORT, the input GPIO is invalid.
+*               RES_IO_ERR, the function failed
+*               other place. For example this GPIO has been using as EINT.
+*****************************************************************/
+int Ql_GPIO_SetPullSelection(Enum_PinName pin_name, Enum_PinPullSel pull_sel);
+
+/*****************************************************************
+* Function:     ql_gpio_get_pull_selection
+*
+* Description:
+*               This function gets the pull selection of the specified GPIO.
+*
+* Parameters:
+*               pin_name:
+*                   Pin name, one value of Enum_PinName.
+* Return:
+*               0<<13   no pull
+*               5<<13   pull down
+*               6<<13   pull up
+*****************************************************************/
+int Ql_GPIO_GetPullSelection(Enum_PinName pin_name);
+
+
+/*****************************************************************
+* Function:     Ql_GPIO_Uninit
+*
+* Description:
+*               This function releases the specified GPIO that was
+*               initialized by calling Ql_GPIO_Init() previously.
+*               After releasing, the GPIO can be used for other purpose.
+* Parameters:
+*               pin_name:
+*                   Pin name, one value of Enum_PinName.
+* Return:
+*               RES_OK, this function succeeds.
+*               RES_IO_NOT_SUPPORT, the input GPIO is invalid.
+*               RES_IO_ERR, the function failed
+*               other place. For example this GPIO has been using as EINT.
+*****************************************************************/
+int Ql_GPIO_Uninit(Enum_PinName pin_name)
+{
+    int gpio = pin_2_gpio(pin_name);
+    if(gpio == -1) {
+        return RES_IO_ERROR;
+    }
+    LOGD("PIN-%d => GPIO-%d", pin_name, gpio);
+
+    if(gpio_unexport(gpio))
+    {
+        LOGE("gpio_unexport() fail.");
+        return RES_IO_ERROR;
+    }
+
+    return RES_OK;
+}
+
+//------------------------------------------------------------------------------
+/*
+* Function:     Ql_EINT_Enable
+*
+* Description:
+*               Set the interrupt sense mode, and enable interrupt.
+*
+* Parameters:
+*               eint_pin_name:
+*                   EINT pin name, one value of Enum_PinName that has
+*                   the interrupt function.
+*
+*               eint_type:
+*                   Interrupt type, level-triggered or edge-triggered.
+*                   Now, only edge-triggered interrupt is supported.
+*
+*               eint_callback:
+*                   call back function
+*
+* Return:
+*               RES_OK, this function succeeds.
+*               else failed to execute the function.
+*/
+//------------------------------------------------------------------------------
+int Ql_EINT_Enable(Enum_PinName eint_pin_name, Enum_EintType eint_type, Ql_EINT_Callback eint_callback);
+
+
+//------------------------------------------------------------------------------
+/*
+* Function:     Ql_EINT_Disable
+*
+* Description:
+*               Disable the interrupt sense.
+*
+* Parameters:
+*               eint_pin_name:
+*                   EINT pin name, one value of Enum_PinName that has
+*                   the interrupt function.
+*
+* Return:
+*               RES_OK, this function succeeds.
+*               else failed to execute the function.
+*/
+//------------------------------------------------------------------------------
+int Ql_EINT_Disable(Enum_PinName eint_pin_name);
+
diff --git a/mbtk/libql_lib_v2/src/ql_i2c.c b/mbtk/libql_lib_v2/src/ql_i2c.c
new file mode 100755
index 0000000..8b8c6a0
--- /dev/null
+++ b/mbtk/libql_lib_v2/src/ql_i2c.c
@@ -0,0 +1,222 @@
+#include <stdio.h>
+#include <linux/types.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <assert.h>
+#include <string.h>
+#include <linux/i2c.h>
+#include <linux/i2c-dev.h>
+
+#include "mbtk_log.h"
+#include "ql/ql_i2c.h"
+
+int Ql_I2C_Init(char *dev_name)
+{
+    int fd = open(dev_name, O_RDWR);
+    if(fd <= 0) {
+        LOGE("open (%s) fail:errno - %d", dev_name, errno);
+        return -1;
+    }
+    return fd;
+}
+
+
+int Ql_I2C_Read(int fd, unsigned short slaveAddr, unsigned char ofstAddr,  unsigned char* ptrBuff, unsigned short length)
+{
+    uint8_t outbuf[1];
+    struct i2c_rdwr_ioctl_data packets;
+    struct i2c_msg messages[2];
+
+    outbuf[0] = ofstAddr;
+    messages[0].addr = slaveAddr;
+    messages[0].flags = 0;
+    messages[0].len = sizeof(outbuf);
+    messages[0].buf = outbuf;
+
+    /* The data will get returned in this structure */
+    messages[1].addr = slaveAddr;
+    messages[1].flags = I2C_M_RD/* | I2C_M_NOSTART*/;
+    messages[1].len = length;
+    messages[1].buf = ptrBuff;
+
+    /* Send the request to the kernel and get the result back */
+    packets.msgs = messages;
+    packets.nmsgs = 2;
+    if(ioctl(fd, I2C_RDWR, &packets) < 0)
+    {
+        LOGE("Error: Unable to send data");
+        return -1;
+    }
+
+    return 0;
+}
+
+
+int Ql_I2C_Write(int fd, unsigned short slaveAddr, unsigned char ofstAddr,  unsigned char* ptrData, unsigned short length)
+{
+    uint8_t *outbuf = NULL;
+    struct i2c_rdwr_ioctl_data packets;
+    struct i2c_msg messages[1];
+
+    outbuf = malloc(length + 1);
+    if (!outbuf) {
+        printf("Error: No memory for buffer\n");
+        return -1;
+    }
+
+    outbuf[0] = ofstAddr;
+    memcpy(outbuf + 1, ptrData, length);
+
+    messages[0].addr = slaveAddr;
+    messages[0].flags = 0;
+    messages[0].len = length + 1;
+    messages[0].buf = outbuf;
+
+    /* Transfer the i2c packets to the kernel and verify it worked */
+    packets.msgs = messages;
+    packets.nmsgs = 1;
+    if(ioctl(fd, I2C_RDWR, &packets) < 0)
+    {
+        printf("Error: Unable to send data");
+        free(outbuf);
+        return -1;
+    }
+
+    free(outbuf);
+
+    return 0;
+}
+
+
+int Ql_I2C_Deinit(int fd)
+{
+    if (fd <= 0)
+        return -1;
+
+    close(fd);
+    return 0;
+}
+
+#if 0
+int open_i2c_dev(int i2cbus, char *filename, size_t size, int quiet)
+{
+	int file, len;
+
+	len = snprintf(filename, size, "/dev/i2c/%d", i2cbus);
+	if (len >= (int)size) {
+		fprintf(stderr, "%s: path truncated\n", filename);
+		return -EOVERFLOW;
+	}
+	file = open(filename, O_RDWR);
+
+	if (file < 0 && (errno == ENOENT || errno == ENOTDIR)) {
+		len = snprintf(filename, size, "/dev/i2c-%d", i2cbus);
+		if (len >= (int)size) {
+			fprintf(stderr, "%s: path truncated\n", filename);
+			return -EOVERFLOW;
+		}
+		file = open(filename, O_RDWR);
+	}
+	...
+	return file;
+}
+
+static int i2c_read_bytes(int fd, uint8_t slave_addr, uint8_t reg_addr, uint8_t *values, uint8_t len)
+{
+    uint8_t outbuf[1];
+    struct i2c_rdwr_ioctl_data packets;
+    struct i2c_msg messages[2];
+
+    outbuf[0] = reg_addr;
+    messages[0].addr = slave_addr;
+    messages[0].flags = 0;
+    messages[0].len = sizeof(outbuf);
+    messages[0].buf = outbuf;
+
+    /* The data will get returned in this structure */
+    messages[1].addr = slave_addr;
+    messages[1].flags = I2C_M_RD/* | I2C_M_NOSTART*/;
+    messages[1].len = len;
+    messages[1].buf = values;
+
+    /* Send the request to the kernel and get the result back */
+    packets.msgs = messages;
+    packets.nmsgs = 2;
+    if(ioctl(fd, I2C_RDWR, &packets) < 0)
+    {
+        printf("Error: Unable to send data");
+        return -1;
+    }
+
+    return 0;
+}
+
+
+static int i2c_write_bytes(int fd, uint8_t slave_addr, uint8_t reg_addr, uint8_t *values, uint8_t len)
+{
+    uint8_t *outbuf = NULL;
+    struct i2c_rdwr_ioctl_data packets;
+    struct i2c_msg messages[1];
+
+    outbuf = malloc(len + 1);
+    if (!outbuf) {
+        printf("Error: No memory for buffer\n");
+        return -1;
+    }
+
+    outbuf[0] = reg_addr;
+    memcpy(outbuf + 1, values, len);
+
+    messages[0].addr = slave_addr;
+    messages[0].flags = 0;
+    messages[0].len = len + 1;
+    messages[0].buf = outbuf;
+
+    /* Transfer the i2c packets to the kernel and verify it worked */
+    packets.msgs = messages;
+    packets.nmsgs = 1;
+    if(ioctl(fd, I2C_RDWR, &packets) < 0)
+    {
+        printf("Error: Unable to send data");
+        free(outbuf);
+        return -1;
+    }
+
+    free(outbuf);
+
+    return 0;
+}
+
+
+int set_slave_addr(int file, int address, int force)
+{
+	/* With force, let the user read from/write to the registers
+	   even when a driver is also running */
+	if (ioctl(file, force ? I2C_SLAVE_FORCE : I2C_SLAVE, address) < 0) {
+		fprintf(stderr,
+			"Error: Could not set address to 0x%02x: %s\n",
+			address, strerror(errno));
+		return -errno;
+	}
+
+	return 0;
+}
+
+
+int main(void)
+{
+	int fd = -1;
+        char send_data[64] = {0};
+	send_data[0] = 0x55;
+	send_data[1] = 0x00;
+	send_data[2] = 0x84;
+    	fd= open_i2c_dev(0, "i2c_test", 5, 0);
+	i2c_write_bytes(fd, 0x12, 0x10,send_data, 3)
+}
+#endif
diff --git a/mbtk/libql_lib_v2/src/ql_quec_nw.c b/mbtk/libql_lib_v2/src/ql_quec_nw.c
new file mode 100755
index 0000000..51598e9
--- /dev/null
+++ b/mbtk/libql_lib_v2/src/ql_quec_nw.c
@@ -0,0 +1,945 @@
+#include "ql/ql_nw.h"
+#include "mbtk_type.h"
+#include "mbtk_info_api.h"
+
+extern mbtk_info_handle_t* ql_info_handle;
+extern int ql_info_handle_num;
+static bool inited = FALSE;
+
+#define SIGNAL_STRENGTH_INVALID_1 99
+#define SIGNAL_STRENGTH_INVALID_2 255
+
+
+typedef struct
+{
+    uint8 *operator_l;
+    uint8 *operator_s;
+    uint32 mcc_mnc;
+} operator_mcc_mnc_t;
+
+typedef struct
+{
+    QL_NW_EventHandlerFunc_t handlerPtr;
+    void* contextPtr;
+} ql_cust_cb_func;
+
+static ql_cust_cb_func ql_func_cb_handle;
+
+static int roaming_pref = 1;  // Open roaming for default.
+
+static operator_mcc_mnc_t operator_mcc_mnc [] =
+{
+    {"China Mobile","CMCC",46000},
+    {"China Unicom","CU",46001},
+    {"China Mobile","CMCC",46002},
+    {"China Telecom","CT",46003},
+    {"China Mobile","CMCC",46004},
+    {"China Telecom","CT",46005},
+    {"China Unicom","CU",46006},
+    {"China Mobile","CMCC",46007},
+    {"China Mobile","CMCC",46008},
+    {"China Unicom","CU",46009},
+    {"China Telecom","CT",46011}
+};
+
+typedef enum {
+    RADIO_TECH_3GPP = 1, /* 3GPP Technologies - GSM, WCDMA */
+    RADIO_TECH_3GPP2 = 2 /* 3GPP2 Technologies - CDMA */
+} RIL_RadioTechnologyFamily;
+
+void ql_nw_state_change_cb(const void* data, int data_len)
+{
+    ///mbtk_net_info_t *reg = (mbtk_net_info_t *)data;
+    uint8 *net_data = NULL;
+
+    net_data = (uint8*)data;
+    /*
+    uint8 data[3];
+    data[0] = (uint8)MBTK_NET_CS_STATE;
+
+    net_data[0] = *(uint8 *)(data);                                 //MBTK_NET_PS_STATE
+    net_data[1] = *(uint8 *)(data + sizeof(uint8));                 //mbtk_net_reg_state_enum state Reg State
+    net_data[2] = *(uint8 *)(data + sizeof(uint8) + sizeof(uint8)); //act
+    */
+    if(roaming_pref == 0)
+    {
+        mbtk_modem_info_t info;
+        if(*net_data == 5)
+        {
+            info.fun=4;
+            //ql_netw_status_cb(5);
+        }
+        else
+            info.fun=1;
+        info.rst=0;
+        //mbtk_set_modem_fun(ql_info_handle, &info);
+    }
+
+    if(ql_func_cb_handle.handlerPtr != NULL)
+    {
+        ql_func_cb_handle.handlerPtr(QL_NW_IND_DATA_REG_EVENT_FLAG,&(net_data[2]), sizeof(&(net_data[2])), NULL);
+    }
+}
+
+QL_NW_ERROR_CODE ql_nw_init()
+{
+    if(!inited && ql_info_handle == NULL)
+    {
+        ql_info_handle = mbtk_info_handle_get();
+        if(ql_info_handle)
+        {
+            ql_info_handle_num++;
+            inited = TRUE;
+            return QL_NW_SUCCESS;
+        } else {
+            LOGE("mbtk_info_handle_get() fail.");
+            return QL_NW_GENERIC_FAILURE;
+        }
+    } else {
+        if(!inited) {
+            ql_info_handle_num++;
+            inited = TRUE;
+        }
+        return QL_NW_SUCCESS;
+    }
+}
+
+QL_NW_ERROR_CODE ql_nw_release()
+{
+    if(ql_info_handle)
+    {
+        LOGD("ql_info_handle_num = %d", ql_info_handle_num);
+        if(ql_info_handle_num == 1) { // 最后一个引用，可释放。
+            int ret = mbtk_info_handle_free(&ql_info_handle);
+            if(ret) {
+                LOGE("mbtk_info_handle_free() fail.");
+                return QL_NW_GENERIC_FAILURE;
+            }
+            else
+            {
+                ql_info_handle_num = 0;
+                ql_info_handle = NULL;
+                return QL_NW_SUCCESS;
+            }
+        } else {
+            ql_info_handle_num--;
+            return QL_NW_SUCCESS;
+        }
+    }
+    else
+    {
+        LOGE("NW handle not inited.");
+        return QL_NW_GENERIC_FAILURE;
+    }
+}
+
+static uint8 net_pre_change(bool mbtk_2_ql,int net_mode)
+{
+    uint8 mbtk_net_pre = 0xFF;
+
+    /*
+    QL_NW_PREF_NET_TYPE_GSM_WCDMA = 0,                      //4
+    QL_NW_PREF_NET_TYPE_GSM_ONLY = 1,                       //0
+    QL_NW_PREF_NET_TYPE_WCDMA = 2,                          //1
+    QL_NW_PREF_NET_TYPE_GSM_WCDMA_AUTO = 3,                 //2
+    QL_NW_PREF_NET_TYPE_LTE_GSM_WCDMA = 9,                  //12
+    QL_NW_PREF_NET_TYPE_LTE_ONLY = 11,                      //5
+    QL_NW_PREF_NET_TYPE_LTE_WCDMA = 12,                     //9
+    QL_NW_PREF_NET_TYPE_LTE_GSM_GSM_PREF = 13,              //7
+    QL_NW_PREF_NET_TYPE_LTE_GSM_LTE_PREF = 14,              //8
+    QL_NW_PREF_NET_TYPE_LTE_GSM = 15,                       //6
+    QL_NW_PREF_NET_TYPE_LTE_WCDMA_WCDMA_PREF = 16,          //10
+    QL_NW_PREF_NET_TYPE_LTE_WCDMA_LTE_PREF = 17,            //11
+    QL_NW_PREF_NET_TYPE_LTE_GSM_WCDMA_GSM_PREF = 19,        //13
+    QL_NW_PREF_NET_TYPE_LTE_GSM_WCDMA_WCDMA_PREF = 20,      //14
+    QL_NW_PREF_NET_TYPE_LTE_GSM_WCDMA_LTE_PREF = 21,        //15
+    */
+    /*
+    0 : GSM only
+    1 : UMTS only
+    2 : GSM/UMTS(auto)
+    3 : GSM/UMTS(GSM preferred)
+    4 : GSM/UMTS(UMTS preferred)
+    5 : LTE only
+    6 : GSM/LTE(auto)
+    7 : GSM/LTE(GSM preferred)
+    8 : GSM/LTE(LTE preferred)
+    9 : UMTS/LTE(auto)
+    10 : UMTS/LTE(UMTS preferred)
+    11 : UMTS/LTE(LTE preferred)
+    12 : GSM/UMTS/LTE(auto)
+    13 : GSM/UMTS/LTE(GSM preferred)
+    14 : GSM/UMTS/LTE(UMTS preferred)
+    15 : GSM/UMTS/LTE(LTE preferred)
+    */
+
+    if(mbtk_2_ql) {
+        switch(net_mode)
+        {
+            case MBTK_NET_PREF_GSM_UMTS_UMTS_PREF:
+                mbtk_net_pre = QL_NW_PREF_NET_TYPE_GSM_WCDMA;
+                break;
+            case MBTK_NET_PREF_GSM_ONLY:
+                mbtk_net_pre = QL_NW_PREF_NET_TYPE_GSM_ONLY;
+                break;
+            case MBTK_NET_PREF_UMTS_ONLY:
+                mbtk_net_pre = QL_NW_PREF_NET_TYPE_WCDMA;
+                break;
+            case MBTK_NET_PREF_GSM_UMTS_AUTO:
+                mbtk_net_pre = QL_NW_PREF_NET_TYPE_GSM_WCDMA_AUTO;
+                break;
+            case MBTK_NET_PREF_GSM_UMTS_LTE_AUTO:
+                mbtk_net_pre = QL_NW_PREF_NET_TYPE_LTE_GSM_WCDMA;
+                break;
+            case MBTK_NET_PREF_LTE_ONLY:
+                mbtk_net_pre = QL_NW_PREF_NET_TYPE_LTE_ONLY;
+                break;
+            case MBTK_NET_PREF_UMTS_LTE_AUTO:
+                mbtk_net_pre = QL_NW_PREF_NET_TYPE_LTE_WCDMA;
+                break;
+            case MBTK_NET_PREF_GSM_LTE_GSM_PREF:
+                mbtk_net_pre = QL_NW_PREF_NET_TYPE_LTE_GSM_GSM_PREF;
+                break;
+            case MBTK_NET_PREF_GSM_LTE_LTE_PREF:
+                mbtk_net_pre = QL_NW_PREF_NET_TYPE_LTE_GSM_LTE_PREF;
+                break;
+            case MBTK_NET_PREF_GSM_LTE_AUTO:
+                mbtk_net_pre = QL_NW_PREF_NET_TYPE_LTE_GSM;
+                break;
+            case MBTK_NET_PREF_UMTS_LTE_UMTS_PREF:
+                mbtk_net_pre = QL_NW_PREF_NET_TYPE_LTE_WCDMA_WCDMA_PREF;
+                break;
+            case MBTK_NET_PREF_UMTS_LTE_LTE_PREF:
+                mbtk_net_pre = QL_NW_PREF_NET_TYPE_LTE_WCDMA_LTE_PREF;
+                break;
+            case MBTK_NET_PREF_GSM_UMTS_LTE_GSM_PREF:
+                mbtk_net_pre = QL_NW_PREF_NET_TYPE_LTE_GSM_WCDMA_GSM_PREF;
+                break;
+            case MBTK_NET_PREF_GSM_UMTS_LTE_UMTS_PREF:
+                mbtk_net_pre = QL_NW_PREF_NET_TYPE_LTE_GSM_WCDMA_WCDMA_PREF;
+                break;
+            case MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF:
+                mbtk_net_pre = QL_NW_PREF_NET_TYPE_LTE_GSM_WCDMA_LTE_PREF;
+                break;
+            default:
+                mbtk_net_pre = 0xFF;
+                break;
+        }
+    } else {
+        switch(net_mode)
+        {
+            case QL_NW_PREF_NET_TYPE_GSM_WCDMA:
+                mbtk_net_pre = MBTK_NET_PREF_GSM_UMTS_UMTS_PREF;
+                break;
+            case QL_NW_PREF_NET_TYPE_GSM_ONLY:
+                mbtk_net_pre = MBTK_NET_PREF_GSM_ONLY;
+                break;
+            case QL_NW_PREF_NET_TYPE_WCDMA:
+                mbtk_net_pre = MBTK_NET_PREF_UMTS_ONLY;
+                break;
+            case QL_NW_PREF_NET_TYPE_GSM_WCDMA_AUTO:
+                mbtk_net_pre = MBTK_NET_PREF_GSM_UMTS_AUTO;
+                break;
+            case QL_NW_PREF_NET_TYPE_LTE_GSM_WCDMA:
+                mbtk_net_pre = MBTK_NET_PREF_GSM_UMTS_LTE_AUTO;
+                break;
+            case QL_NW_PREF_NET_TYPE_LTE_ONLY:
+                mbtk_net_pre = MBTK_NET_PREF_LTE_ONLY;
+                break;
+            case QL_NW_PREF_NET_TYPE_LTE_WCDMA:
+                mbtk_net_pre = MBTK_NET_PREF_UMTS_LTE_AUTO;
+                break;
+            case QL_NW_PREF_NET_TYPE_LTE_GSM_GSM_PREF:
+                mbtk_net_pre = MBTK_NET_PREF_GSM_LTE_GSM_PREF;
+                break;
+            case QL_NW_PREF_NET_TYPE_LTE_GSM_LTE_PREF:
+                mbtk_net_pre = MBTK_NET_PREF_GSM_LTE_LTE_PREF;
+                break;
+            case QL_NW_PREF_NET_TYPE_LTE_GSM:
+                mbtk_net_pre = MBTK_NET_PREF_GSM_LTE_AUTO;
+                break;
+            case QL_NW_PREF_NET_TYPE_LTE_WCDMA_WCDMA_PREF:
+                mbtk_net_pre = MBTK_NET_PREF_UMTS_LTE_UMTS_PREF;
+                break;
+            case QL_NW_PREF_NET_TYPE_LTE_WCDMA_LTE_PREF:
+                mbtk_net_pre = MBTK_NET_PREF_UMTS_LTE_LTE_PREF;
+                break;
+            case QL_NW_PREF_NET_TYPE_LTE_GSM_WCDMA_GSM_PREF:
+                mbtk_net_pre = MBTK_NET_PREF_GSM_UMTS_LTE_GSM_PREF;
+                break;
+            case QL_NW_PREF_NET_TYPE_LTE_GSM_WCDMA_WCDMA_PREF:
+                mbtk_net_pre = MBTK_NET_PREF_GSM_UMTS_LTE_UMTS_PREF;
+                break;
+            case QL_NW_PREF_NET_TYPE_LTE_GSM_WCDMA_LTE_PREF:
+                mbtk_net_pre = MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF;
+                break;
+            default:
+                mbtk_net_pre = 0xFF;
+                break;
+        }
+    }
+    return mbtk_net_pre;
+}
+
+QL_NW_ERROR_CODE ql_nw_set_config(QL_NW_CONFIG_INFO_T *pt_info)
+{
+    if(ql_info_handle == NULL || pt_info == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_NW_GENERIC_FAILURE;
+    }
+
+	if(pt_info->preferred_nw_mode < QL_NW_PREF_NET_TYPE_GSM_WCDMA || pt_info->preferred_nw_mode > QL_NW_PREF_NET_TYPE_LTE_GSM_WCDMA_LTE_PREF)
+	{
+        LOGE("Unknown preferred_nw_mode(%d) error.", pt_info->preferred_nw_mode);
+		return QL_NW_GENERIC_FAILURE;
+	}
+
+    roaming_pref = pt_info->roaming_pref;
+
+    mbtk_band_info_t band;
+    memset(&band, 0, sizeof(mbtk_band_info_t));
+    band.net_pref = net_pre_change(FALSE, pt_info->preferred_nw_mode);
+    if(band.net_pref == 0xFF)
+    {
+        LOGE("net_pre_change() fail.");
+        return QL_NW_GENERIC_FAILURE;
+    }
+    if(mbtk_current_band_set(ql_info_handle, &band)) {
+        return QL_NW_GENERIC_FAILURE;
+    } else {
+        return QL_NW_SUCCESS;
+    }
+}
+
+QL_NW_ERROR_CODE ql_nw_get_config(QL_NW_CONFIG_INFO_T *pt_info)
+{
+    if(ql_info_handle == NULL || pt_info == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_NW_GENERIC_FAILURE;
+    }
+    pt_info->roaming_pref = roaming_pref;
+    mbtk_band_info_t band;
+    if(mbtk_current_band_get(ql_info_handle, &band)) {
+        return QL_NW_GENERIC_FAILURE;
+    } else {
+        pt_info->preferred_nw_mode = (QL_NW_PREFERRED_NETWORK_TYPE)net_pre_change(TRUE, band.net_pref);
+        return QL_NW_SUCCESS;
+    }
+}
+
+QL_NW_ERROR_CODE ql_nw_get_nitz_time_info(QL_NW_NITZ_TIME_INFO_T *pt_info)
+{
+    if(ql_info_handle == NULL || pt_info == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_NW_GENERIC_FAILURE;
+    }
+    memset(pt_info, 0x0, sizeof(QL_NW_NITZ_TIME_INFO_T));
+    char time_str[100]={0};
+    ///printf("mbtk_net_time_get begin\n");
+    int err = mbtk_net_time_get(ql_info_handle, time_str);
+    if(err) {
+        LOGE("mbtk_net_time_get() fail.");
+        return QL_NW_GENERIC_FAILURE;
+    } else {
+        memset(pt_info->nitz_time,0,32);
+        memcpy(pt_info->nitz_time,time_str,strlen(time_str));
+        if(mbtk_get_abs_time(time_str, &(pt_info->abs_time))) {
+            LOGE("mbtk_get_abs_time() fail.");
+            return QL_NW_GENERIC_FAILURE;
+        }
+
+        pt_info->leap_sec = 0;
+
+        return QL_NW_SUCCESS;
+    }
+}
+
+//--------------------------------------------------------------------------------------
+QL_NW_ERROR_CODE ql_nw_event_register(unsigned int bitmask)
+{
+    /*
+    NW_IND_VOICE_REG_EVENT_IND_FLAG 语音拨号注册事件
+    NW_IND_DATA_REG_EVENT_IND_FLAG (1 << 1) 数据拨号注册事件
+    NW_IND_SIGNAL_STRENGTH_EVENT_IND_FLAG (1 << 2) 信号强度事件
+    NW_IND_NITZ_TIME_UPDATE_EVENT_IND_FLAG (1 << 3) 网络时间更新事件
+    */
+    if(bitmask == QL_NW_IND_VOICE_REG_EVENT_FLAG)
+        {}
+    if(bitmask == QL_NW_IND_DATA_REG_EVENT_FLAG)
+        {}
+    if(bitmask == QL_NW_IND_SIGNAL_STRENGTH_EVENT_FLAG)
+        {}
+    if(bitmask == QL_NW_IND_NITZ_TIME_UPDATE_EVENT_FLAG)
+        {}
+    return QL_NW_SUCCESS;
+}
+//--------------------------------------------------------------------------------------
+
+QL_NW_ERROR_CODE ql_nw_get_operator_name(QL_NW_OPERATOR_INFO_T *pt_info)
+{
+    if(ql_info_handle == NULL || pt_info == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_NW_GENERIC_FAILURE;
+    }
+    char OperatorFN[128];
+    char OperatorSH[128];
+    char MccMnc[128];
+    mbtk_net_info_t net;
+    if(!mbtk_net_sel_mode_get(ql_info_handle, &net) && net.plmn > 0)
+    {
+        // printf("Net : %d, %d, %d\n", net.net_sel_mode, net.net_type, net.plmn);
+        int i = 0;
+        while(i < ARRAY_SIZE(operator_mcc_mnc))
+        {
+            if(operator_mcc_mnc[i].mcc_mnc == net.plmn)
+                break;
+            i++;
+        }
+
+        if(i == ARRAY_SIZE(operator_mcc_mnc))   // No found mcc&mnc
+        {
+            strcpy(OperatorFN, "UNKNOWN");
+            strcpy(OperatorSH, "UNKNOWN");
+            sprintf(MccMnc, "%d", net.plmn);
+        }
+        else
+        {
+            strcpy(OperatorFN, operator_mcc_mnc[i].operator_l);
+            strcpy(OperatorSH, operator_mcc_mnc[i].operator_s);
+            sprintf(MccMnc, "%d", operator_mcc_mnc[i].mcc_mnc);
+        }
+        memset(pt_info->long_eons,0,128);
+        memcpy(pt_info->long_eons,operator_mcc_mnc[i].operator_l,strlen(operator_mcc_mnc[i].operator_l));
+        memset(pt_info->short_eons,0,128);
+        memcpy(pt_info->short_eons,operator_mcc_mnc[i].operator_s,strlen(operator_mcc_mnc[i].operator_s));
+        memset(pt_info->mcc,0,4);
+        memset(pt_info->mnc,0,4);
+        sprintf(pt_info->mcc, "%d", (operator_mcc_mnc[i].mcc_mnc)/100);
+        if(0 == operator_mcc_mnc[i].mcc_mnc % 100)
+        {
+            strcpy(pt_info->mnc, "00");   
+        }
+        else
+        {
+            sprintf(pt_info->mnc, "%d", (operator_mcc_mnc[i].mcc_mnc)%100);
+        }
+        //pt_info->act;
+        return QL_NW_SUCCESS;
+    }
+
+    return QL_NW_GENERIC_FAILURE;
+}
+
+QL_NW_ERROR_CODE ql_nw_perform_scan(QL_NW_SCAN_RESULT_LIST_INFO_T *pt_info)
+{
+    if(ql_info_handle == NULL || pt_info == NULL)
+    {
+        LOGE("ARG error.");
+        return -1;
+    }
+	list_node_t* net_list = NULL;
+    int ret = mbtk_available_net_get(ql_info_handle, &net_list);
+    if(ret != 0)
+    {
+        LOGE("mbtk_available_net_get fail.");
+        return QL_NW_GENERIC_FAILURE;
+    }
+    else
+    {
+        memset(pt_info, 0x0, sizeof(QL_NW_SCAN_RESULT_LIST_INFO_T));
+        mbtk_net_info_t* net = NULL;
+		list_first(net_list);
+        int i=0;
+        while ((net = (mbtk_net_info_t*) list_next(net_list)))
+        {
+            //printf("Net : %d, %d, %d, %d\n", net->net_sel_mode, net->net_type, net->net_state, net->plmn);
+            if(net->net_state == 8)
+                pt_info->entry[i].status = QL_NW_ACCESS_TECH_E_UTRAN_CA;
+            else if(net->net_state == 0xff)
+                pt_info->entry[i].status = QL_NW_ACCESS_TECH_NONE;
+            else
+                pt_info->entry[i].status = net->net_state;
+
+            int j = 0;
+            while(j < ARRAY_SIZE(operator_mcc_mnc))
+            {
+                if(operator_mcc_mnc[j].mcc_mnc == net->plmn)
+                    break;
+                j++;
+            }
+            if(j == ARRAY_SIZE(operator_mcc_mnc))   // No found mcc&mnc
+            {
+                strcpy(pt_info->entry[i].operator_name.long_eons, "UNKNOWN");
+                strcpy(pt_info->entry[i].operator_name.short_eons, "UNKNOWN");
+                sprintf(pt_info->entry[i].operator_name.mcc, "%d", (net->plmn)/100);
+                sprintf(pt_info->entry[i].operator_name.mnc, "%d", (net->plmn)%100);
+            }
+            else
+            {
+                strcpy(pt_info->entry[i].operator_name.long_eons, operator_mcc_mnc[j].operator_l);
+                strcpy(pt_info->entry[i].operator_name.short_eons, operator_mcc_mnc[j].operator_s);
+                sprintf(pt_info->entry[i].operator_name.mcc, "%d", (net->plmn)/100);
+                sprintf(pt_info->entry[i].operator_name.mnc, "%d", (net->plmn)%100);
+            }
+            pt_info->entry[i].operator_name ;
+            pt_info->entry[i].act = net->net_type;
+            i++;
+            if(i > 40)
+                break;
+        }
+        pt_info->entry_len = i;
+        list_free(net_list);
+        return QL_NW_SUCCESS;
+    }
+}
+
+#if 0
+static int ql_query_registration_state(const char *type, int* regState,int *imsRegState,int * LAC, int *CID,int *netType,int * radioTechFam,int *netRejected)
+{
+    if(ql_info_handle == NULL || str_empty(type) || regState == NULL || imsRegState == NULL
+        || LAC == NULL || CID == NULL || netType == NULL || radioTechFam == NULL || netRejected == NULL)
+    {
+        return -1;
+    }
+    mbtk_net_reg_info_t reg;
+    int err = mbtk_net_reg_get(ql_info_handle, &reg);
+    if(err) {
+        *netRejected = err;
+        return -1;
+    } else {
+        //printf("REG : %d, %d, %d, %04x, %08o\n", reg.state, reg.type, reg.ims_reg, reg.lac, reg.ci);
+        // Voice/Data/IMS
+        if(strcmp("VOICE", type) == 0) {
+            *regState = reg.call_state;
+        } else if(strcmp("DATA", type) == 0) {
+            *regState = reg.data_state;
+        } else if(strcmp("IMS", type) == 0) {
+            *imsRegState = reg.ims_state;
+        } else {
+            return -1;
+        }
+
+        if(reg.call_state != MBTK_NET_REG_STATE_NON || reg.data_state != MBTK_NET_REG_STATE_NON || reg.ims_state != MBTK_NET_REG_STATE_NON) {
+            sprintf(LAC, "%04x", reg.lac);
+            sprintf(CID, "%08o", reg.ci);
+            *netType = reg.type;
+            *radioTechFam = RADIO_TECH_3GPP;
+        }
+        return 0;
+    }
+
+}
+#endif
+
+QL_NW_ERROR_CODE ql_nw_get_reg_status(QL_NW_REG_STATUS_INFO_T *pt_info)
+{
+    if(ql_info_handle == NULL || pt_info == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_NW_GENERIC_FAILURE;
+    }
+    /*VOICE/DATA/IMS*/
+    mbtk_net_reg_info_t reg;
+    int err = mbtk_net_reg_get(ql_info_handle, &reg);
+    if(err) {
+        LOGE("mbtk_net_reg_get fail.");
+        return QL_NW_GENERIC_FAILURE;
+    } else {
+        memset(pt_info, 0x0, sizeof(QL_NW_REG_STATUS_INFO_T));
+        pt_info->data_reg.state = (QL_NW_REG_STATE)reg.data_state;
+        pt_info->data_reg.lac = reg.lac;
+        pt_info->data_reg.cid = reg.ci;
+        pt_info->voice_reg.state = (QL_NW_REG_STATE)reg.call_state;
+        pt_info->voice_reg.lac = reg.lac;
+        pt_info->voice_reg.cid = reg.ci;
+        switch(reg.type)
+        {
+            case MBTK_RADIO_TECH_GSM:
+            case MBTK_RADIO_TECH_GSM_COMPACT:
+            case MBTK_RADIO_TECH_GSM_EGPRS:
+            case MBTK_RADIO_TECH_UTRAN_HSPA:
+            {
+                pt_info->data_reg.rat = QL_NW_RADIO_TECH_GPRS;
+                pt_info->voice_reg.rat = QL_NW_RADIO_TECH_GSM;
+                break;
+            }
+            case MBTK_RADIO_TECH_UTRAN:
+            case MBTK_RADIO_TECH_UTRAN_HSDPA:
+            case MBTK_RADIO_TECH_UTRAN_HSUPA:
+            case MBTK_RADIO_TECH_UTRAN_HSDPA_HSUPA:
+            {
+                pt_info->data_reg.rat = QL_NW_RADIO_TECH_UMTS;
+                pt_info->voice_reg.rat = QL_NW_RADIO_TECH_UMTS;
+                break;
+            }
+            case MBTK_RADIO_TECH_E_UTRAN:
+            {
+                pt_info->data_reg.rat = QL_NW_RADIO_TECH_LTE;
+                pt_info->voice_reg.rat = QL_NW_RADIO_TECH_LTE;
+                break;
+            }
+            default:
+            {
+                pt_info->data_reg.rat = QL_NW_RADIO_TECH_UNKNOWN;
+                pt_info->voice_reg.rat = QL_NW_RADIO_TECH_UNKNOWN;
+                break;
+            }
+        }
+    }
+
+    return 0;
+
+#if 0
+    int ret = ql_query_registration_state("VOICE", &(pt_info->voice_reg.state), &imsRegState, &(pt_info->voice_reg.lac), &(pt_info->voice_reg.cid), &netType, &(pt_info->voice_reg.rejectCause), &netRejected);
+    if(ret != 0)
+        err = QL_NW_GENERIC_FAILURE;
+    else
+        err = QL_NW_SUCCESS;
+    ret = ql_query_registration_state("DATA", &(pt_info->data_reg.state), &imsRegState, &(pt_info->data_reg.lac), &(pt_info->data_reg.cid), &netType, &(pt_info->data_reg.rejectCause), &netRejected);
+    if(ret != 0)
+        err =  QL_NW_GENERIC_FAILURE;
+    else
+        err = QL_NW_SUCCESS;
+
+    if(err == QL_NW_SUCCESS)
+    {
+        if(netType < 0 || netType > 8)
+            pt_info->data_reg.rat = QL_NW_ACCESS_TECH_NONE;
+        else
+            pt_info->data_reg.rat = netType;
+    }
+    return err;
+#endif
+}
+
+QL_NW_ERROR_CODE ql_nw_set_selection(QL_NW_SELECTION_INFO_T *pt_info)
+{
+    if(ql_info_handle == NULL || pt_info == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_NW_GENERIC_FAILURE;
+    }
+
+    mbtk_net_info_t net;
+    net.net_type = 0xFF;
+    char mccmnc[10];
+    if(pt_info->nw_selection_mode == 0)
+    {
+        net.net_sel_mode = 0;
+        net.plmn = 0;
+    }
+    else if(pt_info->nw_selection_mode == 1 && !str_empty(pt_info->mnc) && !str_empty(pt_info->mcc))
+    {
+        net.net_sel_mode = 1;
+        memset(mccmnc, 0, 10);
+        //memcpy(mccmnc, pt_info->mcc, 3);
+        //memcpy(mccmnc + 3, pt_info->mnc, 3);
+        sprintf(mccmnc,"%s%s",pt_info->mcc,pt_info->mnc);
+        net.plmn = (uint32)atoi(mccmnc);
+        if(pt_info->act < QL_NW_ACCESS_TECH_GSM || pt_info->act > QL_NW_ACCESS_TECH_UTRAN_HSPAP)
+            net.net_type = 0xff;
+        else
+            net.net_type = pt_info->act;
+    }
+    else
+    {
+        LOGE("ARG error.");
+        return QL_NW_GENERIC_FAILURE;
+    }
+    //printf("mccmnc = %s\n",mccmnc);
+    //printf("net.plmn = %d\n",net.plmn);
+    int ret = mbtk_net_sel_mode_set(ql_info_handle, &net);
+    if(ret == 0)
+    {
+        return QL_NW_SUCCESS;
+    }
+    else
+    {
+        printf("mbtk_net_sel_mode_set error: %d\n",ret );
+        return QL_NW_GENERIC_FAILURE;
+    }
+}
+
+QL_NW_ERROR_CODE ql_nw_get_selection(QL_NW_SELECTION_INFO_T *pt_info)
+{
+    if(ql_info_handle == NULL || pt_info == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_NW_GENERIC_FAILURE;
+    }
+    char OperatorFN[128];
+    char OperatorSH[128];
+    char MccMnc[128];
+    mbtk_net_info_t net;
+    if(!mbtk_net_sel_mode_get(ql_info_handle, &net) && net.plmn > 0)
+    {
+        memset(pt_info, 0x0, sizeof(QL_NW_SELECTION_INFO_T));
+        // printf("Net : %d, %d, %d\n", net.net_sel_mode, net.net_type, net.plmn);
+        int i = 0;
+        while(i < ARRAY_SIZE(operator_mcc_mnc))
+        {
+            if(operator_mcc_mnc[i].mcc_mnc == net.plmn)
+                break;
+            i++;
+        }
+        if(i == ARRAY_SIZE(operator_mcc_mnc))   // No found mcc&mnc
+        {
+            strcpy(OperatorFN, "UNKNOWN");
+            strcpy(OperatorSH, "UNKNOWN");
+            sprintf(MccMnc, "%d", net.plmn);
+        }
+        else
+        {
+            strcpy(OperatorFN, operator_mcc_mnc[i].operator_l);
+            strcpy(OperatorSH, operator_mcc_mnc[i].operator_s);
+            sprintf(MccMnc, "%d", operator_mcc_mnc[i].mcc_mnc);
+
+            sprintf(pt_info->mcc,"%d",operator_mcc_mnc[i].mcc_mnc/100);
+            sprintf(pt_info->mnc,"%d",operator_mcc_mnc[i].mcc_mnc%100);
+
+        }
+        pt_info->nw_selection_mode = net.net_sel_mode;
+
+        pt_info->act = net.net_type;
+        return QL_NW_SUCCESS;
+    }
+
+    return QL_NW_GENERIC_FAILURE;
+
+}
+
+QL_NW_ERROR_CODE ql_nw_get_signal_strength(QL_NW_SIGNAL_STRENGTH_INFO_T *pt_info)
+{
+    if(ql_info_handle == NULL || pt_info == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_NW_GENERIC_FAILURE;
+    }
+
+    int ret;
+    mbtk_signal_info_t signal;
+    ret = mbtk_net_signal_get(ql_info_handle, &signal);
+    if(ret != 0) {
+        LOGE("mbtk_net_signal_get fail.");
+        return QL_NW_GENERIC_FAILURE;
+    }
+    else
+    {
+        int rssi = 0;
+        if(SIGNAL_STRENGTH_INVALID_1 == signal.rssi)
+        {
+            rssi = SIGNAL_STRENGTH_INVALID_1;
+        }
+        else
+        {
+            rssi = 2 * signal.rssi - 113;
+        }
+        if(signal.type == MBTK_RADIO_TECH_GSM)              //GSM
+        {
+            pt_info->GW_SignalStrength.bitErrorRate = signal.ber;
+            pt_info->GW_SignalStrength.ecio = signal.ecno;
+            pt_info->GW_SignalStrength.rscp = signal.rscp;
+            pt_info->GW_SignalStrength.rssi = rssi;
+            
+            pt_info->LTE_SignalStrength.rsrp = SIGNAL_STRENGTH_INVALID_1;
+            pt_info->LTE_SignalStrength.rsrq = SIGNAL_STRENGTH_INVALID_1;
+            pt_info->LTE_SignalStrength.rssnr = SIGNAL_STRENGTH_INVALID_2;
+            pt_info->LTE_SignalStrength.rssi = SIGNAL_STRENGTH_INVALID_1;
+        }
+        else if(signal.type == MBTK_RADIO_TECH_E_UTRAN)     //LTE
+        {
+            pt_info->LTE_SignalStrength.cqi = SIGNAL_STRENGTH_INVALID_1;
+            pt_info->LTE_SignalStrength.rsrp = signal.rsrp;
+            pt_info->LTE_SignalStrength.rsrq = signal.rsrq;
+            pt_info->LTE_SignalStrength.rssnr = signal.ecno;
+            pt_info->LTE_SignalStrength.rssi = rssi;
+
+            pt_info->GW_SignalStrength.bitErrorRate = SIGNAL_STRENGTH_INVALID_1;
+            pt_info->GW_SignalStrength.ecio = SIGNAL_STRENGTH_INVALID_2;
+            pt_info->GW_SignalStrength.rscp = SIGNAL_STRENGTH_INVALID_2;
+            pt_info->GW_SignalStrength.rssi = SIGNAL_STRENGTH_INVALID_1;
+        }
+        else
+        {
+            return QL_NW_GENERIC_FAILURE;
+        }
+        LOGI("ql_GW_SignalStrength: %d , %d, %d, %d", pt_info->GW_SignalStrength.rssi, 
+            pt_info->GW_SignalStrength.bitErrorRate, pt_info->GW_SignalStrength.rscp, pt_info->GW_SignalStrength.ecio);
+        LOGI("ql_LTE_SignalStrength: %d , %d, %d, %d", pt_info->LTE_SignalStrength.rssi, 
+            pt_info->LTE_SignalStrength.rsrp, pt_info->LTE_SignalStrength.rsrq, pt_info->LTE_SignalStrength.rssnr, pt_info->LTE_SignalStrength.cqi);
+        return QL_NW_SUCCESS;
+    }
+}
+
+QL_NW_ERROR_CODE ql_nw_get_cell_info(QL_NW_CELL_INFO_T *pt_info)
+{
+    list_node_t* cell_list = NULL;
+    mbtk_cell_type_enum type;
+    if(ql_info_handle == NULL || pt_info == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_NW_GENERIC_FAILURE;
+    }
+
+    memset(pt_info, 0, sizeof(QL_NW_CELL_INFO_T));
+    int err = mbtk_cell_get(ql_info_handle, &type, &cell_list);
+    if(err || cell_list == NULL) {
+        LOGE("mbtk_cell_get fail.");
+        return QL_NW_GENERIC_FAILURE;
+    } else {
+        list_first(cell_list);
+        mbtk_cell_info_t* cell = (mbtk_cell_info_t*) list_next(cell_list);
+        if(cell) { // Current server cell.
+            switch(type)
+            {
+                case MBTK_CELL_TYPE_GSM:
+                {
+                    LOGD("GSM : lac=%d, ci=%d, arfcn=%d, bsic=%d", cell->value1, cell->value2, cell->value3, cell->value4);
+                    pt_info->gsm_info[0].lac = cell->value1;
+                    pt_info->gsm_info[0].cid = cell->value2;
+                    pt_info->gsm_info[0].arfcn = cell->value3;
+                    pt_info->gsm_info[0].bsic = cell->value4;
+                    pt_info->gsm_info[0].mcc = cell->value5;
+                    pt_info->gsm_info[0].mnc = cell->value6;
+                    pt_info->gsm_info[0].flag = 0;
+                    pt_info->gsm_info_num++;
+                    pt_info->gsm_info_valid = 1;
+                }
+                    break;
+                case MBTK_CELL_TYPE_UMTS:
+                {
+                    LOGD("UMTS : lac=%d, ci=%d, arfcn=%d", cell->value1, cell->value2, cell->value3);
+                    pt_info->umts_info[0].lac = cell->value1;
+                    pt_info->umts_info[0].cid = cell->value2;
+                    pt_info->umts_info[0].uarfcn = cell->value3;
+                    pt_info->umts_info[0].mcc = cell->value4;
+                    pt_info->umts_info[0].mnc = cell->value5;
+                    pt_info->umts_info[0].psc = cell->value6;
+                    pt_info->umts_info[0].flag = 0;
+                    pt_info->umts_info_num++;
+                    pt_info->umts_info_valid = 1;
+                }
+                    break;
+                case MBTK_CELL_TYPE_LTE:
+                {
+                    LOGD("LTE : tac=%d, PCI=%d, dlEuarfcn=%d, ulEuarfcn=%d, band=%d", cell->value1, cell->value2, cell->value3, cell->value4, cell->value5);
+                    pt_info->lte_info[0].tac = cell->value1;
+                    pt_info->lte_info[0].pci = cell->value2;
+                    pt_info->lte_info[0].earfcn = cell->value3;
+                    pt_info->lte_info[0].cid = cell->value8;
+                    pt_info->lte_info[0].mcc = cell->value6;
+                    pt_info->lte_info[0].mnc = cell->value7;
+                    pt_info->lte_info[0].flag = 0;
+                    pt_info->lte_info_num++;
+                    pt_info->lte_info_valid = 1;
+                    break;
+                }
+                default:
+                    break;
+            }
+        }
+        while ((cell = (mbtk_cell_info_t*) list_next(cell_list)))
+        {
+            switch(type)
+            {
+                case MBTK_CELL_TYPE_GSM:
+                {
+                    LOGD("CELL : %d, %d, %d, %d, %d", cell->value1, cell->value2, cell->value3, cell->value4, cell->value5);
+                    pt_info->gsm_info[pt_info->gsm_info_num].lac = cell->value1;
+                    pt_info->gsm_info[pt_info->gsm_info_num].cid = cell->value2;
+                    pt_info->gsm_info[pt_info->gsm_info_num].arfcn = cell->value3;
+                    pt_info->gsm_info[pt_info->gsm_info_num].bsic = cell->value4;
+                    pt_info->gsm_info[pt_info->gsm_info_num].flag = 1;
+                    pt_info->gsm_info_num++;
+                    pt_info->gsm_info_valid = 1;
+                }
+                    break;
+                case MBTK_CELL_TYPE_UMTS:
+                {
+                    LOGD("CELL : lac=%d, ci=%d, arfcn=%d", cell->value1, cell->value2, cell->value3);
+                    pt_info->umts_info[pt_info->umts_info_num].lac = cell->value1;
+                    pt_info->umts_info[pt_info->umts_info_num].cid = cell->value2;
+                    pt_info->umts_info[pt_info->umts_info_num].uarfcn = cell->value3;
+                    pt_info->umts_info[pt_info->umts_info_num].flag = 1;
+                    pt_info->umts_info_num++;
+                    pt_info->umts_info_valid = 1;
+                }
+                    break;
+                case MBTK_CELL_TYPE_LTE:
+                {
+                    LOGD("CELL : phyCellId=%d, euArfcn=%d, rsrp=%d, rsrq=%d", cell->value1, cell->value2, cell->value3, cell->value4);
+                    pt_info->lte_info[pt_info->lte_info_num].cid = cell->value1;
+                    pt_info->lte_info[pt_info->lte_info_num].earfcn = cell->value2;
+                    pt_info->lte_info[pt_info->lte_info_num].tac = cell->value3;
+                    pt_info->lte_info[pt_info->lte_info_num].pci = cell->value4;
+                    pt_info->lte_info[pt_info->lte_info_num].flag = 1;
+                    pt_info->lte_info_num++;
+                    pt_info->lte_info_valid = 1;
+                }
+                    break;
+                default:
+                    break;
+            }
+        }
+        list_free(cell_list);
+    }
+
+    LOGD("get_cell_success: %d, %d, %d.",pt_info->gsm_info_valid, pt_info->umts_info_valid, pt_info->lte_info_valid);
+    return QL_NW_SUCCESS;
+}
+
+QL_NW_ERROR_CODE ql_nw_add_event_handler(QL_NW_EventHandlerFunc_t handlerPtr,void* contextPtr)
+{
+    if(ql_info_handle == NULL || handlerPtr == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_NW_GENERIC_FAILURE;
+    }
+    mbtk_net_state_change_cb_reg(ql_info_handle, ql_nw_state_change_cb);
+    ql_func_cb_handle.handlerPtr = handlerPtr;
+    ql_func_cb_handle.contextPtr = contextPtr;
+    return QL_NW_SUCCESS;
+}
+
+QL_NW_ERROR_CODE ql_nw_get_volte_state(VOLTE_STATE *state)
+{
+    int ret;
+    if(ql_info_handle == NULL || state == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_NW_GENERIC_FAILURE;
+    }
+    ret = mbtk_volte_state_get(ql_info_handle, &(state->reg_state));
+    if(ret != 0)
+        return QL_NW_GENERIC_FAILURE;
+    else
+        return QL_NW_SUCCESS;
+}
+
+QL_NW_ERROR_CODE ql_nw_csq_get_signal_strength(QL_NW_CSQ_SIGNAL_STRENGTH_INFO_T *pt_info)
+{
+    int ret;
+    if(ql_info_handle == NULL || pt_info == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_NW_GENERIC_FAILURE;
+    }
+    mbtk_signal_info_t signal;
+    ret = mbtk_net_signal_get(ql_info_handle, &signal);
+    if(ret != 0)
+        return QL_NW_GENERIC_FAILURE;
+    else
+    {
+        pt_info->rssi = (signal.rssi * 2 - 113);
+        pt_info->bitErrorRate = signal.ber;
+        LOGD("pt_info->rssi = %d  pt_info->bitErrorRate = %d",pt_info->rssi,pt_info->bitErrorRate);
+        return QL_NW_SUCCESS;
+    }
+}
+
+//*********************************************************************************
+
diff --git a/mbtk/libql_lib_v2/src/ql_quec_sim.c b/mbtk/libql_lib_v2/src/ql_quec_sim.c
new file mode 100755
index 0000000..edcef9a
--- /dev/null
+++ b/mbtk/libql_lib_v2/src/ql_quec_sim.c
@@ -0,0 +1,406 @@
+#include "ql/ql_sim.h"
+#include "mbtk_type.h"
+#include "mbtk_info_api.h"
+
+extern mbtk_info_handle_t* ql_info_handle;
+extern int ql_info_handle_num;
+static bool inited = FALSE;
+
+QL_SIM_CardStatusIndMsgHandlerFunc_t handlerPtr_cb = NULL;
+
+typedef struct
+{
+    uint8 *operator_l;
+    uint8 *operator_s;
+    uint32 mcc_mnc;
+} operator_mcc_mnc_t;
+
+static operator_mcc_mnc_t operator_mcc_mnc[] =
+{
+    {"China Mobile","CMCC",46000},
+    {"China Unicom","CU",46001},
+    {"China Mobile","CMCC",46002},
+    {"China Telecom","CT",46003},
+    {"China Mobile","CMCC",46004},
+    {"China Telecom","CT",46005},
+    {"China Unicom","CU",46006},
+    {"China Mobile","CMCC",46007},
+    {"China Mobile","CMCC",46008},
+    {"China Unicom","CU",46009},
+    {"China Telecom","CT",46011}
+};
+
+void ql_sim_state_change_cb(const void* data, int data_len)
+{
+    if(handlerPtr_cb != NULL)
+    {
+        //QL_SIM_NFY_MSG_ID msg_id, void *pv_data, int pv_data_len, void *contextPtr
+        //handlerPtr_cb(net_data[2]);
+    }
+    mbtk_sim_card_info *info = NULL;
+    info = (mbtk_sim_card_info*)data;
+
+    QL_SIM_CARD_STATUS_INFO sim_card_info = {0};
+    sim_card_info.card_state = info->sim;
+    sim_card_info.card_type = info->sim_card_type;
+    /*
+        sim_client_handle_type  h_sim,
+        E_QL_SIM_NFY_MSG_ID_T   e_msg_id,
+        void                    *pv_data,
+        void                    *contextPtr
+    */
+    handlerPtr_cb(QL_SIM_CARD_STATUS_UPDATE_EVENT, &sim_card_info, sizeof(QL_SIM_CARD_STATUS_INFO), NULL);
+}
+
+QL_SIM_ERROR_CODE ql_sim_init()
+{
+    if(!inited && ql_info_handle == NULL)
+    {
+        ql_info_handle = mbtk_info_handle_get();
+        if(ql_info_handle)
+        {
+            ql_info_handle_num++;
+            inited = TRUE;
+            return QL_SIM_SUCCESS;
+        } else {
+            LOGE("mbtk_info_handle_get() fail.");
+            return QL_SIM_GENERIC_FAILURE;
+        }
+    } else {
+        if(!inited) {
+            ql_info_handle_num++;
+            inited = TRUE;
+        }
+        return QL_SIM_SUCCESS;
+    }
+}
+
+
+QL_SIM_ERROR_CODE ql_sim_release()
+{
+    if(ql_info_handle)
+    {
+        LOGD("ql_info_handle_num = %d", ql_info_handle_num);
+        if(ql_info_handle_num == 1) { // 最后一个引用，可释放。
+            int ret = mbtk_info_handle_free(&ql_info_handle);
+            if(ret) {
+                LOGE("mbtk_info_handle_free() fail.");
+                return QL_SIM_GENERIC_FAILURE;
+            }
+            else
+            {
+                ql_info_handle_num = 0;
+                ql_info_handle = NULL;
+                return QL_SIM_SUCCESS;
+            }
+        } else {
+            ql_info_handle_num--;
+            return QL_SIM_SUCCESS;
+        }
+    }
+    else
+    {
+        LOGE("Sim handle not inited.");
+        return QL_SIM_GENERIC_FAILURE;
+    }
+}
+
+
+QL_SIM_ERROR_CODE ql_sim_get_imsi(uint8_t *imsi, size_t imsiLen)
+{
+    if(ql_info_handle == NULL || imsi == NULL || imsiLen <= 0)
+    {
+        LOGE("ARG error.");
+        return QL_SIM_GENERIC_FAILURE;
+    }
+    memset(imsi,0,imsiLen);
+    int err = mbtk_imsi_get(ql_info_handle, imsi);
+    if(err) {
+        return QL_SIM_GENERIC_FAILURE;
+    } else {
+        return QL_SIM_SUCCESS;
+    }
+}
+
+QL_SIM_ERROR_CODE ql_sim_get_iccid(uint8_t *iccid, size_t iccidLen)
+{
+    if(ql_info_handle == NULL || iccid == NULL || iccidLen <= 0)
+    {
+        LOGE("ARG error.");
+        return QL_SIM_GENERIC_FAILURE;
+    }
+    memset(iccid, 0, iccidLen);
+    int err = mbtk_iccid_get(ql_info_handle, iccid);
+    if(err) {
+        return QL_SIM_GENERIC_FAILURE;
+    } else {
+        return QL_SIM_SUCCESS;
+    }
+}
+
+QL_SIM_ERROR_CODE ql_sim_get_phonenumber(uint8_t *phone_num, size_t phoneLen)
+{
+    if(ql_info_handle == NULL || phone_num == NULL || phoneLen <= 0)
+    {
+        LOGE("ARG error.");
+        return QL_SIM_GENERIC_FAILURE;
+    }
+    memset(phone_num, 0, phoneLen);
+    int err = mbtk_phone_number_get(ql_info_handle, phone_num);
+    if(err) {
+        return QL_SIM_GENERIC_FAILURE;
+    } else {
+        return QL_SIM_SUCCESS;
+    }
+}
+
+QL_SIM_ERROR_CODE ql_sim_get_operator_plmn_list(QL_SIM_PREFERRED_OPERATOR_LIST *pt_info)
+{
+    if(ql_info_handle == NULL || pt_info == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_SIM_GENERIC_FAILURE;
+    }
+
+    mbtk_plmn_info plmn;
+    int err = mbtk_get_plmn_list(ql_info_handle, &plmn);
+    if(err) {
+        LOGE("mbtk_get_plmn_list file : %d",err);
+        return QL_SIM_GENERIC_FAILURE;
+    } else {
+        memset(pt_info, 0x0, sizeof(QL_SIM_PREFERRED_OPERATOR_LIST));
+        pt_info->preferred_operator_list_num = plmn.count;
+        int list_count;
+        for(list_count = 0; list_count < plmn.count; list_count++)
+        {
+            if(plmn.mbtk_plmn_name[list_count].format == 2)    //number
+            {
+                uint32 plmn_name = (uint32)atoi(plmn.mbtk_plmn_name[list_count].plmn_name);
+                sprintf(pt_info->preferred_operator_list[list_count].mcc,"%d",plmn_name/100);
+                sprintf(pt_info->preferred_operator_list[list_count].mnc,"%02d",plmn_name%100);
+            }
+            else if(plmn.mbtk_plmn_name[list_count].format == 0)
+            {
+                int i = 0;
+                while(i < ARRAY_SIZE(operator_mcc_mnc))
+                {
+                    if(!strcmp(operator_mcc_mnc[i].operator_l,plmn.mbtk_plmn_name))
+                        break;
+                    i++;
+                }
+
+                if(i == ARRAY_SIZE(operator_mcc_mnc))   // No found mcc&mnc
+                {
+                    memcpy(pt_info->preferred_operator_list[list_count].mcc,0,3);
+                    memcpy(pt_info->preferred_operator_list[list_count].mnc,0,3);
+                }
+                else
+                {
+                    sprintf(pt_info->preferred_operator_list[list_count].mcc, "%d", (operator_mcc_mnc[i].mcc_mnc)/100);
+                    sprintf(pt_info->preferred_operator_list[list_count].mnc, "%d", (operator_mcc_mnc[i].mcc_mnc)%100);
+                }
+            }
+            else
+            {
+                int i = 0;
+                while(i < ARRAY_SIZE(operator_mcc_mnc))
+                {
+                    if(!strcmp(operator_mcc_mnc[i].operator_s,plmn.mbtk_plmn_name))
+                        break;
+                    i++;
+                }
+
+                if(i == ARRAY_SIZE(operator_mcc_mnc))   // No found mcc&mnc
+                {
+                    memcpy(pt_info->preferred_operator_list[list_count].mcc,0,3);
+                    memcpy(pt_info->preferred_operator_list[list_count].mnc,0,3);
+                }
+                else
+                {
+                    sprintf(pt_info->preferred_operator_list[list_count].mcc, "%d", (operator_mcc_mnc[i].mcc_mnc)/100);
+                    sprintf(pt_info->preferred_operator_list[list_count].mnc, "%d", (operator_mcc_mnc[i].mcc_mnc)%100);
+                }
+            }
+        }
+        int i;
+        for (i=0;i<pt_info->preferred_operator_list_num;i++)
+        {
+            LOGD("pt_info->preferred_operator_list[%d].mcc=%s",i, pt_info->preferred_operator_list[i].mcc);
+            LOGD("pt_info->preferred_operator_list[%d].mnc=%s",i, pt_info->preferred_operator_list[i].mnc);
+        }
+        return QL_SIM_SUCCESS;
+    }
+}
+
+QL_SIM_ERROR_CODE ql_sim_verify_pin(QL_SIM_VERIFY_PIN_INFO *pt_info)
+{
+    if(ql_info_handle == NULL || pt_info == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_SIM_GENERIC_FAILURE;
+    }
+
+    int err = mbtk_verify_pin(ql_info_handle, pt_info->pin_value);
+    if(err) {
+        LOGE("mbtk_verify_pin fail : %d",err);
+        return QL_SIM_GENERIC_FAILURE;
+    } else {
+        return QL_SIM_SUCCESS;
+    }
+}
+
+QL_SIM_ERROR_CODE ql_sim_change_pin(QL_SIM_CHANGE_PIN_INFO *pt_info)
+{
+    if(ql_info_handle == NULL || pt_info == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_SIM_GENERIC_FAILURE;
+    }
+    mbtk_change_pin_info pin_info = {0};
+    memcpy(pin_info.old_pin_value, pt_info->old_pin_value, strlen(pt_info->old_pin_value));
+    memcpy(pin_info.new_pin_value, pt_info->new_pin_value, strlen(pt_info->new_pin_value));
+    int err = mbtk_change_pin(ql_info_handle, &pin_info);
+    if(err) {
+        LOGE("mbtk_change_pin fail : %d",err);
+        return QL_SIM_GENERIC_FAILURE;
+    } else {
+        return QL_SIM_SUCCESS;
+    }
+}
+
+QL_SIM_ERROR_CODE ql_sim_unblock_pin(QL_SIM_UNBLOCK_PIN_INFO *pt_info)
+{
+    if(ql_info_handle == NULL || pt_info == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_SIM_GENERIC_FAILURE;
+    }
+    mbtk_unlock_pin_info puk_pin_info = {0};
+    memcpy(puk_pin_info.pin_value, pt_info->new_pin_value, strlen(pt_info->new_pin_value));
+    memcpy(puk_pin_info.puk_value, pt_info->puk_value, strlen(pt_info->puk_value));
+    int err = mbtk_unlock_pin(ql_info_handle, &puk_pin_info);
+    if(err) {
+        LOGE("mbtk_unlock_pin fail : %d",err);
+        return QL_SIM_GENERIC_FAILURE;
+    } else {
+        return QL_SIM_SUCCESS;
+    }
+}
+
+QL_SIM_ERROR_CODE ql_sim_enable_pin(QL_SIM_VERIFY_PIN_INFO *pt_info)
+{
+    if(ql_info_handle == NULL || pt_info == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_SIM_GENERIC_FAILURE;
+    }
+    mbtk_enable_pin_info pin_info = {0};
+    memcpy(pin_info.pin_value, pt_info->pin_value, strlen(pt_info->pin_value));
+    pin_info.enable = 1;
+    int err = mbtk_enable_pin(ql_info_handle, &pin_info);
+    if(err) {
+        LOGE("mbtk_enable_pin fail : %d",err);
+        return QL_SIM_GENERIC_FAILURE;
+    } else {
+        return QL_SIM_SUCCESS;
+    }
+}
+
+QL_SIM_ERROR_CODE ql_sim_disable_pin(QL_SIM_VERIFY_PIN_INFO *pt_info)
+{
+    if(ql_info_handle == NULL || pt_info == NULL)
+    {
+        LOGE("ARG error.");
+        return QL_SIM_GENERIC_FAILURE;
+    }
+    mbtk_enable_pin_info pin_info = {0};
+    memcpy(pin_info.pin_value, pt_info->pin_value, strlen(pt_info->pin_value));
+    pin_info.enable = 0;
+    int err = mbtk_enable_pin(ql_info_handle, &pin_info);
+    if(err) {
+        LOGE("ql_sim_disable_pin fail : %d",err);
+        return QL_SIM_GENERIC_FAILURE;
+    } else {
+        return QL_SIM_SUCCESS;
+    }
+}
+
+QL_SIM_ERROR_CODE ql_sim_get_card_status(QL_SIM_CARD_STATUS_INFO *pt_info)
+{
+    if(ql_info_handle == NULL || pt_info == NULL)
+    {
+        LOGE("sim not init.");
+        return QL_SIM_GENERIC_FAILURE;
+    }
+
+    mbtk_sim_state_enum sim;
+    mbtk_sim_card_type_enum sim_card_type;
+    mbtk_pin_puk_last_times ql_last_times = {0};
+    int err = mbtk_sim_state_get(ql_info_handle, &sim);
+    LOGD("mbtk_sim_state_get - %d");
+    if(err) {
+        return QL_SIM_GENERIC_FAILURE;
+    } else {
+        memset(pt_info, 0x0, sizeof(QL_SIM_CARD_STATUS_INFO));
+        pt_info->card_state = sim;
+        switch (sim)
+        {
+            case 0:                     //ABSENT
+                pt_info->card_state = QL_SIM_STAT_NOT_INSERTED;
+                break;
+            case 1:                     //NOT READY
+                pt_info->card_state = QL_SIM_STAT_UNKNOWN;
+                break;
+            case 2:                     //READY
+                pt_info->card_state = QL_SIM_STAT_READY;
+                break;
+            case 3:                     //SIM PIN
+                pt_info->card_state = QL_SIM_STAT_SIM_PIN;
+                break;
+            case 4:                     //SIM PUK
+                pt_info->card_state = QL_SIM_STAT_SIM_PUK;
+                break;
+            case 5:                     //NETWORK
+                pt_info->card_state = QL_SIM_STAT_UNKNOWN;
+                break;
+            default:
+                pt_info->card_state = QL_SIM_STAT_UNKNOWN;
+                break;
+        }
+    }
+    err = mbtk_sim_card_type_get(ql_info_handle, &sim_card_type);
+    LOGD("mbtk_sim_card_type_get - %d", err);
+    if(err) {
+        return QL_SIM_GENERIC_FAILURE;
+    } else {
+        if(sim_card_type == 0 || sim_card_type == 2)
+            pt_info->card_type = QL_SIM_CARD_TYPE_ICC;
+        else if(sim_card_type == 1 || sim_card_type == 3)
+            pt_info->card_type = QL_SIM_CARD_TYPE_UICC;
+        else
+            pt_info->card_type = QL_SIM_CARD_TYPE_UNKNOWN;
+    }
+    err = mbtk_pin_last_num_get(ql_info_handle, &ql_last_times);
+    LOGD("mbtk_pin_last_num_get - %d", err);
+    if(err) {
+        return QL_SIM_GENERIC_FAILURE;
+    } else {
+        pt_info->card_pin_info.pin1_num_retries = ql_last_times.p1_retry;
+        pt_info->card_pin_info.pin2_num_retries = ql_last_times.p2_retry;
+        pt_info->card_pin_info.puk1_num_retries = ql_last_times.puk1_retry;
+        pt_info->card_pin_info.puk2_num_retries = ql_last_times.puk2_retry;
+    }
+    return QL_SIM_SUCCESS;
+}
+
+QL_SIM_ERROR_CODE ql_sim_add_event_handler(QL_SIM_CardStatusIndMsgHandlerFunc_t handlerPtr, void* contextPtr)
+{
+    if(ql_info_handle == NULL || handlerPtr == NULL)
+    {
+        return QL_SIM_GENERIC_FAILURE;
+    }
+    handlerPtr_cb = handlerPtr;
+    mbtk_sim_state_change_cb_reg(ql_info_handle, ql_sim_state_change_cb);
+    return QL_SIM_SUCCESS;
+}
+
diff --git a/mbtk/libql_lib_v2/src/ql_sleep_wakelock.c b/mbtk/libql_lib_v2/src/ql_sleep_wakelock.c
new file mode 100755
index 0000000..03f356c
--- /dev/null
+++ b/mbtk/libql_lib_v2/src/ql_sleep_wakelock.c
@@ -0,0 +1,161 @@
+/*
+*
+* Data : 2023/03/28 16:00:28
+* Author : Hanzhiyu
+*
+*/
+#include "ql/ql_sleep_wakelock.h"
+#include <stdio.h>
+#include <unistd.h>
+#include <stddef.h>
+#include "mbtk_type.h"
+#include "mbtk_log.h"
+
+typedef struct
+{
+    int fd;
+    char name[128];
+} lock_name;
+
+lock_name ql_lock_name[512]={0};
+static bool autosleep_enable = FALSE;
+
+extern int Ql_Autosleep_Enable(char enable)
+{
+    if(enable == 1)
+    {
+        if(!access("/sys/power/autosleep", W_OK))
+        {
+            system("echo mem > /sys/power/autosleep");
+            autosleep_enable = TRUE;
+            return 0;
+        }
+        else
+        {
+            LOGE("/sys/power/autosleep can not write.");
+            return -1;
+        }
+    }
+    else
+    {
+        if(!access("/sys/power/autosleep", W_OK))
+        {
+            system("echo off > /sys/power/autosleep");
+            autosleep_enable = FALSE;
+            return 0;
+        }
+        else
+        {
+            LOGE("/sys/power/autosleep can not write.");
+            return -1;
+        }
+    }
+}
+
+extern int Ql_SLP_WakeLock_Create(const char *name, size_t len)
+{
+    if(!autosleep_enable) {
+        LOGE("Autosleep not enable.");
+        return -1;
+    }
+
+    if(name != NULL && len < 127)
+    {
+        int i;
+        for(i=0;i<512;i++)
+        {
+            if(ql_lock_name[i].fd == 0)
+                break;
+        }
+        memcpy(ql_lock_name[i].name, name, strlen(name)+1);
+        ql_lock_name[i].fd = i;
+        return ql_lock_name[i].fd;
+    }
+    else
+        return -1;
+}
+
+extern int Ql_SLP_WakeLock_Lock(int fd)
+{
+    if(!autosleep_enable) {
+        LOGE("Autosleep not enable.");
+        return -1;
+    }
+
+    int i;
+    for(i=0;i<512;i++)
+    {
+        if(ql_lock_name[i].fd == fd)
+            break;
+    }
+    if(i == 512)
+        return -1;
+
+    if(!access("/sys/power/wake_lock", W_OK))
+    {
+        char cmd[128]={0};
+        sprintf(cmd, "echo %s > /sys/power/wake_lock", ql_lock_name[i].name);
+        system(cmd);
+        return 0;
+    }
+    else
+    {
+        printf("/sys/power/wake_lock can not write.");
+        return -1;
+    }
+}
+
+extern int Ql_SLP_WakeLock_Unlock(int fd)
+{
+    if(!autosleep_enable) {
+        LOGE("Autosleep not enable.");
+        return -1;
+    }
+
+    int i;
+    for(i=0;i<512;i++)
+    {
+        if(ql_lock_name[i].fd == fd)
+            break;
+    }
+    if(i == 512)
+        return -1;
+
+    if(!access("/sys/power/wake_unlock", W_OK))
+    {
+        char cmd[128]={0};
+        sprintf(cmd, "echo %s > /sys/power/wake_unlock", ql_lock_name[i].name);
+        system(cmd);
+        return 0;
+    }
+    else
+    {
+        printf("/sys/power/wake_unlock can not write.");
+        return -1;
+    }
+
+}
+
+extern int Ql_SLP_WakeLock_Destroy(int fd)
+{
+    if(!autosleep_enable) {
+        LOGE("Autosleep not enable.");
+        return -1;
+    }
+
+    int i;
+    for(i=0;i<512;i++)
+    {
+        if(ql_lock_name[i].fd == fd)
+        break;
+    }
+    if(i == 512)
+        return -1;
+    else
+    {
+        ql_lock_name[i].fd = 0;
+        memset(ql_lock_name[i].name, 0, 128);
+        return 0;
+    }
+}
+
diff --git a/mbtk/libql_lib_v2/src/ql_sms.c b/mbtk/libql_lib_v2/src/ql_sms.c
new file mode 100755
index 0000000..cbad623
--- /dev/null
+++ b/mbtk/libql_lib_v2/src/ql_sms.c
@@ -0,0 +1,493 @@
+//#include "lynq/lynq_sms_api.h"
+#include "mbtk_info_api.h"
+#include "mbtk_pdu_sms.h"
+#include "ql/ql_sms.h"
+
+
+#include <stdio.h>
+#include <stdlib.h>
+
+
+#define TELEPHONE_NUM_MAX 16
+#define MSM_NUMBER_MAX 1024+1
+#define RES_NUM_MIN 128
+
+#define DSC_to_msg(DSC) (DSC == 0 ? "Bit7" : (DSC == 1 ? "Bit8" : "UCS2"))
+
+static mbtk_info_handle_t* info_handle = NULL;
+static char center_address[15] = {0};
+
+
+// 编码后短信
+
+#if 0
+struct PDUS {
+    unsigned int count;
+    char **PDU;
+};
+#endif
+
+void lynq_sms_state_change_cb(const void* data, int data_len)
+{
+	LOGV("sms_state_change_cb()----------start\n");
+	uint8 *ptr = (uint8*)data;
+		printf("3sms_state_change_cb() : %s\n", ptr);
+
+	struct SMS_Struct s = PDUDecoding(ptr);
+	printf("服务中心地址: %s\n", s.SCA);
+	printf("发送方地址: %s\n", s.OA);
+	printf("服务中心时间戳: %s\n", s.SCTS);
+	printf("消息内容: %s\n", s.UD);
+	printf("数据编码方案： %s\n", DSC_to_msg(s.DCS));
+}
+
+
+QL_SMS_ERROR_CODE ql_sms_init()
+{
+    if(info_handle == NULL)
+    {
+        info_handle = mbtk_info_handle_get();
+        if(info_handle)
+        {
+			printf("creat info_handle is success\n");
+        }
+		else{
+			printf("creat info_handle is fail\n");
+			return QL_SMS_GENERIC_FAILURE;
+		}
+    }
+
+    return QL_SMS_SUCCESS;
+}
+
+
+QL_SMS_ERROR_CODE ql_sms_release()
+{
+    int ret = QL_SMS_SUCCESS;
+    if(info_handle)
+    {
+        ret = mbtk_info_handle_free(&info_handle);
+    }
+    else
+    {
+        ret = QL_SMS_GENERIC_FAILURE;
+    }
+
+    return ret;
+}
+
+
+/*
+*AT+CMGS="10086", CMGS TEST 				  // Send a SMS
+> CMGS TEST
++CMGS: 17
+OK
+*/
+/*
+int charset: send sms mode
+	 0:pdu, 1:text
+
+*/
+//当state 设置为 0（pdu）模式时，telephony_num应该设置为pud 数据大小的长度；msg：为pud 数据
+
+QL_SMS_ERROR_CODE ql_sms_send_pdu_msg(uint8_t *phone_num,uint8_t *data,int sms_type)
+{
+    if(info_handle == NULL || phone_num == NULL || data == NULL)
+    {
+        return -1;
+    }
+
+    char cmgs[MSM_NUMBER_MAX] = {0};
+    char resp[RES_NUM_MIN] = {0};
+    char pdu_data[512] = {0};
+    char phone_lenth[10] = {0};
+    char *p = pdu_data;
+    int mode = 0;
+    int err = 0;
+    int i = 0;
+    
+    if(strlen(data) > 512 || strlen(data) == 0 || strlen(phone_num) == 0)
+    {
+        printf("strlen(telephony_num):%d\n", strlen(phone_num));
+        printf("strlen(msg):%d\n", strlen(data));
+        return -1;
+    }
+
+    memset(center_address, 0, sizeof(center_address));
+    memcpy(center_address, "+8613800280500", strlen("+8613800280500"));
+
+    printf("phone_num:%s\n", phone_num);
+    printf("center_address:%s\n", center_address);
+    printf("data:%s\n", data);
+
+
+    mode = 0;   // PDU
+
+    char* pdu = NULL;
+        char* smsc = SCAEncoding(center_address);
+    struct PDUS *pdus = PDUEncoding(center_address,phone_num, data, NULL);
+
+    for (i = 0; i < pdus->count; i++) {
+         printf("第 %d 条:\n", i + 1);
+         printf("%s\n", pdus->PDU[i]);
+        pdu = pdus->PDU[i];
+    }
+
+    sprintf(p, "%s",smsc);
+    printf("pdu_data:%s\n", pdu_data);
+    sprintf(p+strlen(p), "%s", pdu);
+    printf("pdu_data:%s\n",pdu_data);
+
+
+    err = mbtk_sms_cmgf_set(info_handle, mode);
+    if(err) {
+       printf("cmgf set error : %d\n", err);
+    } else {
+       printf("cmgf set success\n");
+    }
+
+    sprintf(cmgs,"%d,%s",strlen(pdu_data), pdu_data);
+    printf("cmgs:%s\n", cmgs);
+
+    memset(resp, 0, sizeof(resp));
+
+    err = mbtk_sms_cmgs_set(info_handle, cmgs, resp);
+    if(err) {
+        printf("Error : %d\n", err);
+        return -1;
+    } else {
+        printf("cmgs set success . resp:%s\n", resp);
+    }
+
+    return 0;
+
+}
+QL_SMS_ERROR_CODE ql_sms_send_text_msg(uint8_t *phone_num,uint8_t *data,int sms_type)
+{
+    if(info_handle == NULL || phone_num == NULL || data == NULL)
+    {
+        return -1;
+    }
+
+    char cmgs[MSM_NUMBER_MAX] = {0};
+    char resp[RES_NUM_MIN] = {0};
+    int mode = 0;
+    int err = 0;
+    if(strlen(data) > 512 || strlen(data) == 0 || strlen(phone_num) == 0)
+    {
+        printf("strlen(telephony_num):%d\n", strlen(phone_num));
+        printf("strlen(msg):%d\n", strlen(data));
+        return -1;
+    }
+
+    mode = 1;   // text
+
+    err = mbtk_sms_cmgf_set(info_handle, mode);
+    if(err) {
+       printf("cmgf set error : %d\n", err);
+    } else {
+       printf("cmgf set success\n");
+    }
+
+    sprintf(cmgs,"%s,%s",phone_num, data);
+    printf("cmgs:%s\n", cmgs);
+
+/*  char *ptr = strstr(cmd, "cmgs,");      //CMGS="10086",hf
+    if(ptr != NULL)
+    {
+        ptr = strstr(cmd, ",");
+        ptr++;
+        memset(cmgs, 0, sizeof(cmgs));
+        memcpy(cmgs, ptr, strlen(ptr));
+        printf("1cmgs:%s, strlen(cmgs):%d\n", cmgs, strlen(cmgs));
+    }
+*/
+
+    memset(resp, 0, sizeof(resp));
+
+    err = mbtk_sms_cmgs_set(info_handle, cmgs, resp);
+    if(err) {
+        printf("Error : %d\n", err);
+        return -1;
+    } else {
+        printf("cmgs set success . resp:%s\n", resp);
+    }
+
+    return 0;
+
+}
+
+
+QL_SMS_ERROR_CODE ql_sms_add_event_handler(QL_SMS_StatusIndMsgHandlerFunc_t handlerPtr, void* contextPtr)
+{
+    if(info_handle == NULL)
+    {
+        return QL_SMS_GENERIC_FAILURE;
+    }
+
+	int ret = mbtk_sms_cnmi_set(info_handle);
+	if(ret)
+	{
+		printf("set cnmi fail\n");
+		return QL_SMS_GENERIC_FAILURE;
+	}
+
+	mbtk_sms_state_change_cb_reg(info_handle, lynq_sms_state_change_cb);
+	return QL_SMS_SUCCESS;
+}
+
+
+/*
+	AT+CMGD=<index>[,<delflag>]
+
+	Deletes message based on index
+	node:
+		index is -1, delete all message
+		delflag set 4
+*/
+
+QL_SMS_ERROR_CODE ql_sms_delete_msg(size_t index)
+{
+    char cmgd[128] = {0};
+    int err = 0;
+
+    if(index == -1)		//delete all
+    {
+    	memcpy(cmgd, ",4", strlen(",4"));
+    }
+    else
+    {
+    	sprintf(cmgd,"%d",index);
+    }
+
+    printf("cmgd:%s\n", cmgd);
+
+    err = mbtk_sms_cmgd_set(info_handle, cmgd);
+    if(err) {
+    	printf("lynq_delete_sms Error : %d\n", err);
+    	return -1;
+    } else {
+    	printf("lynq_delete_sms set success\n");
+    }
+
+    return 0;
+
+}
+
+
+QL_SMS_ERROR_CODE ql_search_sms_text_message(int index, recvmessage* payload)
+{
+    if(info_handle == NULL)
+    {
+        return -1;
+    }
+
+    char cmgs[MSM_NUMBER_MAX] = {0};
+    int mode = 1;   // text
+    int err = 0;
+    char *data = "ALL";
+
+    err = mbtk_sms_cmgf_set(info_handle, mode);
+    if(err) {
+       printf("cmgf set error : %d\n", err);
+    } else {
+       printf("cmgf set success\n");
+    }
+
+
+    char cmgl[128] = {0};
+    char resp[1024+1] ={0};
+    sprintf(cmgl,"%d,%s", index, data);
+/*
+    char *ptr = strstr(cmd, "cmgl,");  //  AT+CMGL[=<stat>]
+    if(ptr != NULL)
+    {
+        ptr = strstr(cmd, ",");
+        ptr++;
+        memset(cmgl, 0, sizeof(cmgl));
+        memcpy(cmgl, ptr, strlen(ptr));
+        printf("0cmgl:%s\n", cmgl);
+    }
+*/
+    memset(resp, 0, sizeof(resp));
+    err = mbtk_sms_cmgl_set(info_handle, cmgl, resp);
+    if(err) {
+        printf("lynq_list_sms Error : %d\n", err);
+        return -1;
+    } else {
+        printf("cmgl set success, reg:%s\n",resp);
+    }
+
+    return 0;
+
+}
+QL_SMS_ERROR_CODE ql_search_sms_pdu_message(int index, recvmessage* payload)
+{
+    if(info_handle == NULL)
+    {
+        return -1;
+    }
+
+    char cmgs[MSM_NUMBER_MAX] = {0};
+    int mode = 0;   // pud
+    int err = 0;
+    char *data = "ALL";
+
+
+    err = mbtk_sms_cmgf_set(info_handle, mode);
+    if(err) {
+       printf("cmgf set error : %d\n", err);
+    } else {
+       printf("cmgf set success\n");
+    }
+
+
+    char cmgl[128] = {0};
+    char resp[1024+1] ={0};
+    sprintf(cmgl,"%d,%s", index, data);
+/*
+    char *ptr = strstr(cmd, "cmgl,");  //  AT+CMGL[=<stat>]
+    if(ptr != NULL)
+    {
+        ptr = strstr(cmd, ",");
+        ptr++;
+        memset(cmgl, 0, sizeof(cmgl));
+        memcpy(cmgl, ptr, strlen(ptr));
+        printf("0cmgl:%s\n", cmgl);
+    }
+*/
+    memset(resp, 0, sizeof(resp));
+    err = mbtk_sms_cmgl_set(info_handle, cmgl, resp);
+    if(err) {
+        printf("lynq_list_sms Error : %d\n", err);
+        return -1;
+    } else {
+        printf("cmgl set success, reg:%s\n",resp);
+    }
+
+    return 0;
+
+}
+
+
+/*
+function: lynq_list_sms
+stat:0:pud, 1:text
+index: 0, list index;
+	  > 0,
+
+*/
+QL_SMS_ERROR_CODE ql_sms_list_sms(int stat, int index, char *data)
+{
+    if(info_handle == NULL)
+    {
+        return -1;
+    }
+
+	char cmgs[MSM_NUMBER_MAX] = {0};
+	int mode = 0;
+	int err = 0;
+
+	if(stat)	// text
+	{
+		mode = 1;
+	}
+
+	err = mbtk_sms_cmgf_set(info_handle, mode);
+	if(err) {
+	   printf("cmgf set error : %d\n", err);
+	} else {
+	   printf("cmgf set success\n");
+	}
+
+
+	char cmgl[128] = {0};
+	char resp[1024+1] ={0};
+	sprintf(cmgl,"%d,%s", index, data);
+/*
+	char *ptr = strstr(cmd, "cmgl,");  //  AT+CMGL[=<stat>]
+	if(ptr != NULL)
+	{
+		ptr = strstr(cmd, ",");
+		ptr++;
+		memset(cmgl, 0, sizeof(cmgl));
+		memcpy(cmgl, ptr, strlen(ptr));
+		printf("0cmgl:%s\n", cmgl);
+	}
+*/
+	memset(resp, 0, sizeof(resp));
+	err = mbtk_sms_cmgl_set(info_handle, cmgl, resp);
+	if(err) {
+		printf("lynq_list_sms Error : %d\n", err);
+		return -1;
+	} else {
+	    printf("cmgl set success, reg:%s\n",resp);
+	}
+
+	return 0;
+}
+
+
+
+int ql_sms_query_sms_storage_status(void)
+{
+	char mem[128] = {0};
+	int err = mbtk_sms_cpms_get(info_handle, mem);
+    if(err) {
+        printf("cpms query is fail Error : %d\n", err);
+		return -1;
+    } else {
+        printf("cpms query is success : %s\n", mem);
+    }
+
+	return 0;
+}
+
+QL_SMS_ERROR_CODE ql_sms_get_sms_center_address(uint8_t *sms_center_addree)
+{
+	char csca[128] = {0};
+	if(info_handle == NULL || sms_center_addree == NULL)
+    {
+		return QL_SMS_GENERIC_FAILURE;
+	}
+
+	int err = mbtk_sms_csca_get(info_handle, sms_center_addree);
+	if(err) {
+		printf("lynq_get_smsc_address Error : %d\n", err);
+		return QL_GET_RESPONSE_ERROR;
+	} else {
+		printf("lynq_get_smsc_address success\n");
+	}
+
+	return 0;
+}
+
+
+QL_SMS_ERROR_CODE ql_sms_set_sms_center_address(unsigned char *destNum)
+{
+    printf("1destNum:%s\n", destNum);
+    memset(center_address, 0, sizeof(center_address));
+        memcpy(center_address, destNum, strlen(destNum));
+	if(info_handle == NULL || destNum == NULL)
+	{
+		return -1;
+	}
+
+	int err = mbtk_sms_csca_set(info_handle, destNum);
+	if(err) {
+		printf("Error : %d\n", err);
+		return err;
+	} else {
+    //    memset(center_address, 0, sizeof(center_address));
+    //    memcpy(center_address, destNum, strlen(destNum));
+        printf("destNum:%s\n", destNum);
+		printf("lynq_set_smsc_address success\n");
+	}
+	return 0;
+
+}
+
+
+
+
+
diff --git a/mbtk/libql_lib_v2/src/ql_spi.c b/mbtk/libql_lib_v2/src/ql_spi.c
new file mode 100755
index 0000000..4fc5d9f
--- /dev/null
+++ b/mbtk/libql_lib_v2/src/ql_spi.c
@@ -0,0 +1,342 @@
+#include <stdio.h>
+#include <malloc.h>
+#include <string.h>
+#include <linux/types.h>
+#include <linux/spi/spidev.h>
+
+#include <stdint.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <linux/types.h>
+#include <linux/spi/spidev.h>
+#include <errno.h>
+
+#include "ql/ql_spi.h"
+#include "mbtk_log.h"
+
+#if 0
+static const char *device = "/dev/spidev1.0\0";
+static uint8_t mode = 3; /* SPI通信使用全双工，设置CPOL＝0，CPHA＝0。 */
+static uint8_t bits = 8; /* ８ｂiｔｓ读写，MSB first。*/
+static uint32_t speed = 100 * 1000;/* 设置0.5M传输速度 */
+static uint16_t delay = 500;
+
+int SPI_Transfer(const uint8_t *TxBuf, uint8_t *RxBuf, int len)
+{
+    int ret;
+    int fd = g_SPI_Fd;
+
+
+    struct spi_ioc_transfer tr ;
+    memset(&tr,0x00,sizeof(tr));
+    tr.tx_buf = (unsigned long) TxBuf,
+    tr.rx_buf = (unsigned long) RxBuf,
+    tr.len =len,
+    tr.delay_usecs = delay;
+    tr.speed_hz=speed;
+    tr.bits_per_word=bits;
+    ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
+    if (ret < 1)
+    {
+        printf("can't send spi message");
+    }
+   else
+   {
+        //printf("Send spi message OK %d\n",RxBuf[0]);
+   }
+   return 1;
+}
+
+/**
+* 功 能：关闭SPI模块
+*/
+int SPI_Close(void)
+{
+    int fd = g_SPI_Fd;
+
+
+    if (fd == 0) /* SPI是否已经打开*/
+    return 0;
+    close(fd);
+    g_SPI_Fd = 0;
+
+
+    return 0;
+}
+
+int SPI_Write(uint8_t *TxBuf, int len)
+{
+    int ret;
+    int fd = g_SPI_Fd;
+
+    printf("fd : %d\n",fd);
+    ret = write(fd, TxBuf, len);
+    if (ret < 0)
+    printf("SPI Write errorn");
+
+    return ret;
+}
+
+int SPI_Open(void)
+{
+    int fd;
+    int ret = 0;
+
+	printf("open spi dev:%s \r\n", device);
+    fd = open(device, O_RDWR);
+    if (fd < 0)
+	{
+        	printf("can't open device \n");
+		return -1;
+	}
+    else
+        printf("SPI - Open Succeed. Start Init SPI...n\n");
+
+    /*
+    * spi mode
+    */
+    ret = ioctl(fd, SPI_IOC_WR_MODE, &mode);
+    if (ret == -1)
+    printf("can't set spi mode\n");
+
+
+    ret = ioctl(fd, SPI_IOC_RD_MODE, &mode);
+    if (ret == -1)
+    printf("can't get spi mode\n");
+
+
+    /*
+    * bits per word
+    */
+    ret = ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &bits);
+    if (ret == -1)
+      printf("can't set bits per word\n");
+
+
+    ret = ioctl(fd, SPI_IOC_RD_BITS_PER_WORD, &bits);
+    if (ret == -1)
+      printf("can't get bits per word\n");
+
+
+    /*
+    * max speed hz
+    */
+    ret = ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed);
+    if (ret == -1)
+    printf("can't set max speed hz\n");
+
+
+    ret = ioctl(fd, SPI_IOC_RD_MAX_SPEED_HZ, &speed);
+    if (ret == -1)
+        printf("can't get max speed hz\n");
+
+    g_SPI_Fd=fd;
+    return ret;
+}
+#endif
+
+/**
+ * Function:  Ql_SPI_Init
+ * Description: spi init
+ * Parameters:  dev_name---device name
+ *              mode---spi mode
+ *              bits---spi per word
+ *              speed---spi transfer clock
+ * Return: spi fd
+ **/
+int Ql_SPI_Init(const char *dev_name, SPI_MODE mode, unsigned char bits, SPI_SPEED speed)
+{
+    int fd;
+    int ret = 0;
+
+	LOGD("open spi dev:%s.", dev_name);
+    fd = open(dev_name, O_RDWR);
+    if (fd < 0)
+	{
+        LOGE("can't open device, errno - %d", errno);
+        return -1;
+	}
+    else
+        LOGD("SPI - Open Succeed. Start Init SPI...");
+
+    /*
+    * spi mode
+    */
+    ret = ioctl(fd, SPI_IOC_WR_MODE, &mode);
+    if (ret == -1) {
+        LOGE("can't set spi mode");
+        goto error;
+    }
+
+#if 0
+    ret = ioctl(fd, SPI_IOC_RD_MODE, &mode);
+    if (ret == -1) {
+        LOGE("can't get spi mode");
+        goto error;
+    }
+#endif
+
+    /*
+    * bits per word
+    */
+    ret = ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &bits);
+    if (ret == -1) {
+        LOGE("can't set bits per word");
+        goto error;
+    }
+
+#if 0
+    ret = ioctl(fd, SPI_IOC_RD_BITS_PER_WORD, &bits);
+    if (ret == -1) {
+        LOGE("can't get bits per word");
+        goto error;
+    }
+#endif
+
+    /*
+    * max speed hz
+    */
+    ret = ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed);
+    if (ret == -1) {
+        LOGE("can't set max speed hz");
+        goto error;
+    }
+
+#if 0
+    ret = ioctl(fd, SPI_IOC_RD_MAX_SPEED_HZ, &speed);
+    if (ret == -1) {
+        LOGE("can't get max speed hz");
+        goto error;
+    }
+#endif
+
+    return fd;
+error:
+    if(fd > 0)
+    {
+        close(fd);
+    }
+    return -1;
+}
+
+/**
+ * Function: Ql_SPI_DeInit
+ * Description: spi deinit
+ * Parameters: fd---spi fd
+ * Return:
+ */
+int Ql_SPI_DeInit(int fd)
+{
+    if (fd <= 0)
+        return -1;
+
+    close(fd);
+    return 0;
+}
+
+/**
+ * Function: Ql_SPI_Write_Read
+ * Description: spi write read function
+ * Parameters: fd---spi fd
+ *              w_buf---write buffer
+ *              r_buf---read buffer
+ *              len---spi transfer length
+ * Return: 0---transfer success
+ *          other---failed
+ **/
+int Ql_SPI_Write_Read(int fd, unsigned char *w_buf, unsigned char *r_buf, unsigned int len)
+{
+    int ret;
+    struct spi_ioc_transfer tr ;
+    memset(&tr,0x00,sizeof(tr));
+    tr.tx_buf = (unsigned long) w_buf,
+    tr.rx_buf = (unsigned long) r_buf,
+    tr.len =len,
+    tr.delay_usecs = 500;
+    //tr.speed_hz=speed;
+    //tr.bits_per_word=bits;
+    ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
+    if (ret < 1)
+    {
+        LOGE("can't send spi message");
+        return -1;
+    }
+    else
+    {
+        return 0;
+    }
+}
+
+
+#if 0
+int main(int argc, char *argv[])
+{
+
+	char send_data[64] = {0};
+	char read_data[64] = {0};
+	char crc = 0;
+	int i = 0;
+	int j = 0;
+
+    system("echo PB6 > /sys/kernel/debug/sunxi_pinctrl/sunxi_pin");
+    system("echo PB6 1 > /sys/kernel/debug/sunxi_pinctrl/function");
+    system("echo PB6 0 > /sys/kernel/debug/sunxi_pinctrl/data");
+
+	/* spi 初始化程序 */
+	SPI_Open();
+
+	send_data[0] = 0x55;
+	send_data[1] = 0x00;
+	send_data[2] = 0x84;
+	send_data[3] = 0x00;
+	send_data[4] = 0x08;
+	send_data[5] = 0x00;
+	send_data[6] = 0x00;
+
+	crc = send_data[1];
+	for (i = 2; i < 7; i++)
+	{
+		crc ^= send_data[i];
+	}
+	crc = ~crc;
+
+	send_data[7] = crc;
+
+	printf("send data:");
+	for (i = 0; i < 8; i++)
+	{
+		printf("%#x, ", send_data[i]);
+	}
+	printf("\n");
+
+	/* spi 发送数据 */
+	SPI_Transfer(send_data,read_data,8);
+
+	printf("read data:");
+	for (j = 0; j < 20; j++)
+	{
+		printf("%#x, ", read_data[j]);
+	}
+
+	usleep(10000);
+
+
+	memset(read_data, 0, sizeof(read_data));
+	memset(send_data, 0, sizeof(send_data));
+
+	/* spi 读取数据 */
+	SPI_Transfer(send_data,read_data,16);
+
+	printf("read data:");
+	for (j = 0; j < 20; j++)
+	{
+		printf("%#x, ", read_data[j]);
+	}
+
+	return 0;
+}
+#endif
diff --git a/mbtk/libql_lib_v2/src/ql_uart.c b/mbtk/libql_lib_v2/src/ql_uart.c
new file mode 100755
index 0000000..ca6f779
--- /dev/null
+++ b/mbtk/libql_lib_v2/src/ql_uart.c
@@ -0,0 +1,432 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <errno.h>
+#include <termios.h>
+#include <unistd.h>
+
+#include "mbtk_log.h"
+#include "ql/ql_uart.h"
+
+int Ql_UART_Open(const char* port, Enum_BaudRate baudrate, Enum_FlowCtrl flowctrl)
+{
+    int fd;
+    if((fd = open(port, O_RDWR | O_NOCTTY)) < 0)
+    {
+        LOGE("open %s failed - %d", port, errno);
+        return -1;
+    }
+
+    LOGD("Open %s success.", port);
+
+    /* set newtio */
+    struct termios newtio;
+    memset(&newtio, 0, sizeof(newtio));
+    if (tcflush(fd, TCIOFLUSH) < 0) {
+        LOGE("Could not flush uart port");
+        return -1;
+    }
+
+    newtio.c_cc[VTIME]    = 0;   /* inter-character timer unused */
+    newtio.c_cc[VMIN]      = 0;   /* blocking read until 5 chars received */
+
+    if(flowctrl == FC_RTSCTS) {
+        newtio.c_cflag |= CRTSCTS;
+    } else if(flowctrl == FC_XONXOFF) {
+        newtio.c_cflag |= (IXON | IXOFF);
+    } else {
+        // newtio.c_cflag |= CRTSCTS;
+    }
+        /* c_iflag 输入模式 */
+    newtio.c_iflag &= ~(ICRNL |  INLCR);
+    newtio.c_iflag &= ~(IXON | IXOFF | IXANY);
+
+    // /* c_lflag 本地模式 */
+    newtio.c_cflag &= ~ INPCK;
+    newtio.c_cflag |= (CLOCAL |  CREAD);
+
+    // /* c_lflag 本地模式 */
+    newtio.c_lflag &= ~(ICANON | ECHO | ECHOE |  ISIG);
+    /* c_oflag 输出模式 */
+    newtio.c_oflag &= ~ OPOST;
+    newtio.c_oflag &= ~(ONLCR | OCRNL);
+
+    /* c_cflag 控制模式 */
+    newtio.c_cflag &= ~ CSIZE;
+    newtio.c_cflag |=  CS8;
+    newtio.c_cflag &= ~ CSTOPB;
+    newtio.c_cflag &= ~ PARENB;
+
+    switch(baudrate)
+    {
+        case B_300:
+            cfsetospeed(&newtio, B300);
+            cfsetispeed(&newtio, B300);
+            break;
+        case B_600:
+            cfsetospeed(&newtio, B600);
+            cfsetispeed(&newtio, B600);
+            break;
+        case B_1200:
+            cfsetospeed(&newtio, B1200);
+            cfsetispeed(&newtio, B1200);
+            break;
+        case B_2400:
+            cfsetospeed(&newtio, B2400);
+            cfsetispeed(&newtio, B2400);
+            break;
+        case B_4800:
+            cfsetospeed(&newtio, B4800);
+            cfsetispeed(&newtio, B4800);
+            break;
+        case B_9600:
+            cfsetospeed(&newtio, B9600);
+            cfsetispeed(&newtio, B9600);
+            break;
+        case B_19200:
+            cfsetospeed(&newtio, B19200);
+            cfsetispeed(&newtio, B19200);
+            break;
+        case B_38400:
+            cfsetospeed(&newtio, B38400);
+            cfsetispeed(&newtio, B38400);
+            break;
+        case B_57600:
+            cfsetospeed(&newtio, B57600);
+            cfsetispeed(&newtio, B57600);
+            break;
+        case B_115200:
+            cfsetospeed(&newtio, B115200);
+            cfsetispeed(&newtio, B115200);
+            break;
+        case B_230400:
+            cfsetospeed(&newtio, B230400);
+            cfsetispeed(&newtio, B230400);
+            break;
+        case B_460800:
+            cfsetospeed(&newtio, B460800);
+            cfsetispeed(&newtio, B460800);
+            break;
+        case B_921600:
+            cfsetospeed(&newtio, B921600);
+            cfsetispeed(&newtio, B921600);
+            break;
+        case B_3000000:
+            cfsetospeed(&newtio, B3000000);
+            cfsetispeed(&newtio, B3000000);
+            break;
+        case B_4000000:
+            cfsetospeed(&newtio, B4000000);
+            cfsetispeed(&newtio, B4000000);
+            break;
+        default:
+            cfsetospeed(&newtio, B115200);
+            cfsetispeed(&newtio, B115200);
+            break;
+    }
+
+    if (tcsetattr(fd, TCSANOW, &newtio) < 0) {
+        LOGE("Can't set port setting");
+        return -1;
+    }
+    /* Blocking behavior */
+    fcntl(fd, F_SETFL, 0);
+
+    return fd;
+}
+
+int Ql_UART_Read(int fd, char* buf, unsigned int buf_len)
+{
+    return read(fd, buf, buf_len);
+}
+
+
+int Ql_UART_Write(int fd, const char* buf, unsigned int buf_len)
+{
+    return write(fd, buf, buf_len);
+}
+
+
+int Ql_UART_SetDCB(int fd, ST_UARTDCB *dcb)
+{
+    struct termios newtio;
+    memset(&newtio, 0, sizeof(newtio));
+
+    if(tcgetattr(fd, &newtio) != 0)
+    {
+        LOGE("Serial port configuration backup errno");
+        return -1;
+    }
+
+    switch(dcb->baudrate)
+    {
+        case B_300:
+            cfsetospeed(&newtio, B300);
+            cfsetispeed(&newtio, B300);
+            break;
+        case B_600:
+            cfsetospeed(&newtio, B600);
+            cfsetispeed(&newtio, B600);
+            break;
+        case B_1200:
+            cfsetospeed(&newtio, B1200);
+            cfsetispeed(&newtio, B1200);
+            break;
+        case B_2400:
+            cfsetospeed(&newtio, B2400);
+            cfsetispeed(&newtio, B2400);
+            break;
+        case B_4800:
+            cfsetospeed(&newtio, B4800);
+            cfsetispeed(&newtio, B4800);
+            break;
+        case B_9600:
+            cfsetospeed(&newtio, B9600);
+            cfsetispeed(&newtio, B9600);
+            break;
+        case B_19200:
+            cfsetospeed(&newtio, B19200);
+            cfsetispeed(&newtio, B19200);
+            break;
+        case B_38400:
+            cfsetospeed(&newtio, B38400);
+            cfsetispeed(&newtio, B38400);
+            break;
+        case B_57600:
+            cfsetospeed(&newtio, B57600);
+            cfsetispeed(&newtio, B57600);
+            break;
+        case B_115200:
+            cfsetospeed(&newtio, B115200);
+            cfsetispeed(&newtio, B115200);
+            break;
+        case B_230400:
+            cfsetospeed(&newtio, B230400);
+            cfsetispeed(&newtio, B230400);
+            break;
+        case B_460800:
+            cfsetospeed(&newtio, B460800);
+            cfsetispeed(&newtio, B460800);
+            break;
+        case B_921600:
+            cfsetospeed(&newtio, B921600);
+            cfsetispeed(&newtio, B921600);
+            break;
+        case B_3000000:
+            cfsetospeed(&newtio, B3000000);
+            cfsetispeed(&newtio, B3000000);
+            break;
+        case B_4000000:
+            cfsetospeed(&newtio, B4000000);
+            cfsetispeed(&newtio, B4000000);
+            break;
+        default:
+            LOGD("No set speed.");
+            break;
+    }
+
+    switch(dcb->databit)
+    {
+        case DB_CS5:
+            newtio.c_cflag &= ~CSIZE;
+            newtio.c_cflag |= CS5;
+            break;
+        case DB_CS6:
+            newtio.c_cflag &= ~CSIZE;
+            newtio.c_cflag |= CS6;
+            break;
+        case DB_CS7:
+            newtio.c_cflag &= ~CSIZE;
+            newtio.c_cflag |= CS7;
+            break;
+        case DB_CS8:
+            newtio.c_cflag &= ~CSIZE;
+            newtio.c_cflag |= CS8;
+            break;
+        default:
+            LOGD("No set databit.");
+            break;
+    }
+
+    if(dcb->stopbit == SB_2) {
+        newtio.c_cflag |= CSTOPB;
+    } else {
+        newtio.c_cflag &= ~CSTOPB;
+    }
+
+    switch (dcb->parity)
+    {
+        case PB_ODD:// 奇校验
+            newtio.c_cflag |= PARENB;
+            newtio.c_cflag |= PARODD;
+            break;
+        case PB_EVEN:// 偶校验
+            newtio.c_cflag |= PARENB;
+            newtio.c_cflag &= ~PARODD;
+            break;
+        case PB_NONE:// 无奇偶校验
+            newtio.c_cflag &= ~PARENB;
+            break;
+        default:
+            LOGD("No set parity.");
+            break;
+    }
+
+    switch (dcb->flowctrl)
+    {
+        case FC_RTSCTS:
+            newtio.c_cflag |= CRTSCTS;
+            tcflush(fd, TCIFLUSH);
+            break;
+        case FC_XONXOFF:
+            newtio.c_iflag |= (IXON | IXOFF);
+            tcflush(fd, TCIFLUSH);
+            break;
+        case FC_NONE:
+            newtio.c_cflag &= ~CRTSCTS;
+            newtio.c_iflag &= ~(IXON | IXOFF);
+            tcflush(fd, TCIFLUSH);
+            break;
+        default:
+            LOGD("No set flow ctrl.");
+            break;
+    }
+
+    if(tcsetattr(fd, TCSANOW, &newtio) != 0)
+    {
+        LOGE("Serial port configuration backup errno");
+        return -1;
+    }
+
+    return 0;
+}
+
+
+int Ql_UART_GetDCB(int fd, ST_UARTDCB *dcb)
+{
+    struct termios newtio;
+    memset(&newtio, 0, sizeof(newtio));
+
+    if(tcgetattr(fd, &newtio) != 0)
+    {
+        LOGE("Serial port configuration backup errno");
+        return -1;
+    }
+
+    switch(cfgetispeed(&newtio))
+    {
+        case B300:
+            dcb->baudrate = B_300;
+            break;
+        case B600:
+            dcb->baudrate = B_600;
+            break;
+        case B1200:
+            dcb->baudrate = B_1200;
+            break;
+        case B2400:
+            dcb->baudrate = B_2400;
+            break;
+        case B4800:
+            dcb->baudrate = B_4800;
+            break;
+        case B9600:
+            dcb->baudrate = B_9600;
+            break;
+        case B19200:
+            dcb->baudrate = B_19200;
+            break;
+        case B38400:
+            dcb->baudrate = B_38400;
+            break;
+        case B57600:
+            dcb->baudrate = B_57600;
+            break;
+        case B115200:
+            dcb->baudrate = B_115200;
+            break;
+        case B230400:
+            dcb->baudrate = B_230400;
+            break;
+        case B460800:
+            dcb->baudrate = B_460800;
+            break;
+        case B921600:
+            dcb->baudrate = B_921600;
+            break;
+        case B3000000:
+            dcb->baudrate = B_3000000;
+            break;
+        case B4000000:
+            dcb->baudrate = B_4000000;
+            break;
+        default:
+            dcb->baudrate = B_115200;
+            break;
+    }
+
+    switch(newtio.c_cflag & CSIZE)
+    {
+        case CS5:
+            dcb->databit = DB_CS5;
+            break;
+        case CS6:
+            dcb->databit = DB_CS6;
+            break;
+        case CS7:
+            dcb->databit = DB_CS7;
+            break;
+        case CS8:
+            dcb->databit = DB_CS8;
+            break;
+        default:
+            dcb->databit = DB_CS8;
+            break;
+    }
+
+    if(newtio.c_cflag & CSTOPB) {
+        dcb->stopbit = SB_2;
+    } else {
+        dcb->stopbit = SB_1;
+    }
+
+    if(newtio.c_cflag & PARENB) { // 启用了奇偶校验
+        if(newtio.c_cflag & PARODD) {
+            dcb->parity = PB_ODD; // 奇校验
+        } else {
+            dcb->parity = PB_EVEN; // 偶校验
+        }
+    } else {
+        dcb->parity = PB_NONE;
+    }
+
+    if(newtio.c_cflag & CRTSCTS) {
+        dcb->flowctrl = FC_RTSCTS;
+    } else if(newtio.c_iflag & (IXON | IXOFF) == (IXON | IXOFF)){
+        dcb->flowctrl = FC_XONXOFF;
+    } else {
+        dcb->flowctrl = FC_NONE;
+    }
+
+    return 0;
+}
+
+
+int Ql_UART_IoCtl(int fd, unsigned int cmd, void* pValue)
+{
+    return 0;
+}
+
+
+int Ql_UART_Close(int fd)
+{
+    if (fd <= 0)
+        return -1;
+
+    close(fd);
+    return 0;
+}
+
diff --git a/mbtk/libql_lib_v2/src/ql_voice.c b/mbtk/libql_lib_v2/src/ql_voice.c
new file mode 100755
index 0000000..9df4053
--- /dev/null
+++ b/mbtk/libql_lib_v2/src/ql_voice.c
@@ -0,0 +1,229 @@
+#include "mbtk_type.h"
+#include "ql/ql_at.h"
+#include "ql/ql_vcall.h"
+#include "ql/ql_mcm_call.h"
+#include "ql/ql_voice.h"
+
+typedef struct
+{
+    int  cmdIdx;
+    char *funcName;
+} st_api_test_case;
+
+//for server test
+st_api_test_case at_api_testcases[] =
+{
+    {0,   "print_help"},
+    {1,   "QL_Voice_Call_Ecall"},
+    {2,   "QL_Voice_Call_Ecall_HangUp"},
+
+    {-1,    NULL}
+};
+
+
+voice_client_handle_type h_voice = 0;
+
+
+void print_help(void)
+{
+    int i;
+
+    printf("Supported test cases:\n");
+    for(i = 0; ; i++)
+    {
+        if(at_api_testcases[i].cmdIdx == -1)
+        {
+            break;
+        }
+        printf("%d:\t%s\n", at_api_testcases[i].cmdIdx, at_api_testcases[i].funcName);
+    }
+}
+
+static void ql_voice_call_ind_func(unsigned int ind_id,
+                                   void* ind_data,
+                                   uint32_t ind_data_len)
+{
+    if(NULL == ind_data)
+    {
+        return;
+    }
+
+    switch(ind_id)
+    {
+        case E_QL_MCM_VOICE_CALL_IND:
+        {
+            if(ind_data_len != sizeof(ql_mcm_voice_call_ind))
+            {
+                break;
+            }
+
+            ql_mcm_voice_call_ind *pVoiceCallInd = (ql_mcm_voice_call_ind*)ind_data;
+
+            char *call_state[] = {"INCOMING", "DIALING", "ALERTING", "ACTIVE", "HOLDING", "END", "WAITING"};
+
+            int i = 0;
+            for(i = 0; i < pVoiceCallInd->calls_len; i++)
+            {
+                printf("######### Call id=%d, PhoneNum:%s, event=%s!  ######\n",
+                            pVoiceCallInd->calls[i].call_id, pVoiceCallInd->calls[i].number, call_state[pVoiceCallInd->calls[i].state]);
+            }
+
+            break;
+        }
+
+        case E_QL_MCM_VOICE_ECALL_STATUE_IND:
+        {
+            if(ind_data_len != sizeof(ql_mcm_voice_ecall_status_ind))
+            {
+                break;
+            }
+
+            ql_mcm_voice_ecall_status_ind *pEcallStatusInd
+                                           = (ql_mcm_voice_ecall_status_ind*)ind_data;
+
+            if (pEcallStatusInd->ecall_msd_tx_status_valid)
+            {
+                if (pEcallStatusInd->ecall_msd_tx_status == E_QL_MCM_VOICE_ECALL_MSD_TRANSMISSION_STATUS_SUCCESS)
+                {
+                    printf("========== Ecall status  call_id =%d ,   ecall msd tx success.\r\n", pEcallStatusInd->call_id);
+                }
+                else
+                {
+                    printf("========== Ecall status  call_id =%d ,   ecall msd tx failure.\r\n",  pEcallStatusInd->call_id);
+                }
+            }
+            else
+            {
+                printf("========== Ecall status  call_id =%d  \r\n", pEcallStatusInd->call_id);
+            }
+
+            break;
+        }
+
+        case E_QL_MCM_VOICE_UNKOWN_IND:
+        default:
+            break;
+    }
+}
+
+//"\t1 call init\n"
+QL_VOICE_ERROR_CODE ql_voice_call_init()
+{
+    int ret = 0;
+    ret = QL_Voice_Call_Client_Init(&h_voice);
+    if(ret < 0)
+    {
+        printf("QL_Voice_Call_Client_Init FAIL. ret:%d\n",ret);
+        ret = QL_VOICE_GENERIC_FAILURE;
+    }
+    else{
+        printf("QL_Voice_Call_Client_Init ret = %d, with h_voice=%d\n", ret, h_voice);
+    }
+
+    return ret;
+}
+
+//"\t9 call deinit\n"
+QL_VOICE_ERROR_CODE ql_voice_call_release()
+{
+    int ret = 0;
+    ret = QL_Voice_Call_Client_Deinit(h_voice);
+    if(ret)
+    {
+        ret = QL_VOICE_GENERIC_FAILURE;
+    }
+    
+    return ret;
+}
+
+//\t2 call register handle\n"
+QL_VOICE_ERROR_CODE ql_voice_call_event_register(QL_VOICE_EventHandlerFunc_t handlerPtr, void* contextPtr)
+{
+    int ret = 0;
+    ret = QL_Voice_Call_AddCommonStateHandler(h_voice, (QL_VoiceCall_CommonStateHandlerFunc_t)ql_voice_call_ind_func);
+    if(ret < 0)
+    {
+        printf("QL_Voice_Call_AddCommonStateHandler FAIL.       ret:%d\n",ret);
+        ret = QL_VOICE_GENERIC_FAILURE;
+    }
+    
+    return ret;
+}
+
+/*
+    Phone call.
+     -call_num   : dst phone number
+*/
+QL_VOICE_ERROR_CODE ql_voice_call_start(char* call_num)
+{
+    int ret = 0;
+
+    ret = QL_Voice_Call_Start(h_voice, 0, call_num, NULL);
+    if(ret)
+    {
+        ret = QL_VOICE_GENERIC_FAILURE;
+    }
+    return ret;
+}
+
+
+/*
+    Put through.
+*/
+QL_VOICE_ERROR_CODE ql_voice_call_answer()
+{
+    int ret = 0;
+    ret = QL_Voice_Call_Answer(h_voice, 0);
+    if(ret)
+    {
+        ret = QL_VOICE_GENERIC_FAILURE;
+    }
+    return ret;
+}
+QL_VOICE_ERROR_CODE ql_voice_auto_answer(int seconds)
+{
+    int ret = 0;
+
+    ret = QL_Voice_Call_SetAutoAnswer(h_voice, E_QL_MCM_VOICE_AUTO_ANSWER_ENABLE, 6000);
+    if(ret)
+    {
+        ret = QL_VOICE_GENERIC_FAILURE;
+    }
+    return ret;
+}
+
+/*
+    Hang up.
+*/
+QL_VOICE_ERROR_CODE ql_voice_call_end()
+{
+    int ret = 0;
+    ret = QL_Voice_Call_End(h_voice, 0);
+    if(ret)
+    {
+        ret = QL_VOICE_GENERIC_FAILURE;
+    }
+
+    return ret;
+}
+
+
+/* hold the voice */
+QL_VOICE_ERROR_CODE ql_voice_call_hold()
+{
+    int ret = 0;
+    QL_Voice_Call_Hold(h_voice);
+
+    return ret;
+}
+
+/* unhold the voice */
+QL_VOICE_ERROR_CODE ql_voice_call_unhold()
+{
+    int ret = 0;
+
+    QL_Voice_Call_UnHold(h_voice);
+
+    return ret;
+}
+
