From c6b88db01917f01cad9fa391903ad9eaace55f76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C4=8Cih=C3=A1nek?= Date: Tue, 10 Oct 2023 22:01:17 +0200 Subject: [PATCH] added test device and workspace --- lora-to-mqtt-gateway.code-workspace | 8 ++++++++ src/main.cpp | 27 ++++++++++++--------------- 2 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 lora-to-mqtt-gateway.code-workspace diff --git a/lora-to-mqtt-gateway.code-workspace b/lora-to-mqtt-gateway.code-workspace new file mode 100644 index 0000000..876a149 --- /dev/null +++ b/lora-to-mqtt-gateway.code-workspace @@ -0,0 +1,8 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": {} +} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index f6ebb28..f8aa214 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -345,9 +345,7 @@ void websitePublish() StaticJsonDocument<192> doc; -byte adresses[] = {0, 1}; - -String topics[] = {"lora2mqtt/gateway", "lora2mqtt/meteostation"}; +String topics[] = {"lora2mqtt/gateway", "lora2mqtt/meteostation", "lora2mqtt/bulshit"}; void setup() { @@ -373,28 +371,27 @@ void loop() debug("LoRa Received data: "); debugln(receivedData); deserializeJson(doc, receivedData); - if (!doc["gtw"]) + if (!doc["dest"]) { int addr = doc["addr"]; debugln("Data for Gateway"); debug("Source: "); debugln(topics[addr]); - } - else - { - debugln("Data for diferent device"); - } - - if (mqttPublish(receivedData)) - { - debugln("Published to MQTT!"); - msgToSend = 0; + if (mqttPublish(receivedData)) + { + debugln("Published to MQTT!"); + } + else + { + debugln("MQTT Publish Failed!"); + } } else { - debugln("MQTT Publish Failed!"); + debugln("Data for diferent device"); } + msgToSend = 0; } // server.handleClient();