From f6481400498c13b93f1657fe77d20016ff4cdb88 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Tue, 6 Jun 2023 14:26:17 -0400 Subject: [PATCH] repack update last heard stations --- data/igate_conf.json | 1 + src/LoRa_APRS_iGate.cpp | 66 +++++------------------------------------ src/configuration.cpp | 1 + src/configuration.h | 1 + src/station_utils.cpp | 50 +++++++++++++++++++++++++++---- src/station_utils.h | 4 ++- 6 files changed, 59 insertions(+), 64 deletions(-) diff --git a/data/igate_conf.json b/data/igate_conf.json index d6f1848..301248c 100644 --- a/data/igate_conf.json +++ b/data/igate_conf.json @@ -39,6 +39,7 @@ }, "other": { "beaconInterval": 15, + "rememberStationTime": 30, "statusAfterBoot": true, "defaultStatus": "https://github.com/richonguzman/LoRa_APRS_iGate" } diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 10b4ed1..d14aa24 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -9,6 +9,7 @@ #include "wifi_utils.h" #include "aprs_is_utils.h" #include "gps_utils.h" +#include "station_utils.h" #include "utils.h" /*#include @@ -50,56 +51,6 @@ String createAPRSPacket(String unprocessedPacket) { return processedPacket; } -bool checkValidHeardStation(String station) { - bool validStation = false; - for (int i=0; i Listened Station"); - } - } - if (!validStation) { - Serial.println(" ---> Station not Heard for last 30 min (Not Tx)\n"); - } - return validStation; -} - -void deleteNotHeardStation() { - uint32_t minReportingTime = 30*60*1000; // 30 minutes // from .json and CONFIGURATION????? - for (int i=0; i Uploaded to APRS-IS"); - deleteNotHeardStation(); - updateLastHeardStation(Sender); + //STATION_Utils::deleteNotHeardStation(); + //updateLastHeardStation(Sender); + STATION_Utils::updateLastHeard(Sender); if (aprsPacket.indexOf("::") >= 10) { show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> MESSAGE", 1000); } else if (aprsPacket.indexOf(":>") >= 10) { @@ -206,7 +158,6 @@ String processAPRSISPacket(String aprsisMessage) { firstPart = aprsisMessage.substring(0, aprsisMessage.indexOf(",")); messagePart = aprsisMessage.substring(aprsisMessage.indexOf("::")+2); newLoraPacket = firstPart + ",TCPIP," + Config.callsign + "::" + messagePart; - Serial.print("Received from APRS-IS : " + aprsisMessage); return newLoraPacket; } @@ -249,7 +200,7 @@ void loop() { if (!espClient.connected()) { APRS_IS_Utils::connect(); } - secondLine = APRS_IS_Utils::checkStatus();// "WiFi: " + wifiState + "/ APRS-IS: " + aprsisState; + secondLine = APRS_IS_Utils::checkStatus(); show_display(firstLine, secondLine, thirdLine, fourthLine, 0); while (espClient.connected()) { @@ -330,10 +281,9 @@ void loop() { show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> QUERY", 1000); } } else { - newLoraPacket = processAPRSISPacket(aprsisPacket); - deleteNotHeardStation(); - validHeardStation = checkValidHeardStation(Addressee); - if (validHeardStation) { + Serial.print("Received from APRS-IS : " + aprsisPacket); + if (STATION_Utils::wasHeard(Addressee)) { + newLoraPacket = processAPRSISPacket(aprsisPacket); LoRaUtils::sendNewPacket("APRS", newLoraPacket); display_toggle(true); lastRxTxTime = millis(); diff --git a/src/configuration.cpp b/src/configuration.cpp index aed5a3b..fc01d28 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -32,6 +32,7 @@ void Configuration::readFile(fs::FS &fs, const char *fileName) { callsign = data["callsign"].as(); comment = data["comment"].as(); beaconInterval = data["other"]["beaconInterval"].as(); + rememberStationTime = data["other"]["rememberStationTime"].as(); statusAfterBoot = data["other"]["statusAfterBoot"].as(); defaultStatus = data["other"]["defaultStatus"].as(); diff --git a/src/configuration.h b/src/configuration.h index 37fc2f0..6ae2b04 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -50,6 +50,7 @@ public: String callsign; String comment; int beaconInterval; + int rememberStationTime; bool statusAfterBoot; String defaultStatus; std::vector wifiAPs; diff --git a/src/station_utils.cpp b/src/station_utils.cpp index c2e43fc..5845184 100644 --- a/src/station_utils.cpp +++ b/src/station_utils.cpp @@ -1,18 +1,22 @@ #include "station_utils.h" +#include +#include "configuration.h" /*#include #include "configuration.h" #include "display.h" -extern Configuration Config; + extern WiFiClient espClient; extern int internalLedPin; extern uint32_t lastRxTxTime;*/ +extern Configuration Config; +extern std::vector lastHeardStation; +extern std::vector lastHeardStation_temp; -namespace APRS_IS_Utils { +namespace STATION_Utils { - -void deleteNotHeardStation() { - uint32_t minReportingTime = 30*60*1000; // 30 minutes // from .json and CONFIGURATION????? +void deleteNotHeard() { + uint32_t minReportingTime = Config.rememberStationTime*60*1000; for (int i=0; i Listened Station"); + } + } + if (!validStation) { + Serial.println(" ---> Station not Heard for last 30 min (Not Tx)\n"); + } + return validStation; +} + } \ No newline at end of file diff --git a/src/station_utils.h b/src/station_utils.h index bd9dbbf..2da92d1 100644 --- a/src/station_utils.h +++ b/src/station_utils.h @@ -5,7 +5,9 @@ namespace STATION_Utils { -void deleteNotHeardStation(); +void deleteNotHeard(); +void updateLastHeard(String station); +bool wasHeard(String station); }