上库LYNQ_SLEEP接口以及添加对应测试demo(LPM接口暂时未完成等驱动配合),优化LYNQ_NW模块支持配置飞行模式,配置OOS

Change-Id: Id6e9d9e05d8392348cf567a22c253c3a4e319af5
diff --git a/mbtk/lynq_lib/src/lynq_sleep.c b/mbtk/lynq_lib/src/lynq_sleep.c
index 2b1ef31..b7592bd 100755
--- a/mbtk/lynq_lib/src/lynq_sleep.c
+++ b/mbtk/lynq_lib/src/lynq_sleep.c
@@ -6,6 +6,9 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <pthread.h>
+#include <string.h>
+
 
 #include "mbtk_type.h"
 #include "mbtk_log.h"
@@ -25,6 +28,16 @@
 static bool sms_off = FALSE;
 static bool data_off = FALSE;
 
+pthread_t lpm_t;
+static int edge_t = 0;
+
+typedef struct{
+    qser_lpm_wakeupin_data_t wakeupin;
+    qser_lpm_wakeupout_data_t wakeupout;
+}lynq_wake_t;
+
+static lynq_wake_t lpm_init;
+
 
 static int powerrind_get()
 {
@@ -57,7 +70,6 @@
 static mbtk_info_handle_t* whitelist_info_handle = NULL;
 
 
-
 int qser_autosuspend_enable(char enable)
 {
     //UNUSED(enable);
@@ -217,15 +229,46 @@
     return 0;
 }
 
+void *threadFunction(void *arg)
+{
+    int pinValue;
+    
+
+    edge_t = pinValue;
+    return NULL;
+}
 
 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);
+    //UNUSED(qser_lpm_handler);
+    //UNUSED(qser_lpm_cfg);
 
-    //pthread_mutex_init();
+    lpm_init.wakeupin.wakeupin_pin = qser_lpm_cfg->wakeupin.wakeupin_pin;
+    printf(">>pin = %d",lpm_init.wakeupin.wakeupin_pin);
+    lpm_init.wakeupin.wakeupin_edge = qser_lpm_cfg->wakeupin.wakeupin_edge;
+    printf(">>edge = %d",lpm_init.wakeupin.wakeupin_edge);
+    edge_t = qser_lpm_cfg->wakeupin.wakeupin_edge;//保留原始状态值 0 or 1
 
+    //pthread_attr_t thread_attr;
+    //pthread_attr_init(&thread_attr);
+    /*
+    if(pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED))
+    {
+        printf("pthread_attr_setdetachstate() fail\n");
+        return -1;
+    }
+    */
+    //if(pthread_create(&lpm_t, &thread_attr, threadFunction, NULL))
+    if(pthread_create(&lpm_t, NULL, threadFunction, NULL))
+    {
+        printf("qser_lpm_init can't create thread\n");
+        return -1;
+    }
 
+    //pthread_attr_destroy(&thread_attr);
+
+    if (edge_t != qser_lpm_cfg->wakeupin.wakeupin_edge)//说明有变化,并且和原来的值不相同
+        qser_lpm_handler(edge_t);
 
     return 0;
 }
@@ -233,6 +276,18 @@
 int qser_lpm_deinit(void)
 {
 
+    if(pthread_cancel(lpm_t) != 0)
+    {
+        printf("qser_lpm_deinit pthread_cancel err\n");
+        return -1;
+    }
+
+    if(pthread_join(lpm_t,NULL) != 0)
+    {
+        printf("qser_lpm_deinit pthread_join err\n");
+        return -1;
+    }
+
     return 0;
 }
 
@@ -270,7 +325,8 @@
 
     if (len != 4)
     {
-        printf("whitelish num error.\n");
+        printf("whitelish num error num=[%d]\n",len);
+        return -1;
     }
 
     tmp = atoi(whitelish);
@@ -362,7 +418,7 @@
 int qser_whitelist_get(char* whitelish)
 {
     //UNUSED(whitelish);
-    char *list = NULL;
+    char list[10]={0};
     int call_t, nw_t, data_t, sms_t;
 
     if (call_Off == TRUE)
@@ -385,9 +441,9 @@
     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;
+    sprintf(list, "%d%d%d%d", call_t, nw_t, data_t, sms_t);
+    //printf(">>>whitelist: %s\n",list);
+    strncpy(whitelish, list, strlen(list));
 
     if(whitelist_info_handle != NULL)
     {