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

Change-Id: Id6e9d9e05d8392348cf567a22c253c3a4e319af5
diff --git a/mbtk/lynq_lib/src/lynq_network.c b/mbtk/lynq_lib/src/lynq_network.c
index 34f215f..7b5eb9f 100755
--- a/mbtk/lynq_lib/src/lynq_network.c
+++ b/mbtk/lynq_lib/src/lynq_network.c
@@ -10,7 +10,6 @@
 
 nw_client_handle_type g_nw_val = -1;
 
-
 typedef struct
 {
     QSER_NW_RxMsgHandlerFunc_t handlerPtr;
@@ -51,47 +50,32 @@
 
 void lynq_nw_state_change_cb(const void* data, int data_len)
 {
+
+/*
     uint8 *net_data = NULL;
 
     net_data = (uint8*)data;
-    log_hex(">>>data",data,data_len);
 
-    if (net_data == NULL)
+    if(data && data_len > 0)
     {
-        LOG(">>>NO DATA");
+        if(*net_data == 0)
+        { // CS
+                printf("CS:act=%d, mode=%d\n", *(net_data + 1), *(net_data + 2));
+        }
+        else
+        { // PS
+                printf("PS[%s]:act=%d, mode=%d\n", *(net_data + 3) == 0 ? "GSM/WCDMA" : "LTE", *(net_data + 1), *(net_data + 2));
+        }
     }
     else
     {
-        LOG(">>>net_data =[%0x]\n",net_data[2]);
+        printf("NET_CB : NULL");
     }
-    
-/*
-    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)
+    if(lynq_func_cb_handle.handlerPtr != NULL)//数据原样输出
     {
-        mbtk_modem_info_t info;
-        if(*net_data == 5)
-        {
-            info.fun=4;
-        }
-        else
-            info.fun=1;
-        info.rst=0;
-        mbtk_set_modem_fun(lynq_nw_info_handle, &info);
-    }
-    
-    if(lynq_func_cb_handle.handlerPtr != NULL)
-    {
-        //lynq_func_cb_handle.handlerPtr(g_nw_val, NW_IND_VOICE_REG_EVENT_IND_FLAG,&(net_data[2]), sizeof(&(net_data[2])), NULL);
-        lynq_func_cb_handle.handlerPtr(g_nw_val, NW_IND_DATA_REG_EVENT_IND_FLAG,&(net_data[2]), sizeof(&(net_data[2])), NULL);
-        //lynq_func_cb_handle.handlerPtr(g_nw_val, NW_IND_SIGNAL_STRENGTH_EVENT_IND_FLAG,&(net_data[2]), sizeof(&(net_data[2])), NULL);
+        lynq_func_cb_handle.handlerPtr(g_nw_val, NW_IND_DATA_REG_EVENT_IND_FLAG, data, data_len, NULL);
     }
 }
 
@@ -169,7 +153,7 @@
     } else {
         switch(net_mode)
         {
-            //只做234G的only下配 MBTK_NET_PREF_GSM_ONLY/MBTK_NET_PREF_UMTS_ONLY/MBTK_NET_PREF_LTE_ONLY
+            //只做234G的下配 MBTK_NET_PREF_GSM_ONLY/MBTK_NET_PREF_GSM_UMTS_UMTS_PREF/MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF
             case QSER_NW_MODE_GSM:
                 mbtk_net_pre = MBTK_NET_PREF_GSM_ONLY;
                 break;
@@ -584,16 +568,142 @@
 
 int qser_nw_set_oos_config (nw_client_handle_type h_nw, QSER_NW_OOS_CONFIG_INFO_T *pt_info)
 {
-    UNUSED(h_nw);
-    UNUSED(pt_info);
+    //UNUSED(h_nw);
+    //UNUSED(pt_info);
+    if (h_nw != g_nw_val || g_nw_val == -1)
+    {
+        printf("handle NULL\n");
+        return -1;
+    }
+
+    if (pt_info == NULL)
+    {
+        printf("QSER_NW_OOS_CONFIG_INFO_T NULL\n");
+        return -1;
+    }
+
+    uint32 oosPhase_0, oosPhase_1, oosPhase_2;
+    char tmp_type;
+    mbtk_oos_info oos_info;
+
+    memset(&oos_info, 0x00, sizeof(mbtk_oos_info));
+
+
+    tmp_type = pt_info->type;
+
+    if (tmp_type == QSER_NW_OOS_CFG_TYPE_FULL_BAND_SCAN)
+    {//如果没有配置对应的值,例如,10,20
+     //oosPhase_2这个位置没有配置,则使用默认值20,既不限制次数的5s进行一次扫描
+     //同理oosPhase_0,oosPhase_1这个位置没有配置,则使用默认值5,10,既限制次数5次的5s,10s进行一次扫描
+     //输入多少配置多少,可以缺省使用默认值
+        if (pt_info->u.full_band_scan_info.t_min < 0 || pt_info->u.full_band_scan_info.t_step < 0 || pt_info->u.full_band_scan_info.t_max < 0)
+        {
+            printf("qser_nw_set_oos_config set time < 0 \n");
+            return -1;
+        }
+        else if ((pt_info->u.full_band_scan_info.t_min > 0 && pt_info->u.full_band_scan_info.t_min <= 255) && pt_info->u.full_band_scan_info.t_step == 0 && pt_info->u.full_band_scan_info.t_max == 0)
+        {
+            oosPhase_0 = pt_info->u.full_band_scan_info.t_min;
+            oos_info.mode = 1;
+            oos_info.oosPhase[0] = oosPhase_0;
+        }
+        else if ((pt_info->u.full_band_scan_info.t_min > 0 && pt_info->u.full_band_scan_info.t_min <= 255) && (pt_info->u.full_band_scan_info.t_step > 0 && pt_info->u.full_band_scan_info.t_step <= 255) && pt_info->u.full_band_scan_info.t_max == 0)
+        {
+            oosPhase_0 = pt_info->u.full_band_scan_info.t_min;
+            oosPhase_1 = pt_info->u.full_band_scan_info.t_step;
+            oos_info.mode = 1;
+            oos_info.oosPhase[0] = oosPhase_0;
+            oos_info.oosPhase[1] = oosPhase_1;
+        }
+        else if ((pt_info->u.full_band_scan_info.t_min > 0 && pt_info->u.full_band_scan_info.t_min <= 255) && (pt_info->u.full_band_scan_info.t_step > 0 && pt_info->u.full_band_scan_info.t_step <= 255) && (pt_info->u.full_band_scan_info.t_max > 0 && pt_info->u.full_band_scan_info.t_max <= 255))
+        {
+            oosPhase_0 = pt_info->u.full_band_scan_info.t_min;
+            oosPhase_1 = pt_info->u.full_band_scan_info.t_step;
+            oosPhase_2 = pt_info->u.full_band_scan_info.t_max;
+            oos_info.mode = 1;
+            oos_info.oosPhase[0] = oosPhase_0;
+            oos_info.oosPhase[1] = oosPhase_1;
+            oos_info.oosPhase[2] = oosPhase_2;
+        }
+        else if (pt_info->u.full_band_scan_info.t_min == 0 && pt_info->u.full_band_scan_info.t_step == 0 && pt_info->u.full_band_scan_info.t_max == 0)
+        {
+            oos_info.mode = 0;
+        }
+        else
+        {
+            printf("qser_nw_set_oos_config set Format err\n");
+            return -1;
+        }
+
+        int err = mbtk_oos_set(lynq_nw_info_handle, &oos_info);
+        if (err != 0)
+        {
+            printf("qser_nw_set_oos_config mbtk_oos_set err \n");
+            return -1;
+        }
+    }
+    else if (tmp_type == QSER_NW_OOS_CFG_TYPE_FAST_SCAN)
+    {
+        printf("Not currently supported\n");
+        return -1;
+    }
+    else
+    {
+        printf("type is error\n");
+        return -1;
+    }
 
     return 0;
 }
 
 int qser_nw_get_oos_config (nw_client_handle_type h_nw, QSER_NW_OOS_CONFIG_INFO_T *pt_info)
 {
-    UNUSED(h_nw);
-    UNUSED(pt_info);
+    //UNUSED(h_nw);
+    //UNUSED(pt_info);
+    if (h_nw != g_nw_val || g_nw_val == -1)
+    {
+        printf("handle NULL\n");
+        return -1;
+    }
+
+    mbtk_oos_info oos_info;
+    uint32 oosPhase_0, oosPhase_1, oosPhase_2;
+    char cmd[100] = {0};
+
+    memset(&oos_info, 0x00, sizeof(mbtk_oos_info));
+
+    int err = mbtk_oos_get(lynq_nw_info_handle, &oos_info);
+    if (err != 0)
+    {
+        printf("qser_nw_get_oos_config mbtk_oos_get err \n");
+        return -1;
+    }
+
+    printf("oos_info.mode =[%d] \n",oos_info.mode);
+    printf("oos_info.1 =[%d] \n",oos_info.oosPhase[0]);
+    printf("oos_info.2 =[%d] \n",oos_info.oosPhase[1]);
+    printf("oos_info.3 =[%d] \n",oos_info.oosPhase[2]);
+
+    if(oos_info.mode == 0)//关闭状态
+    {
+        pt_info->u.full_band_scan_info.t_min = 0;
+        pt_info->u.full_band_scan_info.t_step = 0;
+        pt_info->u.full_band_scan_info.t_max = 0;
+    }
+    else
+    {
+        pt_info->u.full_band_scan_info.t_min = (int)oos_info.oosPhase[0];
+        pt_info->u.full_band_scan_info.t_step = (int)oos_info.oosPhase[1];
+        pt_info->u.full_band_scan_info.t_max = (int)oos_info.oosPhase[2];
+    }
+    pt_info->type = QSER_NW_OOS_CFG_TYPE_FULL_BAND_SCAN;
+
+
+    if (pt_info == NULL)
+    {
+        printf("qser_nw_get_oos_config pt_info is null \n");
+        return -1;
+    }
 
     return 0;
 }
@@ -603,6 +713,7 @@
     //UNUSED(h_nw);
     //UNUSED(rf_mode);
     int ret;
+    mbtk_modem_info_t info;
 
     if (h_nw != g_nw_val || g_nw_val == -1)
     {
@@ -616,13 +727,24 @@
         return -1;
     }
 
+/*
     if (rf_mode == 4)
     {
         printf("Flight Mode no Support Now\n");
         return -1;
     }
+*/
+    if (rf_mode != 4 && rf_mode != 0 && rf_mode != 1) 
+    {
+        printf("mode is error!\n");
+        return -1;
+    }
 
-    ret = mbtk_radio_state_set(lynq_nw_info_handle, rf_mode);
+    info.fun = rf_mode;
+    info.rst = 0;
+    ret = mbtk_set_modem_fun(lynq_nw_info_handle, &info);
+
+    //ret = mbtk_radio_state_set(lynq_nw_info_handle, rf_mode);
     if (ret != 0)
     {
         LOGE("mbtk_radio_state_set fail.");
@@ -655,7 +777,9 @@
         return -1;
     }
 
-    ret = mbtk_radio_state_get(lynq_nw_info_handle, &tmp_rf);
+    ret = mbtk_get_modem_fun(lynq_nw_info_handle, &tmp_rf);
+
+    //ret = mbtk_radio_state_get(lynq_nw_info_handle, &tmp_rf);
     if (ret != 0)
     {
         LOGE("mbtk_radio_state_get fail.");