Added mqtt option mqtt-topic

This commit is contained in:
Tilen Komel
2024-06-06 09:30:22 +02:00
parent 1fb6a27ab0
commit 5678396071

View File

@ -31,6 +31,11 @@ const optionsList = [
type: String, type: String,
description: "MQTT Password (e.g: large4cats)", description: "MQTT Password (e.g: large4cats)",
}, },
{
name: "mqtt-topic",
type: String,
description: "MQTT Topic to subscribe to (e.g: msh/#)",
},
{ {
name: "collect-service-envelopes", name: "collect-service-envelopes",
type: Boolean, type: Boolean,
@ -108,6 +113,7 @@ if(options.help){
const mqttBrokerUrl = options["mqtt-broker-url"] ?? "mqtt://mqtt.meshtastic.org"; const mqttBrokerUrl = options["mqtt-broker-url"] ?? "mqtt://mqtt.meshtastic.org";
const mqttUsername = options["mqtt-username"] ?? "meshdev"; const mqttUsername = options["mqtt-username"] ?? "meshdev";
const mqttPassword = options["mqtt-password"] ?? "large4cats"; const mqttPassword = options["mqtt-password"] ?? "large4cats";
const mqttTopic = options["mqtt-topic"] ?? "#";
const collectServiceEnvelopes = options["collect-service-envelopes"] ?? false; const collectServiceEnvelopes = options["collect-service-envelopes"] ?? false;
const collectPositions = options["collect-positions"] ?? false; const collectPositions = options["collect-positions"] ?? false;
const collectTextMessages = options["collect-text-messages"] ?? false; const collectTextMessages = options["collect-text-messages"] ?? false;
@ -269,7 +275,7 @@ function decrypt(packet) {
// subscribe to everything when connected // subscribe to everything when connected
client.on("connect", () => { client.on("connect", () => {
client.subscribe("#"); client.subscribe(mqttTopic);
}); });
// handle message received // handle message received