mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-08-08 01:42:45 +02:00
repack update last heard stations
This commit is contained in:
+45
-5
@@ -1,18 +1,22 @@
|
||||
#include "station_utils.h"
|
||||
#include <vector>
|
||||
#include "configuration.h"
|
||||
/*#include <WiFi.h>
|
||||
#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<String> lastHeardStation;
|
||||
extern std::vector<String> 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<lastHeardStation.size(); i++) {
|
||||
String deltaTimeString = lastHeardStation[i].substring(lastHeardStation[i].indexOf(",")+1);
|
||||
uint32_t deltaTime = deltaTimeString.toInt();
|
||||
@@ -27,4 +31,40 @@ void deleteNotHeardStation() {
|
||||
lastHeardStation_temp.clear();
|
||||
}
|
||||
|
||||
void updateLastHeard(String station) {
|
||||
deleteNotHeard();
|
||||
bool stationHeard = false;
|
||||
for (int i=0; i<lastHeardStation.size(); i++) {
|
||||
if (lastHeardStation[i].substring(0,lastHeardStation[i].indexOf(",")) == station) {
|
||||
lastHeardStation[i] = station + "," + String(millis());
|
||||
stationHeard = true;
|
||||
}
|
||||
}
|
||||
if (!stationHeard) {
|
||||
lastHeardStation.push_back(station + "," + String(millis()));
|
||||
}
|
||||
|
||||
//////
|
||||
Serial.print("Stations Near (last 30 minutes): ");
|
||||
for (int k=0; k<lastHeardStation.size(); k++) {
|
||||
Serial.print(lastHeardStation[k].substring(0,lastHeardStation[k].indexOf(","))); Serial.print(" ");
|
||||
}
|
||||
Serial.println("");
|
||||
}
|
||||
|
||||
bool wasHeard(String station) {
|
||||
deleteNotHeard();
|
||||
bool validStation = false;
|
||||
for (int i=0; i<lastHeardStation.size(); i++) {
|
||||
if (lastHeardStation[i].substring(0,lastHeardStation[i].indexOf(",")) == station) {
|
||||
validStation = true;
|
||||
Serial.println(" ---> Listened Station");
|
||||
}
|
||||
}
|
||||
if (!validStation) {
|
||||
Serial.println(" ---> Station not Heard for last 30 min (Not Tx)\n");
|
||||
}
|
||||
return validStation;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user