From 57f720b0d1c7da72664e4f81f5d695c1ac6eef75 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Sat, 16 Nov 2024 08:02:15 -0300 Subject: [PATCH] small code cleaning on 25SecBuffer --- src/LoRa_APRS_iGate.cpp | 2 +- src/station_utils.cpp | 27 ++++++++------------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index e27f821..92ef184 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -48,7 +48,7 @@ ___________________________________________________________________*/ #include "A7670_utils.h" #endif -String versionDate = "2024.11.06"; +String versionDate = "2024.11.16"; Configuration Config; WiFiClient espClient; #ifdef HAS_GPS diff --git a/src/station_utils.cpp b/src/station_utils.cpp index 3eebc28..9ad11e7 100644 --- a/src/station_utils.cpp +++ b/src/station_utils.cpp @@ -72,32 +72,21 @@ namespace STATION_Utils { } void clean25SegBuffer() { - if (!packet25SegBuffer.empty()) { - if ((millis() - packet25SegBuffer[0].receivedTime) > 25 * 1000) { - packet25SegBuffer.erase(packet25SegBuffer.begin()); - } - } + if (!packet25SegBuffer.empty() && (millis() - packet25SegBuffer[0].receivedTime) > 25 * 1000) packet25SegBuffer.erase(packet25SegBuffer.begin()); } bool check25SegBuffer(const String& station, const String& textMessage) { - bool shouldBeIgnored = false; if (!packet25SegBuffer.empty()) { for (int i = 0; i < packet25SegBuffer.size(); i++) { - if (packet25SegBuffer[i].station == station && packet25SegBuffer[i].payload == textMessage) { - shouldBeIgnored = true; - } + if (packet25SegBuffer[i].station == station && packet25SegBuffer[i].payload == textMessage) return false; } } - if (shouldBeIgnored) { - return false; - } else { - Packet25SegBuffer packet; - packet.receivedTime = millis(); - packet.station = station; - packet.payload = textMessage; - packet25SegBuffer.push_back(packet); - return true; - } + Packet25SegBuffer packet; + packet.receivedTime = millis(); + packet.station = station; + packet.payload = textMessage; + packet25SegBuffer.push_back(packet); + return true; } void processOutputPacketBuffer() {