From 5678396071e2e2297be8fd9effb9c27efb4d0046 Mon Sep 17 00:00:00 2001 From: Tilen Komel Date: Thu, 6 Jun 2024 09:30:22 +0200 Subject: [PATCH] Added mqtt option mqtt-topic --- src/mqtt.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mqtt.js b/src/mqtt.js index 9c78076..032b9bc 100644 --- a/src/mqtt.js +++ b/src/mqtt.js @@ -31,6 +31,11 @@ const optionsList = [ type: String, description: "MQTT Password (e.g: large4cats)", }, + { + name: "mqtt-topic", + type: String, + description: "MQTT Topic to subscribe to (e.g: msh/#)", + }, { name: "collect-service-envelopes", type: Boolean, @@ -108,6 +113,7 @@ if(options.help){ const mqttBrokerUrl = options["mqtt-broker-url"] ?? "mqtt://mqtt.meshtastic.org"; const mqttUsername = options["mqtt-username"] ?? "meshdev"; const mqttPassword = options["mqtt-password"] ?? "large4cats"; +const mqttTopic = options["mqtt-topic"] ?? "#"; const collectServiceEnvelopes = options["collect-service-envelopes"] ?? false; const collectPositions = options["collect-positions"] ?? false; const collectTextMessages = options["collect-text-messages"] ?? false; @@ -269,7 +275,7 @@ function decrypt(packet) { // subscribe to everything when connected client.on("connect", () => { - client.subscribe("#"); + client.subscribe(mqttTopic); }); // handle message received