diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index e775d8f..90e4460 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -52,6 +52,7 @@ std::vector lastHeardStation; std::vector lastHeardStation_temp; std::vector outputPacketBuffer; uint32_t lastTxTime = millis(); +uint32_t lastRxTime = millis(); std::vector receivedPackets; diff --git a/src/aprs_is_utils.cpp b/src/aprs_is_utils.cpp index 4e47ceb..a1eac50 100644 --- a/src/aprs_is_utils.cpp +++ b/src/aprs_is_utils.cpp @@ -21,6 +21,7 @@ extern String sixthLine; extern String seventhLine; extern std::vector outputPacketBuffer; +extern uint32_t lastRxTime; namespace APRS_IS_Utils { @@ -243,6 +244,7 @@ namespace APRS_IS_Utils { String aprsisPacket = espClient.readStringUntil('\r'); // Serial.println(aprsisPacket); processAPRSISPacket(aprsisPacket); + lastRxTime = millis(); } } } diff --git a/src/lora_utils.cpp b/src/lora_utils.cpp index 2810ae3..1ad7222 100644 --- a/src/lora_utils.cpp +++ b/src/lora_utils.cpp @@ -7,13 +7,15 @@ #include "display.h" #include "utils.h" -extern Configuration Config; +extern Configuration Config; +extern uint32_t lastRxTime; + extern std::vector receivedPackets; -bool transmissionFlag = true; -bool ignorePacket = false; -bool operationDone = true; +bool transmissionFlag = true; +bool ignorePacket = false; +bool operationDone = true; #ifdef HAS_SX1262 SX1262 radio = new Module(RADIO_CS_PIN, RADIO_DIO1_PIN, RADIO_RST_PIN, RADIO_BUSY_PIN); @@ -181,6 +183,7 @@ namespace LoRa_Utils { if (Config.syslog.active && WiFi.status() == WL_CONNECTED) { SYSLOG_Utils::log("Rx", loraPacket, rssi, snr, freqError); } + lastRxTime = millis(); return loraPacket; } } else if (state == RADIOLIB_ERR_RX_TIMEOUT) { diff --git a/src/station_utils.cpp b/src/station_utils.cpp index 3f78972..07dcf13 100644 --- a/src/station_utils.cpp +++ b/src/station_utils.cpp @@ -10,6 +10,7 @@ extern std::vector lastHeardStation; extern std::vector lastHeardStation_temp; extern std::vector outputPacketBuffer; extern uint32_t lastTxTime; +extern uint32_t lastRxTime; extern String fourthLine; @@ -63,8 +64,10 @@ namespace STATION_Utils { } void processOutputPacketBuffer() { + int timeToWait = 3 * 1000; // 3 segs between packet Tx and also Rx ??? + uint32_t lastRx = millis() - lastRxTime; uint32_t lastTx = millis() - lastTxTime; - if (outputPacketBuffer.size() == 0 || lastTx < 5 * 1000) { // 5 segs between packet tx ??? + if (outputPacketBuffer.size() == 0 || lastTx < timeToWait || lastRx < timeToWait) { return; } else { LoRa_Utils::sendNewPacket(outputPacketBuffer[0]);