support multiple topics
This commit is contained in:
@ -34,6 +34,8 @@ const optionsList = [
|
|||||||
{
|
{
|
||||||
name: "mqtt-topic",
|
name: "mqtt-topic",
|
||||||
type: String,
|
type: String,
|
||||||
|
multiple: true,
|
||||||
|
typeLabel: '<topic> ...',
|
||||||
description: "MQTT Topic to subscribe to (e.g: msh/#)",
|
description: "MQTT Topic to subscribe to (e.g: msh/#)",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -158,7 +160,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"] ?? "msh/#";
|
const mqttTopics = options["mqtt-topic"] ?? ["msh/#"];
|
||||||
const collectServiceEnvelopes = options["collect-service-envelopes"] ?? false;
|
const collectServiceEnvelopes = options["collect-service-envelopes"] ?? false;
|
||||||
const collectPositions = options["collect-positions"] ?? true;
|
const collectPositions = options["collect-positions"] ?? true;
|
||||||
const collectTextMessages = options["collect-text-messages"] ?? false;
|
const collectTextMessages = options["collect-text-messages"] ?? false;
|
||||||
@ -572,7 +574,9 @@ function decrypt(packet) {
|
|||||||
|
|
||||||
// subscribe to everything when connected
|
// subscribe to everything when connected
|
||||||
client.on("connect", () => {
|
client.on("connect", () => {
|
||||||
client.subscribe(mqttTopic);
|
for(const mqttTopic of mqttTopics){
|
||||||
|
client.subscribe(mqttTopic);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// handle message received
|
// handle message received
|
||||||
|
Reference in New Issue
Block a user