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

Set QOS level to 1 (2 doesn't work?)

Remove unnecessary call to JSON.stringify() in non-JSON mode
parent fddec635
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
var mqtt = new MQTT; var mqtt = new MQTT;
var topic = "sbbs/" + system.qwk_id + "/stats"; var topic = "sbbs/" + system.qwk_id + "/stats";
var retain = true; var retain = true;
var qos = 1;
if(!mqtt.connect()) { if(!mqtt.connect()) {
alert(format("Error (%s) connecting to %s:%u" alert(format("Error (%s) connecting to %s:%u"
...@@ -13,13 +14,13 @@ if(!mqtt.connect()) { ...@@ -13,13 +14,13 @@ if(!mqtt.connect()) {
} }
if(argv.indexOf("-json") >= 0) { if(argv.indexOf("-json") >= 0) {
if(!mqtt.publish(retain, topic, JSON.stringify(system.stats))) { if(!mqtt.publish(retain, qos, topic, JSON.stringify(system.stats))) {
alert(format("Error (%s) publishing to %s", mqtt.error_str, topic)); alert(format("Error (%s) publishing to %s", mqtt.error_str, topic));
exit(1); exit(1);
} }
} else { } else {
for(var p in system.stats) { for(var p in system.stats) {
if(!mqtt.publish(retain, topic + "/" + p, JSON.stringify(system.stats[p]))) { if(!mqtt.publish(retain, qos, topic + "/" + p, system.stats[p])) {
alert(format("Error (%s) publishing to %s", mqtt.error_str, topic)); alert(format("Error (%s) publishing to %s", mqtt.error_str, topic));
exit(1); exit(1);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment