Merge "[Bugfix][T106BUG-654][MONITOR]Unable to trigger callback when SDK and ping exceptions occur"
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-monitor-demo/files/lynq-monitor-demo.cpp b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-monitor-demo/files/lynq-monitor-demo.cpp
index 447f75b..bddc176 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-monitor-demo/files/lynq-monitor-demo.cpp
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-monitor-demo/files/lynq-monitor-demo.cpp
@@ -18,6 +18,19 @@
{
int ret;
char* file_name = "/etc/config/lynq_monitor.cfg";
+
+ ret = lynq_monitor_set_all_state(1);
+ if(ret != 0)
+ {
+ printf("lynq_monitor_set_all_state failed\n");
+ return -1;
+ }
+ ret = lynq_monitor_set_monitor_state(0, 1);
+ if(ret != 0)
+ {
+ printf("lynq_monitor_set_enable failed\n");
+ return -1;
+ }
ret = lynq_monitor_init(file_name);
if(ret != 0)
{
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-monitor/include/lynq_monitor.h b/cap/zx297520v3/src/lynq/lib/liblynq-monitor/include/lynq_monitor.h
index 245a206..bcd26ae 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-monitor/include/lynq_monitor.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-monitor/include/lynq_monitor.h
@@ -33,7 +33,7 @@
/**
* @brief 设置总的监控开关,准备休眠时,FOTA时建议关闭监测和异常状态处理
*
- * @param state 状态,取值为0则不监控,取值为1则继续监控
+ * @param state 状态,取值为0则不监控,取值为1则开始监控
* @return 设置结果,成功返回0,失败返回非0
*/
int lynq_monitor_set_all_state(int state);
@@ -44,7 +44,7 @@
* @param enabled 1表示开启,0表示关闭
* @return 设置结果,成功返回0,失败返回非0
*/
-int lynq_monitor_set_enable(int monitor_type,int enabled);
+int lynq_monitor_set_monitor_state(int monitor_type,int enabled);
#ifdef __cplusplus
}
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-monitor/lynq_monitor.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-monitor/lynq_monitor.cpp
index 85014b1..d4850c2 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-monitor/lynq_monitor.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-monitor/lynq_monitor.cpp
@@ -19,31 +19,29 @@
static void lynq_monitor_config_print(const Lynq_Monitor_Config* config)
{
- LYDBGLOG("Lynq Monitor Config:\n");
- LYDBGLOG(" Network Monitor Enabled: %d\n", config->network_monitor_enabled);
- LYDBGLOG(" Data Monitor Enabled: %d\n", config->data_monitor_enabled);
- LYDBGLOG(" Device Monitor Enabled: %d\n", config->device_monitor_enabled);
- LYDBGLOG(" Ping Monitor Enabled: %d\n", config->ping_monitor_enabled);
- LYDBGLOG(" NW Monitor Period: %d\n", config->nw_monitor_period);
- LYDBGLOG(" Ping Monitor Period: %d\n", config->ping_monitor_period);
- LYDBGLOG(" Limit Reset Nad: %d\n", config->limit_reset_nad_1);
- LYDBGLOG(" Limit Reset NW: %d\n", config->limit_reset_nw_1);
- LYDBGLOG(" Limit Reset Data: %d\n", config->limit_reset_data_1);
- LYDBGLOG(" Limit Reset Nad: %d\n", config->limit_reset_nad_2);
- LYDBGLOG(" Limit Reset NW: %d\n", config->limit_reset_nw_2);
- LYDBGLOG(" Limit Reset Data: %d\n", config->limit_reset_data_2);
- LYDBGLOG(" Opt Reset Nad: %d\n", config->opt_reset_nad);
- LYDBGLOG(" Opt Reset NW: %d\n", config->opt_reset_nw);
- LYDBGLOG(" Opt Reset Data: %d\n", config->opt_reset_data);
+ LYINFLOG("Lynq Monitor Config:\n");
+ LYINFLOG(" Network Monitor Enabled: %d\n", config->network_monitor_enabled);
+ LYINFLOG(" Device Monitor Enabled: %d\n", config->device_monitor_enabled);
+ LYINFLOG(" Ping Monitor Enabled: %d\n", config->ping_monitor_enabled);
+ LYINFLOG(" NW Monitor Period: %d\n", config->nw_monitor_period);
+ LYINFLOG(" Ping Monitor Period: %d\n", config->ping_monitor_period);
+ LYINFLOG(" Limit Reset Nad: %d\n", config->limit_reset_nad_1);
+ LYINFLOG(" Limit Reset NW: %d\n", config->limit_reset_nw_1);
+ LYINFLOG(" Limit Reset Data: %d\n", config->limit_reset_data_1);
+ LYINFLOG(" Limit Reset Nad: %d\n", config->limit_reset_nad_2);
+ LYINFLOG(" Limit Reset NW: %d\n", config->limit_reset_nw_2);
+ LYINFLOG(" Limit Reset Data: %d\n", config->limit_reset_data_2);
+ LYINFLOG(" Opt Reset Nad: %d\n", config->opt_reset_nad);
+ LYINFLOG(" Opt Reset NW: %d\n", config->opt_reset_nw);
+ LYINFLOG(" Opt Reset Data: %d\n", config->opt_reset_data);
- LYDBGLOG(" Ping addr1: %s\n", config->ping_addr1);
- LYDBGLOG(" Ping addr2: %s\n", config->ping_addr2);
- LYDBGLOG(" Ping addr3: %s\n", config->ping_addr3);
+ LYINFLOG(" Ping addr1: %s\n", config->ping_addr1);
+ LYINFLOG(" Ping addr2: %s\n", config->ping_addr2);
+ LYINFLOG(" Ping addr3: %s\n", config->ping_addr3);
}
static void lynq_monitor_config_init()
{
g_monitor_config.network_monitor_enabled = lynq_cfg_get_i("network_monitor_enabled", 1);
- g_monitor_config.data_monitor_enabled = lynq_cfg_get_i("data_monitor_enabled", 1);
g_monitor_config.device_monitor_enabled = lynq_cfg_get_i("device_monitor_enabled", 1);
g_monitor_config.ping_monitor_enabled = lynq_cfg_get_i("ping_monitor_enabled", 1);
g_monitor_config.nw_monitor_period = lynq_cfg_get_i("nw_monitor_period", DEFAULT_NW_MONITOR_PERIOD);
@@ -76,7 +74,9 @@
{
config_file_path = LYNQ_MONITOR_DEFAULT_CONFIG_PATH;
}
- LYDBGLOG("Initializing monitor with config at %s\n", config_file_path);
+ //LYLOGSET(LOG_INFO);
+ //LYLOGEINIT(USER_LOG_TAG);
+ LYINFLOG("Initializing monitor with config at %s\n", config_file_path);
lynq_config_load(config_file_path);
lynq_monitor_config_init();
@@ -94,7 +94,7 @@
int lynq_monitor_register_exception_handler(MonitorExceptionHandler handler)
{
s_ExceptionHandler = handler;
- LYDBGLOG("Exception handler registered.\n");
+ LYINFLOG("Exception handler registered.\n");
return 0;
}
@@ -105,7 +105,7 @@
return -1; // 参数错误
}
g_monitor_state = state;
- LYDBGLOG("Setting all state to %d\n", state);
+ LYINFLOG("Setting all state to %d\n", state);
return 0;
}
@@ -114,22 +114,17 @@
if(monitor_type == 0)//network
{
g_monitor_config.network_monitor_enabled = enabled;
- LYDBGLOG("Network monitoring set to %d\n", enabled);
+ LYINFLOG("Network monitoring set to %d\n", enabled);
}
- else if(monitor_type == 1)//data
- {
- g_monitor_config.data_monitor_enabled = enabled;
- LYDBGLOG("Data monitoring set to %d\n", enabled);
- }
- else if(monitor_type == 2)//device
+ else if(monitor_type == 1)//device
{
g_monitor_config.device_monitor_enabled = enabled;
- LYDBGLOG("Device monitoring set to %d\n", enabled);
+ LYINFLOG("Device monitoring set to %d\n", enabled);
}
- else if(monitor_type == 3)//ping
+ else if(monitor_type == 2)//ping
{
g_monitor_config.ping_monitor_enabled = enabled;
- LYDBGLOG("Ping monitoring set to %d\n", enabled);
+ LYINFLOG("Ping monitoring set to %d\n", enabled);
}
return 0;
}
@@ -146,13 +141,13 @@
}
else
{
- LYDBGLOG("Exception occurred but no handler registered.\n");
+ LYINFLOG("Exception occurred but no handler registered.\n");
}
}
int lynq_monitor_check_state(void)
{
- if (g_monitor_state)
+ if (g_monitor_state == 0)
{
return 1;
}
@@ -161,7 +156,7 @@
int lynq_monitor_need_reset_nad(int exception_type, int error_code)
{
- LYDBGLOG("lynq_monitor_need_reset_nad start\n");
+ LYINFLOG("lynq_monitor_need_reset_nad start\n");
if (lynq_monitor_check_state())
{
return 0;
@@ -173,22 +168,17 @@
}
else if(g_monitor_config.opt_reset_nad == 1)
{
- LYDBGLOG("lynq_monitor_handle_exception ret 1\n");
+ LYINFLOG("lynq_monitor_handle_exception ret 1\n");
lynq_monitor_handle_exception(exception_type, error_code, LYNQ_OPT_RESET_NAD);
return 1;
}
- else if(g_monitor_config.opt_reset_nad == 2)
- {
- lynq_monitor_reset_module();
- return 1;
- }
return -1;
}
int lynq_monitor_need_reset_data(int exception_type, int error_code)
{
- LYDBGLOG("lynq_monitor_need_reset_data start\n");
+ LYINFLOG("lynq_monitor_need_reset_data start\n");
if (lynq_monitor_check_state())
{
return 0;
@@ -208,7 +198,7 @@
}
int lynq_monitor_need_reset_flight_mode(int exception_type, int error_code)
{
- LYDBGLOG("lynq_monitor_need_reset_flight_mode start\n");
+ LYINFLOG("lynq_monitor_need_reset_flight_mode start\n");
if (lynq_monitor_check_state())
{
return 0;
@@ -234,7 +224,7 @@
int lynq_monitor_need_reset_sim(int exception_type, int error_code)
{
- LYDBGLOG("lynq_monitor_need_reset_data start\n");
+ LYINFLOG("lynq_monitor_need_reset_data start\n");
if (lynq_monitor_check_state())
{
return 0;
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-monitor/lynq_monitor_api.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-monitor/lynq_monitor_api.cpp
index 787c80b..c3b0433 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-monitor/lynq_monitor_api.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-monitor/lynq_monitor_api.cpp
@@ -21,13 +21,13 @@
ret = lynq_sim_init(pid);
if(ret != 0)
{
- LYDBGLOG("lynq_sim_init fail. \n");
+ LYERRLOG("lynq_sim_init fail. \n");
return ret;
}
ret = lynq_network_init(pid);
if(ret != 0)
{
- LYDBGLOG("lynq_network_init fail. \n");
+ LYERRLOG("lynq_network_init fail. \n");
return ret;
}
return ret;
@@ -41,20 +41,20 @@
int netType = 0;
int radioTechFam = 0;
int errorCode = -1;
- LYDBGLOG("lynq_monitor_is_network_registered start.\n");
+ LYINFLOG("lynq_monitor_is_network_registered start.\n");
if(lynq_query_registration_state("DATA",®State,&imsRegState,LAC,CID,&netType,&radioTechFam,&errorCode) != 0)
{
- LYDBGLOG("lynq_query_registration_state fail. \n");
+ LYERRLOG("lynq_query_registration_state fail. \n");
return 1;
}
if(regState == 0 || regState == 2 || regState == 3 || regState == 4)
{
- LYDBGLOG("regState: %d is not OK yet, try again. \n",regState);
+ LYERRLOG("regState: %d is not OK yet, try again. \n",regState);
return 0;
}
else
{
- LYDBGLOG("regState: %d is OK.\n",regState);
+ LYERRLOG("regState: %d is OK.\n",regState);
}
return 1;
@@ -65,7 +65,19 @@
int ret = 0;
int sdk_ready;
char buf[4] = "";
- lynq_get_value(LOG_UCI_FILE, "lynq_sdk", "sdk_ready", buf);
+ FILE* pipe = popen("uci get lynq_uci.sdk_ready", "r");
+ if (pipe == NULL)
+ {
+ LYERRLOG("get sdk_ready fail\n");
+ return ret;
+ }
+ if (fgets(buf, sizeof(buf), pipe) == NULL)
+ {
+ LYERRLOG("get sdk_ready fail\n");
+ pclose(pipe);
+ return ret;
+ }
+ pclose(pipe);
sdk_ready=atoi(buf);
if(sdk_ready == 0)
{
@@ -89,19 +101,11 @@
return ret;
}
-int lynq_monitor_reset_module(void)
-{
- int ret;
- LYDBGLOG("lynq_monitor_reset_module start\n");
- sync();
- ret = system("reboot");
- return ret;
-}
int lynq_monitor_reset_flight_mode(void)
{
int ret;
- LYDBGLOG("lynq_monitor_reset_flight_mode start\n");
+ LYINFLOG("lynq_monitor_reset_flight_mode start\n");
ret = lynq_radio_on(NETWORK_RADIO_ON_TYPE_CFUN_0);
sleep(1);
ret = lynq_radio_on(NETWORK_RADIO_ON_TYPE_NORMAL_MODE);
@@ -111,7 +115,7 @@
int lynq_monitor_reset_sim(void)
{
int ret;
- LYDBGLOG("lynq_monitor_reset_sim start\n");
+ LYINFLOG("lynq_monitor_reset_sim start\n");
ret = lynq_reset_sim();
return ret;
}
@@ -121,7 +125,7 @@
char buf[128];
int lock_held = 0;
int ret;
- LYDBGLOG("lynq_monitor_get_lock_state start\n");
+ LYINFLOG("lynq_monitor_get_lock_state start\n");
if(wake_name == NULL)
{
return 0;
@@ -142,7 +146,7 @@
{
fprintf(stderr, "Error: Failed to run command\n");
}
- LYDBGLOG("lynq_monitor_get_lock_state end\n");
+ LYINFLOG("lynq_monitor_get_lock_state end\n");
return lock_held;
}
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-monitor/lynq_monitor_internal.h b/cap/zx297520v3/src/lynq/lib/liblynq-monitor/lynq_monitor_internal.h
index bb72bf0..6f54cbb 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-monitor/lynq_monitor_internal.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-monitor/lynq_monitor_internal.h
@@ -45,7 +45,6 @@
typedef struct
{
int network_monitor_enabled;
- int data_monitor_enabled;
int device_monitor_enabled;
int ping_monitor_enabled;
int nw_monitor_period;
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-monitor/lynq_monitor_nw.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-monitor/lynq_monitor_nw.cpp
index 166238e..7f85775 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-monitor/lynq_monitor_nw.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-monitor/lynq_monitor_nw.cpp
@@ -34,7 +34,7 @@
// 网络注册成功返回1,注册不上返回0
static int lynq_monitor_check_network(void)
{
- LYDBGLOG("s_nw_check_count.nw_error_count %d\n", s_nw_check_count.nw_error_count);
+ LYINFLOG("s_nw_check_count.nw_error_count %d\n", s_nw_check_count.nw_error_count);
if (g_monitor_config.network_monitor_enabled == 0)
{
return 1;
@@ -53,7 +53,6 @@
if (s_nw_check_count.nw_error_count > g_monitor_config.limit_reset_nad_1)
{
- LYDBGLOG("before lynq_monitor_need_reset_nad\n");
lynq_monitor_need_reset_nad(LYNQ_EXCEPTION_TYPE_NW, LYNQ_ERR_NW_TIMEOUT);
lynq_monitor_nw_check_count_reset();
}
@@ -69,7 +68,7 @@
// 运行正常返回1,异常返回0
static int lynq_monitor_check_dev(void)
{
- LYDBGLOG("s_nw_check_count.dev_error_count %d\n", s_nw_check_count.dev_error_count);
+ LYINFLOG("s_nw_check_count.dev_error_count %d\n", s_nw_check_count.dev_error_count);
if (g_monitor_config.device_monitor_enabled == 0)
{
return 1;
@@ -87,7 +86,6 @@
if (s_nw_check_count.dev_error_count > g_monitor_config.limit_reset_nad_1)
{
- LYDBGLOG("before lynq_monitor_need_reset_nad\n");
lynq_monitor_need_reset_nad(LYNQ_EXCEPTION_TYPE_DEV, LYNQ_ERR_DEV_TIMEOUT);
lynq_monitor_nw_check_count_reset();
}
@@ -109,16 +107,16 @@
// 网络状态检测
if (lynq_monitor_check_network())
{
- LYDBGLOG("lynq_monitor_check_network ret 1\n");
+ LYERRLOG("lynq_monitor_check_network ret 1\n");
}
else
{
- LYDBGLOG("lynq_monitor_check_network ret 0\n");
+ LYERRLOG("lynq_monitor_check_network ret 0\n");
}
}
else
{
- LYDBGLOG("lynq_monitor_check_dev ret 0\n");
+ LYERRLOG("lynq_monitor_check_dev ret 0\n");
}
}
@@ -136,7 +134,7 @@
result = pthread_create(&thread_id, NULL, lynq_monitor_network_check_thread, NULL);
if (result != 0)
{
- LYDBGLOG("Error creating network check thread: %s\n", strerror(result));
+ LYERRLOG("Error creating network check thread: %s\n", strerror(result));
return result;
}
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-monitor/lynq_monitor_ping.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-monitor/lynq_monitor_ping.cpp
index 0d799ab..13c8904 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-monitor/lynq_monitor_ping.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-monitor/lynq_monitor_ping.cpp
@@ -58,7 +58,7 @@
{
int ret=0;
int ping_error_count = 0;
- printf("lynq_monitor_ping_check_thread start\n");
+ LYINFLOG("lynq_monitor_ping_check_thread start\n");
while (1)
{
@@ -70,14 +70,14 @@
continue;
}
- if (lynq_monitor_check_state() == 0)
+ if (lynq_monitor_check_state())
{
continue;
}
if (lynq_monitor_is_data_connected() == 0)
{
- LYDBGLOG("lynq_monitor_is_data_connected ret 0\n");
+ LYERRLOG("lynq_monitor_is_data_connected ret 0\n");
ping_error_count = 0;
continue;
}
@@ -85,13 +85,13 @@
// 网络连通性检测
if (lynq_monitor_is_ping_ok())
{
- LYDBGLOG("lynq_monitor_is_ping_ok ret 1\n");
+ LYERRLOG("lynq_monitor_is_ping_ok ret 1\n");
ping_error_count = 0;
continue;
}
else
{
- LYDBGLOG("lynq_monitor_is_ping_ok ret 0\n");
+ LYERRLOG("lynq_monitor_is_ping_ok ret 0\n");
ping_error_count++;
}
@@ -123,7 +123,7 @@
pthread_t thread_id;
if ((result = pthread_create(&thread_id, NULL, lynq_monitor_ping_check_thread, NULL)) != 0)
{
- LYDBGLOG("Error creating ping check thread: %s\n", strerror(result));
+ LYERRLOG("Error creating ping check thread: %s\n", strerror(result));
return result;
}