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

New MQTT topics that the terminal server will subscribe to for node changes

<nelgin> can I push an intr instruction to a node with mqtt?

node/#/set/status - set the node status value (to an integer)
node/#/set/errors - set the node error counter (to an integer, e.g. "0")
node/#/set/misc - set the node's miscellaneous attributes/flags value
 (hexadecimal values can be set by including "0x" prefix)

The message (payload) doesn't matter for the following topics:
node/#/set/lock - lock a node (no one but sysop can login)
node/#/set/intr - interrupt a node (disconnect a user)
node/#/set/down - down a node (not available for connections)
node/#/set/rerun - rerun a node (reload config upon next connection)
parent 82a3bab7
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #4616 passed
......@@ -25,6 +25,7 @@
#include "startup.h"
#include "xpdatetime.h"
#include "date_str.h"
#include "userdat.h"
const char* server_type_desc(enum server_type type)
{
......@@ -472,6 +473,36 @@ static void mqtt_message_received(struct mosquitto* mosq, void* cbdata, const st
if(mqtt->startup->type == SERVER_TERM) {
bbs_startup_t* bbs_startup = (bbs_startup_t*)mqtt->startup;
for(int i = bbs_startup->first_node; i <= bbs_startup->last_node; i++) {
if(strcmp(msg->topic, mqtt_topic(mqtt, TOPIC_BBS, topic, sizeof(topic), "node/%d/set/status", i)) == 0) {
set_node_status(mqtt->cfg, i, strtoul(msg->payload, NULL, 0));
return;
}
if(strcmp(msg->topic, mqtt_topic(mqtt, TOPIC_BBS, topic, sizeof(topic), "node/%d/set/errors", i)) == 0) {
set_node_errors(mqtt->cfg, i, strtoul(msg->payload, NULL, 0));
return;
}
if(strcmp(msg->topic, mqtt_topic(mqtt, TOPIC_BBS, topic, sizeof(topic), "node/%d/set/misc", i)) == 0) {
set_node_misc(mqtt->cfg, i, strtoul(msg->payload, NULL, 0));
return;
}
if(strcmp(msg->topic, mqtt_topic(mqtt, TOPIC_BBS, topic, sizeof(topic), "node/%d/set/lock", i)) == 0) {
set_node_lock(mqtt->cfg, i, TRUE);
return;
}
if(strcmp(msg->topic, mqtt_topic(mqtt, TOPIC_BBS, topic, sizeof(topic), "node/%d/set/intr", i)) == 0) {
set_node_interrupt(mqtt->cfg, i, TRUE);
return;
}
if(strcmp(msg->topic, mqtt_topic(mqtt, TOPIC_BBS, topic, sizeof(topic), "node/%d/set/down", i)) == 0) {
set_node_down(mqtt->cfg, i, TRUE);
return;
}
if(strcmp(msg->topic, mqtt_topic(mqtt, TOPIC_BBS, topic, sizeof(topic), "node/%d/set/rerun", i)) == 0) {
set_node_rerun(mqtt->cfg, i, TRUE);
return;
}
}
for(int i = bbs_startup->first_node; i <= bbs_startup->last_node; i++) {
mqtt_topic(mqtt, TOPIC_BBS, topic, sizeof(topic), "node/%d/input", i);
if(strcmp(msg->topic, topic) != 0)
......@@ -542,6 +573,7 @@ int mqtt_startup(struct mqtt* mqtt, scfg_t* cfg, struct startup* startup, const
char str[128];
for(int i = bbs_startup->first_node; i <= bbs_startup->last_node; i++) {
mqtt_subscribe(mqtt, TOPIC_BBS, str, sizeof(str), "node/%d/input", i);
mqtt_subscribe(mqtt, TOPIC_BBS, str, sizeof(str), "node/%d/set/#", i);
}
}
mqtt_pub_noval(mqtt, TOPIC_SERVER, "recycle");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment