上库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.");
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)
{