From 97ed7877c75c47cb27d3a90c5f208b54de0eeb28 Mon Sep 17 00:00:00 2001
From: Eric Duminil <eric.duminil@gmail.com>
Date: Sun, 27 Dec 2020 16:21:32 +0100
Subject: [PATCH] LoRa: Dont try to send until connected

---
 lorawan.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lorawan.cpp b/lorawan.cpp
index 9765c5f..2e6c407 100644
--- a/lorawan.cpp
+++ b/lorawan.cpp
@@ -184,7 +184,7 @@ namespace lorawan {
   void preparePayloadIfTimeHasCome(const int16_t &co2, const float &temperature, const float &humidity) {
     static unsigned long last_sent_at = 0;
     unsigned long now = seconds();
-    if (now - last_sent_at > config::lorawan_sending_interval) {
+    if (connected && (now > last_sent_at + config::lorawan_sending_interval)) {
       last_sent_at = now;
       preparePayload(co2, temperature, humidity);
     }
-- 
GitLab