上库LYNQ_SLEEP接口以及添加对应测试demo,删除LYNQ_SMS模块的冗余代码

Change-Id: Iaa684b0da9af0f895554f45e30ead62333a816a1
diff --git a/mbtk/include/lynq/lynq-qser-autosuspend.h b/mbtk/include/lynq/lynq-qser-autosuspend.h
index 8ea9c01..37adfc7 100755
--- a/mbtk/include/lynq/lynq-qser-autosuspend.h
+++ b/mbtk/include/lynq/lynq-qser-autosuspend.h
@@ -63,6 +63,8 @@
 int qser_wakelock_lock(int fd);
 int qser_wakelock_unlock(int fd);
 int qser_wakelock_destroy(int fd);
+int qser_whitelist_get(char* whitelish);
+int qser_whitelist_set(char* whitelish);
 
 
 #ifdef __cplusplus
diff --git a/mbtk/include/mbtk/mbtk_info_api.h b/mbtk/include/mbtk/mbtk_info_api.h
index fe4268d..ac0bfe3 100755
--- a/mbtk/include/mbtk/mbtk_info_api.h
+++ b/mbtk/include/mbtk/mbtk_info_api.h
@@ -467,6 +467,12 @@
     mbtk_pin_puk_last_times ql_last_times;
 } mbtk_sim_card_info;
 
+
+typedef struct{
+    uint8_t         mode;
+    uint32_t        oosPhase[3];   //单位为秒      
+} mbtk_oos_info;
+
 mbtk_info_handle_t* mbtk_info_handle_get();
 
 int mbtk_info_handle_free(mbtk_info_handle_t** handle);
@@ -894,6 +900,14 @@
 int mbtk_mute_state_set(mbtk_info_handle_t* handle, int mute_state);
 //get mute state
 int mbtk_mute_state_get(mbtk_info_handle_t* handle, int *mute_state);
+//Wake-up control
+int mbtk_wakeup_state_set(mbtk_info_handle_t* handle, uint32 wakeup_state);
+//Get the searching interval of OOS 
+int mbtk_oos_get(mbtk_info_handle_t* handle, mbtk_oos_info *oos_info);
+//Set the searching interval of OOS 
+int mbtk_oos_set(mbtk_info_handle_t* handle, char *oos_info);
+
+
 //set dtmf character
 int mbtk_dtmf_send(mbtk_info_handle_t* handle, mbtk_call_dtmf_info_t *dtmf_character);
 
diff --git a/mbtk/lynq_lib/src/lynq_sleep.c b/mbtk/lynq_lib/src/lynq_sleep.c
index 59a363f..2b1ef31 100755
--- a/mbtk/lynq_lib/src/lynq_sleep.c
+++ b/mbtk/lynq_lib/src/lynq_sleep.c
@@ -1,41 +1,401 @@
 #include "lynq-qser-autosuspend.h"
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stddef.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
 #include "mbtk_type.h"
+#include "mbtk_log.h"
+#include "mbtk_info_api.h"
+
+/*
+该模块是系统睡眠,锁存在的时候系统无法休眠
+验证是否在睡眠状态,则需要测试功耗
+电源管理原则,只要有一个wakelock锁存在,系统就不会进入Suspend状态
+所以名字可以随便取,表示需要这样的一个锁,所以系统就不会进行睡眠
+*/
+#define MTBK_POWERIND           "/system/etc/powerind"      //1806
+//#define MTBK_POWERIND           "/etc/powerind"             //1803
+
+static bool call_Off  = FALSE;
+static bool nw_off = FALSE;
+static bool sms_off = FALSE;
+static bool data_off = FALSE;
+
+
+static int powerrind_get()
+{
+    char buffer[50];
+    int ret = 0;
+
+    int fd = open(MTBK_POWERIND, O_RDWR | O_SYNC, 0662);
+    if (fd != -1)
+    {
+        read(fd, buffer, strlen(buffer)+1);
+        close(fd);
+    }
+
+    ret = atoi(buffer);
+
+    return ret;
+}
+
+
+
+typedef struct
+{
+    int fd;
+    char name[128];
+} lock_name;
+
+lock_name lynq_lock_name[512]={0};
+static bool autosleep_enable = FALSE;
+
+static mbtk_info_handle_t* whitelist_info_handle = NULL;
+
+
 
 int qser_autosuspend_enable(char enable)
 {
-    UNUSED(enable);
+    //UNUSED(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;
+        }
+    }
 
     return 0;
 }
 
 int qser_wakelock_create(const char* name , size_t len)
 {
-    UNUSED(name);
-    UNUSED(len);
+    //UNUSED(name);
+    //UNUSED(len);
+
+    if(!autosleep_enable) {
+        LOGE("Autosleep not enable.");
+        return -1;
+    }
+
+    if(name != NULL && len < 127)
+    {
+        int i;
+        for(i=0;i<512;i++)
+        {
+            if(lynq_lock_name[i].fd == 0)
+                break;
+        }
+        memcpy(lynq_lock_name[i].name, name, strlen(name)+1);
+        lynq_lock_name[i].fd = i;
+        return lynq_lock_name[i].fd;
+    }
+    else
+        return -1;
 
     return 0;
 }
 
 int qser_wakelock_lock(int fd)
 {
-    UNUSED(fd);
+    //UNUSED(fd);
+
+    if(!autosleep_enable) {
+        LOGE("Autosleep not enable.");
+        return -1;
+    }
+
+    int i;
+    for(i=0;i<512;i++)
+    {
+        if(lynq_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", lynq_lock_name[i].name);
+        system(cmd);
+        return 0;
+    }
+    else
+    {
+        printf("/sys/power/wake_lock can not write.");
+        return -1;
+    }
 
     return 0;
 }
 
 int qser_wakelock_unlock(int fd)
 {
-    UNUSED(fd);
+    //UNUSED(fd);
+
+    if(!autosleep_enable) {
+        LOGE("Autosleep not enable.");
+        return -1;
+    }
+
+    int i;
+    for(i=0;i<512;i++)
+    {
+        if(lynq_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", lynq_lock_name[i].name);
+        system(cmd);
+        return 0;
+    }
+    else
+    {
+        printf("/sys/power/wake_unlock can not write.");
+        return -1;
+    }
 
     return 0;
 }
 
 int qser_wakelock_destroy(int fd)
 {
-    UNUSED(fd);
+    //UNUSED(fd);
+
+    if(!autosleep_enable) {
+        LOGE("Autosleep not enable.");
+        return -1;
+    }
+
+    int i;
+    for(i=0;i<512;i++)
+    {
+        if(lynq_lock_name[i].fd == fd)
+        break;
+    }
+    if(i == 512)
+        return -1;
+    else
+    {
+        lynq_lock_name[i].fd = 0;
+        memset(lynq_lock_name[i].name, 0, 128);
+        return 0;
+    }
 
     return 0;
 }
 
 
+int qser_lpm_init(qser_lpm_Handler_t qser_lpm_handler, qser_pm_cfg_t *qser_lpm_cfg)
+{
+    UNUSED(qser_lpm_handler);
+    UNUSED(qser_lpm_cfg);
+
+    //pthread_mutex_init();
+
+
+
+    return 0;
+}
+
+int qser_lpm_deinit(void)
+{
+
+    return 0;
+}
+
+/*
+例如AT*POWERIND=31,就相当于设置NETWORK、SIM、SMS、CS CALL、PS DATA变化时都不主动上报,
+其中PS DATA目前暂时不支持,只是保留了这个标志位;
+AP power state: 1~31 means suspend, bitmap: bit0 - NETWORK;bit1 - SIM;bit2 - SMS;bit3 - CS CALL;bit4 - PS DATA
+0 means resume all.
+目标文件"/system/etc/powerind"
+如果bit0-bit3都配置可以采用的值是1-15,如果是当前采用NETWORK SMS CALL 则值的取值是 1 4 8 5 9 12 13
+
+
+白名单的状态由四位数字组成,第一位代表是否屏蔽电话唤醒,第二
+位代表是否屏蔽网络注册状态唤醒,第三位代表是否屏蔽数据业务唤
+醒,第四位代表是否屏蔽短信唤醒。其中 1 代表屏蔽,其他不会屏
+蔽。
+第一位:1:打开电话唤醒,其他:屏蔽电话唤醒
+第二位:1:打开网络注册状态唤醒,其他:屏蔽网络注册状态唤醒
+第三位:1:打开数据业务唤醒,其他:屏蔽数据业务唤醒
+第四位:1:打开短信唤醒,其他屏蔽短信唤醒
+当四位都不为 1 时(比如默认的状态:0000),则代表白名单为空,
+所有唤醒都不会屏蔽。
+
+从左往右判断
+
+*/
+
+int qser_whitelist_set(char* whitelish)
+{
+    //UNUSED(whitelish);
+    uint32 on = 0;
+    int call_t, nw_t, data_t, sms_t, tmp;
+
+    int len = strlen(whitelish);
+
+    if (len != 4)
+    {
+        printf("whitelish num error.\n");
+    }
+
+    tmp = atoi(whitelish);
+
+    call_t = tmp/1000;
+    nw_t = tmp%1000/100;
+    data_t = tmp%1000%100/10;
+    sms_t = tmp%1000%100%10;
+
+    if (call_t == 1)
+        call_Off = TRUE;
+    else
+        call_Off = FALSE;
+
+    if (nw_t == 1)
+        nw_off = TRUE;
+    else
+        nw_off = FALSE;
+
+    if (data_t == 1)
+        data_off = TRUE;
+    else
+        data_off = FALSE;
+
+    if (sms_t == 1)
+        sms_off = TRUE;
+    else
+        sms_off = FALSE;
+
+    if (call_Off == FALSE && nw_off == FALSE && data_off == FALSE && sms_off == FALSE)
+    {
+        on = 2;//0000的情况,所有上报源都不屏蔽,SIM的上报会一直被包含在内
+    }
+    else
+    {
+        if (call_Off == TRUE)
+            call_t = 8;
+        else
+            call_t = 0;
+
+        if (nw_off == TRUE)
+            nw_t = 1;
+        else
+            nw_t = 0;
+
+        if (data_off == TRUE)
+            data_t = 16;
+        else
+            data_t = 0;
+
+        if (sms_off == TRUE)
+            sms_t = 4;
+        else
+            sms_t = 0;
+
+        on = 31 - (call_t + nw_t + data_t + sms_t);//SIM的上报会一直被包含在内
+    }
+
+    if(whitelist_info_handle == NULL)
+    {
+        whitelist_info_handle = mbtk_info_handle_get();
+        if(whitelist_info_handle)
+        {
+            printf("creat whitelist_info_handle is success\n");
+        }
+        else
+        {
+            printf("creat whitelist_info_handle is fail\n");
+            return -1;
+        }
+    }
+
+    int err = mbtk_wakeup_state_set(whitelist_info_handle, on);
+    if(err)
+    {
+        printf("Error : %d\n", err);
+        return -1;
+    }
+    else
+    {
+        printf("wakeup set success.\n");
+    }
+
+
+    return 0;
+}
+
+
+int qser_whitelist_get(char* whitelish)
+{
+    //UNUSED(whitelish);
+    char *list = NULL;
+    int call_t, nw_t, data_t, sms_t;
+
+    if (call_Off == TRUE)
+        call_t = 1;
+    else
+        call_t = 0;
+    
+    if (nw_off == TRUE)
+        nw_t = 1;
+    else
+        nw_t = 0;
+    
+    if (data_off == TRUE)
+        data_t = 1;
+    else
+        data_t = 0;
+    
+    if (sms_off == TRUE)
+        sms_t = 1;
+    else
+        sms_t = 0;
+
+    sprintf(list,"%d%d%d%d\n",call_t, nw_t, data_t, sms_t);
+    printf(">>>whitelist: %s\n",list);
+    whitelish = list;
+
+    if(whitelist_info_handle != NULL)
+    {
+        mbtk_info_handle_free(&whitelist_info_handle);
+        printf("deinit whitelist_info_handle is succuess\n");
+    }
+
+    return 0;
+}
+
 
diff --git a/mbtk/lynq_lib/src/lynq_sms.c b/mbtk/lynq_lib/src/lynq_sms.c
index bde4083..37cc6a1 100755
--- a/mbtk/lynq_lib/src/lynq_sms.c
+++ b/mbtk/lynq_lib/src/lynq_sms.c
@@ -140,20 +140,6 @@
         return -1;
     }
 
-    //QSER_sms_info_t get_sms_info;
-
-    //get_sms_info.format = pt_sms_info->format;//格式,7/8/UCS2,分别对应英文/彩铃图片/中文
-    //get_sms_info.mode = pt_sms_info->mode;//指定存储位置
-    //get_sms_info.sms_data = pt_sms_info->sms_data;//数据
-    //get_sms_info.sms_data_len = pt_sms_info->sms_data_len;//数据长度
-    //get_sms_info.src_addr = pt_sms_info->src_addr;//电话号码
-    //get_sms_info.storage = pt_sms_info->storage;//存储位置
-    //get_sms_info.storage_index = pt_sms_info->storage_index;//索引
-    //get_sms_info.timestamp = pt_sms_info->timestamp;//时间戳
-    //get_sms_info.type = pt_sms_info->type;//起始/结束/广播
-    //get_sms_info.user_data_head = pt_sms_info->user_data_head;//长短信用户头部信息
-    //get_sms_info.user_data_head_valid = pt_sms_info->user_data_head_valid;//是否是长短信
-
     uint8_t *phone_num = NULL, *data = NULL;
 
     char cmgs[MSM_NUMBER_MAX] = {0};
@@ -192,6 +178,7 @@
     else
     {
         printf("qser_sms_deletefromstorage storage is no Support \n");
+        return -1;
     }
 
     memset(resp, 0, sizeof(resp));
@@ -231,9 +218,9 @@
             memcpy(sms_center_address, "+8613800280500", strlen("+8613800280500"));
         }
 
-        printf("phone_num:%s\n", phone_num);
-        printf("sms_center_address:%s\n", sms_center_address);
-        printf("data:%s\n", data);
+        //printf("phone_num:%s\n", phone_num);
+        //printf("sms_center_address:%s\n", sms_center_address);
+        //printf("data:%s\n", data);
 
         char* pdu = NULL;
         char* smsc = SCAEncoding(sms_center_address);
@@ -392,6 +379,7 @@
     else
     {
         printf("qser_sms_deletefromstorage storage is no Support \n");
+        return -1;
     }
 
     memset(resp, 0, sizeof(resp));
@@ -520,7 +508,7 @@
 
     destNum = get_sca_cfg->service_center_addr;
 
-    printf("1destNum:%s\n", destNum);
+    //printf("1destNum:%s\n", destNum);
     memset(sms_center_address, 0, sizeof(sms_center_address));
     memcpy(sms_center_address, destNum, strlen(destNum));
 
@@ -540,7 +528,7 @@
     {
     //    memset(sms_center_address, 0, sizeof(sms_center_address));
     //    memcpy(sms_center_address, destNum, strlen(destNum));
-        printf("destNum:%s\n", destNum);
+        //printf("destNum:%s\n", destNum);
         printf("qser_sms_setsmscenteraddress success\n");
     }
 
diff --git a/mbtk/mbtk_lib/inc/mbtk_info.h b/mbtk/mbtk_lib/inc/mbtk_info.h
index 7277171..b562cb2 100755
--- a/mbtk/mbtk_lib/inc/mbtk_info.h
+++ b/mbtk/mbtk_lib/inc/mbtk_info.h
@@ -216,6 +216,15 @@
 
     MBTK_INFO_ID_PB_END,
 
+    //wakeup 
+    MBTK_INFO_ID_WAKEUP_STA_REQ,
+    MBTK_INFO_ID_WAKEUP_STA_RSP,
+
+    //oos(out of service))
+    MBTK_INFO_ID_OOS_STA_REQ,
+    MBTK_INFO_ID_OOS_STA_RSP,
+
+
     // IND Information
     MBTK_INFO_ID_IND_BEGIN = 10000,
     // <uint8>  State
diff --git a/mbtk/mbtk_lib/src/mbtk_info_api.c b/mbtk/mbtk_lib/src/mbtk_info_api.c
index 1dafe64..87c55e2 100755
--- a/mbtk/mbtk_lib/src/mbtk_info_api.c
+++ b/mbtk/mbtk_lib/src/mbtk_info_api.c
@@ -2115,6 +2115,49 @@
 }
 
 /*
+* Set wakeup state.
+*
+* wakeup_state:(0~31)
+* 0 : means resume all
+* 1~31 means suspend
+* Control the active reporting of some platform modems to reduce wakeup
+*/
+
+int mbtk_wakeup_state_set(mbtk_info_handle_t* handle, uint32 wakeup_state)
+{
+    return info_item_process(handle, MBTK_INFO_ID_WAKEUP_STA_REQ, (uint32*)&wakeup_state, sizeof(uint32), NULL) ? handle->info_err : 0;
+}
+
+/*
+* oos get.
+*/
+int mbtk_oos_get(mbtk_info_handle_t* handle, mbtk_oos_info *oos_info)
+{
+    if(info_item_process(handle, MBTK_INFO_ID_OOS_STA_REQ, NULL, 0, oos_info) > 0) {
+        return 0;
+    } else {
+        return handle->info_err;
+    }
+}
+
+/*
+* oos set .
+*/
+int mbtk_oos_set(mbtk_info_handle_t* handle, char *oos_info)
+{
+    if(handle == NULL)
+    {
+        LOGE("ARG error.");
+        return -1;
+    }
+    if(str_empty(oos_info))
+        return -1;
+
+    return info_item_process(handle, MBTK_INFO_ID_OOS_STA_REQ, oos_info, strlen(oos_info), NULL) ? handle->info_err : 0;
+}
+
+
+/*
 * Set DTMF character.
 *
 */
diff --git a/mbtk/mbtk_ril/src/mbtk_info_server.c b/mbtk/mbtk_ril/src/mbtk_info_server.c
index 4073f5f..2e06e3d 100755
--- a/mbtk/mbtk_ril/src/mbtk_info_server.c
+++ b/mbtk/mbtk_ril/src/mbtk_info_server.c
@@ -47,6 +47,152 @@
 static char server_ready_status = 0;
 //mbtk wyq for server_ready_status add end
 
+
+/*
+AT*POWERIND=0"
+or
+AT*POWERIND=1~31"
+
+OK
+
+AT*POWERIND=31,就相当于设置NETWORK、SIM、SMS、CS CALL、PS DATA变化时都不主动上报,
+其中PS DATA目前暂时不支持,只是保留了这个标志位,0 means resume all.
+
+AP power state: 1~31 means suspend,
+bitmap:
+bit0 - NETWORK;
+bit1 - SIM;
+bit2 - SMS;
+bit3 - CS CALL
+bit4 - PS DATA
+
+*/
+static int req_powerind_set(uint32 state, int *cme_err)
+{
+    ATResponse *response = NULL;
+    char cmd[100] = {0};
+
+    if (state >= 0 && state < 32)
+    {
+        sprintf(cmd, "AT*POWERIND=%d", state);
+        LOG("Set the powerind command is = %s.\n", cmd);
+    }
+    int err = at_send_command(cmd, &response);
+    if (err < 0 || response->success == 0){
+        *cme_err = at_get_cme_error(response);
+        goto exit;
+    }
+
+exit:
+    at_response_free(response);
+    return err;
+}
+
+/*
+AT+OOSPP=1,20,30,40 //AtOospp()
+ param1:mode
+ param2:oosPhasePeriod[0] //5 times, 5s by default;
+ param3:oosPhasePeriod[1] //5 times, 5s by default;
+ param4:oosPhasePeriod[2] //unlimited, 5s by default;
+
+
+BTW
+1, 如果只输入mode=1,其余参数不设置,相当于这个功能打开,时间间隔是这个功能的默认值。
+2, 如果当mode=1加上其余设置参数后,功能打开,时间间隔是本次设置的值;
+3,如果再设置mode=0,相当于这个功能关闭,是走默认的搜网间隔。
+
+*/
+static int req_oos_set(char* state, int *cme_err)
+{
+    ATResponse *response = NULL;
+    char cmd[100] = {0};
+    int mode;
+
+    mode = atoi(state);
+    if (mode == 1 || mode == 0)//只有一个值0/1
+    {
+        sprintf(cmd, "AT+OOSPP=%d", mode);
+    }
+    else
+    {
+        sprintf(cmd, "AT+OOSPP=%s", state);
+    }
+
+    LOG("Set the oos command is = %s.\n", cmd);
+    int err = at_send_command(cmd, &response);
+    if (err < 0 || response->success == 0){
+        *cme_err = at_get_cme_error(response);
+        goto exit;
+    }
+
+exit:
+    at_response_free(response);
+    return err;
+}
+
+
+/*
+AT+OOSPP?
+开:
++OOSPP:5,5,5
+关:
++OOSPP:0
+*/
+static int req_oos_get(mbtk_oos_info *req, int *cme_err)
+{
+    ATResponse *response = NULL;
+
+    int err = at_send_command_singleline("AT+CSCA?", "+OOSPP:", &response);
+
+    if (err < 0 || response->success == 0 || !response->p_intermediates){
+        *cme_err = at_get_cme_error(response);
+        goto exit;
+    }
+
+    char *line = response->p_intermediates->line;
+
+    char *tmp_str = NULL;
+    err = at_tok_nextstr(&line, &tmp_str);
+    if (err < 0)
+    {
+        goto exit;
+    }
+
+    LOG("[xiaorui] >>> req_oos_get =[%s]",tmp_str);
+
+    int mode = atoi(tmp_str);
+    if (mode == 0)//关闭状态
+    {
+        req->mode = (uint8)mode;
+    }
+    else//开状态
+    {
+        req->mode = 1;
+
+        req->oosPhase[0] = (uint8)tmp_str;
+        
+        err = at_tok_nextstr(&line, &tmp_str);
+        if (err < 0)
+        {
+            goto exit;
+        }
+        req->oosPhase[1] = (uint8)tmp_str;
+
+        err = at_tok_nextstr(&line, &tmp_str);
+        if (err < 0)
+        {
+            goto exit;
+        }
+        req->oosPhase[2] = (uint8)tmp_str;
+    }
+
+    memcpy(req, tmp_str, strlen(tmp_str));
+
+exit:
+    at_response_free(response);
+    return err;
+}
+
 static void sock_cli_free_func(void *data)
 {
     if (data)
@@ -3708,6 +3854,7 @@
 mbtk_info_err_enum call_pack_req_process(sock_client_info_t* cli_info, mbtk_info_pack_t* pack);
 mbtk_info_err_enum sms_pack_req_process(sock_client_info_t* cli_info, mbtk_info_pack_t* pack);
 mbtk_info_err_enum pb_pack_req_process(sock_client_info_t* cli_info, mbtk_info_pack_t* pack);
+
 //mbtk wyq for data_call_ex add start
 void data_call_bootconn_save(int cid, int bootconn);
 //mbtk wyq for data_call_ex add end
@@ -5062,6 +5209,73 @@
                 }
                 break;
             }
+            case MBTK_INFO_ID_WAKEUP_STA_REQ:
+            {
+                if(pack->data_len == 0 || pack->data == NULL)
+                {
+                    err = MBTK_INFO_ERR_UNSUPPORTED;
+                    LOG("Get POWERIND state UNSUPPORTED.");
+                }
+                else     // Set powerind state.
+                {
+                    uint32 state = *(pack->data);
+                    if(req_powerind_set(state, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON)
+                    {
+                        if(cme_err != MBTK_INFO_ERR_CME_NON) {
+                            err = MBTK_INFO_ERR_CME + cme_err;
+                        } else {
+                            err = MBTK_INFO_ERR_UNKNOWN;
+                        }
+                        LOG("Set POWERIND state fail.");
+                    }
+                    else
+                    {
+                        pack_rsp_send(cli_info->fd, MBTK_INFO_ID_WAKEUP_STA_RSP, NULL, 0);
+                    }
+                }
+                break;
+            }
+            case MBTK_INFO_ID_OOS_STA_REQ:
+            {
+                if(pack->data_len == 0 || pack->data == NULL)
+                {
+                    mbtk_oos_info oos_t;
+                    if(req_oos_get(&oos_t, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON)
+                    {
+                        if(cme_err != MBTK_INFO_ERR_CME_NON) {
+                            err = MBTK_INFO_ERR_CME + cme_err;
+                        } else {
+                            err = MBTK_INFO_ERR_UNKNOWN;
+                        }
+                        LOG("Get SMS OOS fail.");
+                        printf("Get OOS fail\n");
+                    }
+                    else
+                    {
+                        printf("Get OOS suscess\n");
+                        pack_rsp_send(cli_info->fd, MBTK_INFO_ID_OOS_STA_RSP, &oos_t, sizeof(mbtk_oos_info));
+                    }
+                }
+                else     // Set OOS 
+                {
+                    char* state = pack->data;
+                    if(req_oos_set(state, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON)
+                    {
+                        if(cme_err != MBTK_INFO_ERR_CME_NON) {
+                            err = MBTK_INFO_ERR_CME + cme_err;
+                        } else {
+                            err = MBTK_INFO_ERR_UNKNOWN;
+                        }
+                        LOG("Set OOS  fail.");
+                    }
+                    else
+                    {
+                        pack_rsp_send(cli_info->fd, MBTK_INFO_ID_OOS_STA_RSP, NULL, 0);
+                    }
+                }
+                break;
+            }
+
             default:
             {
                 err = MBTK_INFO_ERR_REQ_UNKNOWN;
diff --git a/mbtk/test/asr1806/lynq_sleep_test.c b/mbtk/test/asr1806/lynq_sleep_test.c
new file mode 100755
index 0000000..c390fe1
--- /dev/null
+++ b/mbtk/test/asr1806/lynq_sleep_test.c
@@ -0,0 +1,124 @@
+#include "lynq-qser-autosuspend.h"
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stddef.h>
+#include "mbtk_type.h"
+#include "mbtk_log.h"
+
+
+static void qser_lpm_handler(qser_lpm_edge_t edge_state)
+{
+ printf("this is qser_lpm_handler, edge_state=%d\n", edge_state);
+}
+
+
+int main(int argc, char *argv[])
+{
+    char operator[10];
+    int opt;
+    int lv_voll = 0;
+    int fd_t;
+
+
+    while(1)
+    {
+        printf("=========sleep main=========\n"
+            "\t0 exit\n"
+            "\t1 autosuspend enable\n"
+            "\t2 wakelock create\n"
+            "\t3 wakelock lock\n"
+            "\t4 wakelock unlock\n"
+            "\t5 wakelock destroy\n"
+            "\t6 whitelist set\n"
+            "\t7 whitelist get\n"
+            "\t6 lpm init\n"
+            "\t7 lpm destroy\n"
+            "operator: >> \n");
+
+        fgets(operator, sizeof(operator), stdin);
+        fflush(stdin);
+        opt = atoi(operator);
+        switch (opt)
+        {
+        case 0:
+            printf("main exit\n");
+            return 0;
+        case 1:
+            {
+            int en;
+            printf(">>>>>Input 0 or 1<<<<<\n");
+            memset(operator, 0x00, sizeof(operator));
+            fgets(operator, sizeof(operator), stdin);
+            fflush(stdin);
+            en = atoi(operator);
+            if (en == 0 || en == 1)
+            {
+                qser_autosuspend_enable(en);
+            }
+            else
+                printf(">>>>>Input 0 or 1 error<<<<<\n");
+            break;
+            }
+        case 2:
+            {
+            char *t_name = NULL;
+            char t_operator[128];
+            int len_name;
+            memset(t_operator, 0x00, sizeof(t_operator));
+            fgets(t_operator, sizeof(t_operator), stdin);
+            fflush(stdin);
+            len_name = strlen(t_operator);
+            strncpy(t_name, t_operator, len_name);
+
+            fd_t = qser_wakelock_create(t_operator, len_name);
+            break;
+            }
+        case 3:
+            qser_wakelock_lock(fd_t);
+            break;
+        case 4:
+            qser_wakelock_unlock(fd_t);
+            break;
+        case 5:
+            qser_wakelock_destroy(fd_t);
+            break;
+        case 6:
+            {
+            char* whitelish = NULL;
+            memset(operator, 0x00, sizeof(operator));
+            fgets(operator, sizeof(operator), stdin);
+            fflush(stdin);
+            strcpy(whitelish, operator);
+            qser_whitelist_set(whitelish);
+            }
+            break;
+        case 7:
+            {
+            char* whitelish = NULL;
+            qser_whitelist_get(whitelish);
+            printf(">>>server list = %s\n", whitelish);
+            }
+            break;
+        case 8:
+            {
+            qser_pm_cfg_t *qser_lpm_cfg = NULL;
+            qser_lpm_cfg = (qser_pm_cfg_t *)malloc(sizeof(qser_pm_cfg_t));
+            qser_lpm_cfg->wakeupin.wakeupin_pin = 50;
+            qser_lpm_cfg->wakeupin.wakeupin_edge = E_QL_LPM_FALLING;
+            qser_lpm_init(qser_lpm_handler, qser_lpm_cfg);
+            }
+            break;
+        case 9:
+            qser_lpm_deinit();
+            break;
+
+        default:
+            break;
+        }
+
+    }
+
+    return 0;
+}
+