Commit 09dce424 authored by 学习的菜鸟's avatar 学习的菜鸟

解决了mqtt不上报的bug

parent e29952ad
...@@ -49,14 +49,14 @@ void *thread_exit_time(void *arg) { ...@@ -49,14 +49,14 @@ void *thread_exit_time(void *arg) {
pthread_mutex_lock(&g_exit_count_mutex); pthread_mutex_lock(&g_exit_count_mutex);
g_devcontrol_exit_count++; g_devcontrol_exit_count++;
pthread_mutex_lock(&g_exit_count_mutex);
if(g_devcontrol_exit_count>=5) { if(g_devcontrol_exit_count>=5) {
device_stop(g_device_type); device_stop(g_device_type);
pthread_mutex_lock(&g_exit_count_mutex);
g_devcontrol_exit_count=6; g_devcontrol_exit_count=6;
pthread_mutex_unlock(&g_exit_count_mutex);
} }
pthread_mutex_unlock(&g_exit_count_mutex);
} }
return NULL; return NULL;
} }
...@@ -95,6 +95,7 @@ void *thread_open_browser(void *arg) { ...@@ -95,6 +95,7 @@ void *thread_open_browser(void *arg) {
//mqtt异常处理,断开自动重连,简单粗暴 //mqtt异常处理,断开自动重连,简单粗暴
void *thread_mqtt_reconnect(void *arg) { void *thread_mqtt_reconnect(void *arg) {
if (mqtt_init() != 0) { if (mqtt_init() != 0) {
my_zlog_fatal("mqtt_init failed"); my_zlog_fatal("mqtt_init failed");
return NULL; return NULL;
...@@ -111,6 +112,7 @@ void *thread_mqtt_reconnect(void *arg) { ...@@ -111,6 +112,7 @@ void *thread_mqtt_reconnect(void *arg) {
g_mqtt_grc = mqtt_create(mosq); g_mqtt_grc = mqtt_create(mosq);
if (g_mqtt_grc != 0) { if (g_mqtt_grc != 0) {
my_zlog_warn("mqtt fail ...");
mqtt_clean(mosq); mqtt_clean(mosq);
mosq = NULL; mosq = NULL;
continue; continue;
...@@ -118,6 +120,7 @@ void *thread_mqtt_reconnect(void *arg) { ...@@ -118,6 +120,7 @@ void *thread_mqtt_reconnect(void *arg) {
g_mqtt_grc = mqtt_cycle(mosq); // 阻塞直到断开 g_mqtt_grc = mqtt_cycle(mosq); // 阻塞直到断开
if(g_mqtt_grc !=0 ){ if(g_mqtt_grc !=0 ){
my_zlog_warn("mqtt fail ...");
mqtt_clean(mosq); mqtt_clean(mosq);
mosq = NULL; mosq = NULL;
} }
......
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment