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

解决了mqtt不上报的bug

parent e29952ad
......@@ -49,14 +49,14 @@ void *thread_exit_time(void *arg) {
pthread_mutex_lock(&g_exit_count_mutex);
g_devcontrol_exit_count++;
pthread_mutex_lock(&g_exit_count_mutex);
if(g_devcontrol_exit_count>=5) {
device_stop(g_device_type);
pthread_mutex_lock(&g_exit_count_mutex);
g_devcontrol_exit_count=6;
pthread_mutex_unlock(&g_exit_count_mutex);
}
pthread_mutex_unlock(&g_exit_count_mutex);
}
return NULL;
}
......@@ -95,6 +95,7 @@ void *thread_open_browser(void *arg) {
//mqtt异常处理,断开自动重连,简单粗暴
void *thread_mqtt_reconnect(void *arg) {
if (mqtt_init() != 0) {
my_zlog_fatal("mqtt_init failed");
return NULL;
......@@ -111,6 +112,7 @@ void *thread_mqtt_reconnect(void *arg) {
g_mqtt_grc = mqtt_create(mosq);
if (g_mqtt_grc != 0) {
my_zlog_warn("mqtt fail ...");
mqtt_clean(mosq);
mosq = NULL;
continue;
......@@ -118,6 +120,7 @@ void *thread_mqtt_reconnect(void *arg) {
g_mqtt_grc = mqtt_cycle(mosq); // 阻塞直到断开
if(g_mqtt_grc !=0 ){
my_zlog_warn("mqtt fail ...");
mqtt_clean(mosq);
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