Skip to content
Snippets Groups Projects
Commit 417b22d7 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Don't attempt MQTT functions when MQTT is disabled

This is to avoid the error reporting/logging that results.
parent 165a81a4
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
...@@ -569,6 +569,7 @@ bool sbbs_t::update_nodeterm(void) ...@@ -569,6 +569,7 @@ bool sbbs_t::update_nodeterm(void)
} }
strListFree(&ini); strListFree(&ini);
if(cfg.mqtt.enabled) {
char str[256]; char str[256];
char topic[128]; char topic[128];
SAFEPRINTF(topic, "node%u/terminal", cfg.node_num); SAFEPRINTF(topic, "node%u/terminal", cfg.node_num);
...@@ -582,6 +583,7 @@ bool sbbs_t::update_nodeterm(void) ...@@ -582,6 +583,7 @@ bool sbbs_t::update_nodeterm(void)
,console ,console
); );
mqtt_pub_strval(&startup->mqtt, TOPIC_BBS, topic, str); mqtt_pub_strval(&startup->mqtt, TOPIC_BBS, topic, str);
}
return result; return result;
} }
......
...@@ -2481,10 +2481,12 @@ void output_thread(void* arg) ...@@ -2481,10 +2481,12 @@ void output_thread(void* arg)
sem_post(startup->node_spysem[sbbs->cfg.node_num-1]); sem_post(startup->node_spysem[sbbs->cfg.node_num-1]);
} }
/* Spy on the user remotely */ /* Spy on the user remotely */
if(sbbs->cfg.mqtt.enabled) {
int result = mqtt_pub_message(&startup->mqtt, TOPIC_BBS, spy_topic, buf+bufbot, i); int result = mqtt_pub_message(&startup->mqtt, TOPIC_BBS, spy_topic, buf+bufbot, i);
if(result != MQTT_SUCCESS) if(result != MQTT_SUCCESS)
lprintf(LOG_WARNING, "%s ERROR %d (%d) publishing node output (%u bytes): %s" lprintf(LOG_WARNING, "%s ERROR %d (%d) publishing node output (%u bytes): %s"
,node, result, errno, i, spy_topic); ,node, result, errno, i, spy_topic);
}
if(spy_socket[sbbs->cfg.node_num-1]!=INVALID_SOCKET) if(spy_socket[sbbs->cfg.node_num-1]!=INVALID_SOCKET)
(void)sendsocket(spy_socket[sbbs->cfg.node_num-1],(char*)buf+bufbot,i); (void)sendsocket(spy_socket[sbbs->cfg.node_num-1],(char*)buf+bufbot,i);
#ifdef __unix__ #ifdef __unix__
......
...@@ -91,6 +91,7 @@ int sbbs_t::putnodedat(uint number, node_t* node) ...@@ -91,6 +91,7 @@ int sbbs_t::putnodedat(uint number, node_t* node)
} }
pthread_mutex_unlock(&nodefile_mutex); pthread_mutex_unlock(&nodefile_mutex);
if(cfg.mqtt.enabled) {
snprintf(str, sizeof(str), "%u\t%u\t%u\t%u\t%x\t%u\t%u\t%u" snprintf(str, sizeof(str), "%u\t%u\t%u\t%u\t%x\t%u\t%u\t%u"
,node->status ,node->status
,node->action ,node->action
...@@ -105,7 +106,7 @@ int sbbs_t::putnodedat(uint number, node_t* node) ...@@ -105,7 +106,7 @@ int sbbs_t::putnodedat(uint number, node_t* node)
int result = mqtt_pub_strval(&startup->mqtt, TOPIC_BBS, topic, str); int result = mqtt_pub_strval(&startup->mqtt, TOPIC_BBS, topic, str);
if(result != MQTT_SUCCESS) if(result != MQTT_SUCCESS)
lprintf(LOG_WARNING, "ERROR %d (%d) publishing node status: %s", result, errno, topic); lprintf(LOG_WARNING, "ERROR %d (%d) publishing node status: %s", result, errno, topic);
}
if(wr!=sizeof(node_t)) { if(wr!=sizeof(node_t)) {
errno=wrerr; errno=wrerr;
errormsg(WHERE,ERR_WRITE,"nodefile",number+1); errormsg(WHERE,ERR_WRITE,"nodefile",number+1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment