From bf97a1f2d33a34bb24088fc7e636bd9de8c95085 Mon Sep 17 00:00:00 2001 From: nicolasimeoni <32333383+nicolasimeoni@users.noreply.github.com> Date: Tue, 5 Feb 2019 18:30:10 +0100 Subject: [PATCH] Update _loraModem.ino Modified loraWait() to avoid hangs when tmst is in the past --- ESP-sc-gway/_loraModem.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ESP-sc-gway/_loraModem.ino b/ESP-sc-gway/_loraModem.ino index 0d0c45b..a13eaca 100644 --- a/ESP-sc-gway/_loraModem.ino +++ b/ESP-sc-gway/_loraModem.ino @@ -647,7 +647,8 @@ void loraWait(const uint32_t timestamp) } tmst = tmst + txDelay + adjust; // tmst based on txDelay and spreading factor uint32_t waitTime = tmst - micros(); - if (waitTime<0) { +// if (waitTime<0) { //uint32_t is never negative! If micros() is > tmst, waitTime assume a very big value and the app hangs + if (micros()>tmst) { // test if the tmst is in the past to avoid hangs Serial.println(F("loraWait:: Error wait time < 0")); return; }