Merge pull request #41 from KomelT/topic-mqtt-option

added --mqtt-topic option to allow configuring which topic to subscribe to
This commit is contained in:
Liam Cottle
2024-06-06 20:44:23 +12:00
committed by GitHub
2 changed files with 10 additions and 2 deletions

View File

@ -74,6 +74,7 @@ My version of the map is available at https://meshtastic.liamcottle.net
- not affiliated with meshtastic info
- donate link
- login/register to add nodes to the map manually
- need to prevent spam
- captcha for reg
- limit how many nodes can be added from an account
@ -159,7 +160,7 @@ node src/mqtt.js --help
```
Meshtastic MQTT Collector
Collects and processes service envelopes from a Meshtastic MQTT server.
Collects and processes service envelopes from a Meshtastic MQTT server.
Options
@ -167,6 +168,7 @@ Options
--mqtt-broker-url string MQTT Broker URL (e.g: mqtt://mqtt.meshtastic.org)
--mqtt-username string MQTT Username (e.g: meshdev)
--mqtt-password string MQTT Password (e.g: large4cats)
--mqtt-topic MQTT Topic to subscribe to (e.g: msh/#)
--collect-service-envelopes This option will save all received service envelopes to the database.
--collect-text-messages This option will save all received text messages to the database.
--collect-waypoints This option will save all received waypoints to the database.

View File

@ -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