From 445452d7f58b47a0e39bea654bad731c3795dc96 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Wed, 27 Mar 2024 01:28:43 +1300 Subject: [PATCH] add command line arg to collect all service envelopes --- src/mqtt.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mqtt.js b/src/mqtt.js index 6f29252..6b473a1 100644 --- a/src/mqtt.js +++ b/src/mqtt.js @@ -24,12 +24,18 @@ const options = commandLineArgs([ type: String, description: "MQTT Password (e.g: large4cats)", }, + { + name: "collect-service-envelopes", + type: Boolean, + description: "This option will save all received service envelopes to the database.", + }, ]); // get options and fallback to default values const mqttBrokerUrl = options["mqtt-broker-url"] || "mqtt://mqtt.meshtastic.org"; const mqttUsername = options["mqtt-username"] || "meshdev"; const mqttPassword = options["mqtt-password"] || "large4cats"; +const collectServiceEnvelopes = options["collect-service-envelopes"] ?? false; // create mqtt client const client = mqtt.connect(mqttBrokerUrl, { @@ -115,7 +121,7 @@ client.on("message", async (topic, message) => { } // create service envelope in db - if(process.env.MM_COLLECT_SERVICE_ENVELOPES === "true"){ + if(collectServiceEnvelopes){ try { await prisma.serviceEnvelope.create({ data: {