diff --git a/common/SH_global.h b/common/SH_global.h index e893d95..c67b7d6 100644 --- a/common/SH_global.h +++ b/common/SH_global.h @@ -20,7 +20,7 @@ enum enumZigBeeTransmitStatus { //#define NR5G_MODULE -//#define Q4G_MODULE +#define Q4G_MODULE //#define WIFI_MODULE //#define NR5G_MEIGE //#define G2UL_GATEWAY @@ -47,6 +47,7 @@ public : static std::string Config_G; //配置文件 static std::string ServerIP; //服务器地址 static int ServerPort; //服务器端口 + static int threadStatus; static std::string UartName_G; static TopicList Topic_G; //发布的主题 static ZigbeeInfo ZigbeeInfo_G; //gateway zigbee info diff --git a/main.cpp b/main.cpp index 1618a43..05a71ff 100644 --- a/main.cpp +++ b/main.cpp @@ -138,7 +138,7 @@ int main(int argc, char *argv[]) startHeart.detach(); int fd = OpenWatchDog(); - + int count = 0; while (GlobalConfig::QuitFlag_G) { #ifdef G2UL_GATEWAY gpio_set(GlobalConfig::GPIO_G.hardWatchDog,1); @@ -147,6 +147,16 @@ int main(int argc, char *argv[]) #endif WriteWatchDog(fd); sleep(20); + if(GlobalConfig::threadStatus == 0){ + count ++; + }else if(GlobalConfig::threadStatus == 1){ + GlobalConfig::threadStatus = 0; + count = 0; + } + if(count >= 180){ + LOG_ERROR("===========threadStatus ========failed \n"); + break; + } // data_publish(senddata.c_str(), GlobalConfig::Topic_G.mPubData.c_str()); } diff --git a/mqttclient/SH_MqttClient.cpp b/mqttclient/SH_MqttClient.cpp index 830d5d0..3a24cc4 100644 --- a/mqttclient/SH_MqttClient.cpp +++ b/mqttclient/SH_MqttClient.cpp @@ -247,7 +247,8 @@ int start_client(const char *boardname, const char *gwid, const char* gwip, cons mosquitto_lib_cleanup(); return 1; } - snprintf(id, len, "mosqsub/%d-%s", getpid(), hostname); + + snprintf(id, len, "mosqsub/%s-%s", GlobalConfig::ZigbeeInfo_G.PanID.c_str(), hostname); if (strlen(id) > MOSQ_MQTT_ID_MAX_LENGTH){ /* Enforce maximum client id length of 23 characters */ id[MOSQ_MQTT_ID_MAX_LENGTH] = '\0'; diff --git a/platform/SH_PlatformInit.cpp b/platform/SH_PlatformInit.cpp index 9201d51..a1be577 100644 --- a/platform/SH_PlatformInit.cpp +++ b/platform/SH_PlatformInit.cpp @@ -23,6 +23,7 @@ std::string GlobalConfig::NR5GTemp = ""; int GlobalConfig::serverStatus = 0; int GlobalConfig::NetSignal = 0; int GlobalConfig::ServerPort = 0; +int GlobalConfig::threadStatus = 1; TopicList GlobalConfig::Topic_G; diff --git a/threadfunc/SH_ThreadFunc.cpp b/threadfunc/SH_ThreadFunc.cpp index 27d2044..fa1ecef 100644 --- a/threadfunc/SH_ThreadFunc.cpp +++ b/threadfunc/SH_ThreadFunc.cpp @@ -50,6 +50,7 @@ void CheckThread() int connectCount = 0; while (GlobalConfig::QuitFlag_G) { + GlobalConfig::threadStatus = 1; if (10 == heart_count) { // StatusPub(); if (GlobalConfig::LinkCount > 30) {