Skip to content

Commit

Permalink
Merge pull request #41 from KomelT/topic-mqtt-option
Browse files Browse the repository at this point in the history
added --mqtt-topic option to allow configuring which topic to subscribe to
  • Loading branch information
liamcottle committed Jun 6, 2024
2 parents 1fb6a27 + 5479835 commit b7ce102
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -159,14 +160,15 @@ 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
-h, --help Display this usage guide.
--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.
Expand Down
8 changes: 7 additions & 1 deletion src/mqtt.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -269,7 +275,7 @@ function decrypt(packet) {

// subscribe to everything when connected
client.on("connect", () => {
client.subscribe("#");
client.subscribe(mqttTopic);
});

// handle message received
Expand Down

0 comments on commit b7ce102

Please sign in to comment.