Skip to content

Commit

Permalink
small code cleaning on 25SecBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
richonguzman committed Nov 16, 2024
1 parent 3d01ea0 commit 57f720b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/LoRa_APRS_iGate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 8 additions & 19 deletions src/station_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 57f720b

Please sign in to comment.