From a69a9d1416403e1a3d3fc23a6d50a45a22179d14 Mon Sep 17 00:00:00 2001 From: sh123 Date: Fri, 29 Jan 2021 15:16:41 +0200 Subject: [PATCH] Add small delay before constructing packet --- loraprs_service.cpp | 8 +++++--- loraprs_service.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/loraprs_service.cpp b/loraprs_service.cpp index 372bab9..4dec39d 100644 --- a/loraprs_service.cpp +++ b/loraprs_service.cpp @@ -75,7 +75,7 @@ void Service::setupWifi(const String &wifiName, const String &wifiKey) WiFi.begin(wifiName.c_str(), wifiKey.c_str()); while (WiFi.status() != WL_CONNECTED) { - delay(500); + delay(CfgConnRetryMs); Serial.print("."); } Serial.println("ok"); @@ -89,7 +89,7 @@ void Service::reconnectWifi() while (WiFi.status() != WL_CONNECTED || WiFi.localIP() == IPAddress(0,0,0,0)) { WiFi.reconnect(); - delay(500); + delay(CfgConnRetryMs); Serial.print("."); } @@ -118,7 +118,7 @@ void Service::setupLora(int loraFreq, int bw, byte sf, byte cr, byte pwr, byte s while (!LoRa.begin(loraFreq)) { Serial.print("."); - delay(500); + delay(CfgConnRetryMs); } LoRa.setSyncWord(sync); LoRa.setSpreadingFactor(sf); @@ -342,6 +342,7 @@ void Service::processTx() } } } + yield(); } } @@ -355,6 +356,7 @@ bool Service::kissProcessCommand(unsigned char rxByte) { switch (rxByte) { case KissCmd::Data: + delay(CfgPollDelayMs); // LoRa may drop packet if removed if (LoRa.beginPacket() == 0) return false; kissState_ = KissState::GetData; break; diff --git a/loraprs_service.h b/loraprs_service.h index 16d1c1a..7763a9d 100644 --- a/loraprs_service.h +++ b/loraprs_service.h @@ -74,6 +74,7 @@ private: const String CfgLoraprsVersion = "LoRAPRS 0.1"; + const int CfgConnRetryMs = 500; const int CfgPollDelayMs = 5; const int CfgLoraTxQueueSize = 1024;