优化mqtt client ID,在看门狗加了检测线程状态判断,3.2.3
This commit is contained in:
parent
3439188cc4
commit
a0b04aad09
@ -20,7 +20,7 @@ enum enumZigBeeTransmitStatus {
|
|||||||
|
|
||||||
|
|
||||||
//#define NR5G_MODULE
|
//#define NR5G_MODULE
|
||||||
//#define Q4G_MODULE
|
#define Q4G_MODULE
|
||||||
//#define WIFI_MODULE
|
//#define WIFI_MODULE
|
||||||
//#define NR5G_MEIGE
|
//#define NR5G_MEIGE
|
||||||
//#define G2UL_GATEWAY
|
//#define G2UL_GATEWAY
|
||||||
@ -47,6 +47,7 @@ public :
|
|||||||
static std::string Config_G; //配置文件
|
static std::string Config_G; //配置文件
|
||||||
static std::string ServerIP; //服务器地址
|
static std::string ServerIP; //服务器地址
|
||||||
static int ServerPort; //服务器端口
|
static int ServerPort; //服务器端口
|
||||||
|
static int threadStatus;
|
||||||
static std::string UartName_G;
|
static std::string UartName_G;
|
||||||
static TopicList Topic_G; //发布的主题
|
static TopicList Topic_G; //发布的主题
|
||||||
static ZigbeeInfo ZigbeeInfo_G; //gateway zigbee info
|
static ZigbeeInfo ZigbeeInfo_G; //gateway zigbee info
|
||||||
|
12
main.cpp
12
main.cpp
@ -138,7 +138,7 @@ int main(int argc, char *argv[])
|
|||||||
startHeart.detach();
|
startHeart.detach();
|
||||||
|
|
||||||
int fd = OpenWatchDog();
|
int fd = OpenWatchDog();
|
||||||
|
int count = 0;
|
||||||
while (GlobalConfig::QuitFlag_G) {
|
while (GlobalConfig::QuitFlag_G) {
|
||||||
#ifdef G2UL_GATEWAY
|
#ifdef G2UL_GATEWAY
|
||||||
gpio_set(GlobalConfig::GPIO_G.hardWatchDog,1);
|
gpio_set(GlobalConfig::GPIO_G.hardWatchDog,1);
|
||||||
@ -147,6 +147,16 @@ int main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
WriteWatchDog(fd);
|
WriteWatchDog(fd);
|
||||||
sleep(20);
|
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());
|
// data_publish(senddata.c_str(), GlobalConfig::Topic_G.mPubData.c_str());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,8 @@ int start_client(const char *boardname, const char *gwid, const char* gwip, cons
|
|||||||
mosquitto_lib_cleanup();
|
mosquitto_lib_cleanup();
|
||||||
return 1;
|
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){
|
if (strlen(id) > MOSQ_MQTT_ID_MAX_LENGTH){
|
||||||
/* Enforce maximum client id length of 23 characters */
|
/* Enforce maximum client id length of 23 characters */
|
||||||
id[MOSQ_MQTT_ID_MAX_LENGTH] = '\0';
|
id[MOSQ_MQTT_ID_MAX_LENGTH] = '\0';
|
||||||
|
@ -23,6 +23,7 @@ std::string GlobalConfig::NR5GTemp = "";
|
|||||||
int GlobalConfig::serverStatus = 0;
|
int GlobalConfig::serverStatus = 0;
|
||||||
int GlobalConfig::NetSignal = 0;
|
int GlobalConfig::NetSignal = 0;
|
||||||
int GlobalConfig::ServerPort = 0;
|
int GlobalConfig::ServerPort = 0;
|
||||||
|
int GlobalConfig::threadStatus = 1;
|
||||||
|
|
||||||
|
|
||||||
TopicList GlobalConfig::Topic_G;
|
TopicList GlobalConfig::Topic_G;
|
||||||
|
@ -50,6 +50,7 @@ void CheckThread()
|
|||||||
int connectCount = 0;
|
int connectCount = 0;
|
||||||
|
|
||||||
while (GlobalConfig::QuitFlag_G) {
|
while (GlobalConfig::QuitFlag_G) {
|
||||||
|
GlobalConfig::threadStatus = 1;
|
||||||
if (10 == heart_count) {
|
if (10 == heart_count) {
|
||||||
// StatusPub();
|
// StatusPub();
|
||||||
if (GlobalConfig::LinkCount > 30) {
|
if (GlobalConfig::LinkCount > 30) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user