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

Change-Id: Iaa684b0da9af0f895554f45e30ead62333a816a1
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;