Skip to content

Commit

Permalink
added test device and workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
Johnymalina committed Oct 10, 2023
1 parent c6c122d commit c6b88db
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
8 changes: 8 additions & 0 deletions lora-to-mqtt-gateway.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"folders": [
{
"path": "."
}
],
"settings": {}
}
27 changes: 12 additions & 15 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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();
Expand Down

0 comments on commit c6b88db

Please sign in to comment.