repack update last heard stations
This commit is contained in:
parent
35ad116f68
commit
f648140049
|
|
@ -39,6 +39,7 @@
|
||||||
},
|
},
|
||||||
"other": {
|
"other": {
|
||||||
"beaconInterval": 15,
|
"beaconInterval": 15,
|
||||||
|
"rememberStationTime": 30,
|
||||||
"statusAfterBoot": true,
|
"statusAfterBoot": true,
|
||||||
"defaultStatus": "https://github.com/richonguzman/LoRa_APRS_iGate"
|
"defaultStatus": "https://github.com/richonguzman/LoRa_APRS_iGate"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
#include "wifi_utils.h"
|
#include "wifi_utils.h"
|
||||||
#include "aprs_is_utils.h"
|
#include "aprs_is_utils.h"
|
||||||
#include "gps_utils.h"
|
#include "gps_utils.h"
|
||||||
|
#include "station_utils.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
/*#include <AsyncTCP.h>
|
/*#include <AsyncTCP.h>
|
||||||
|
|
@ -50,56 +51,6 @@ String createAPRSPacket(String unprocessedPacket) {
|
||||||
return processedPacket;
|
return processedPacket;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkValidHeardStation(String station) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
void deleteNotHeardStation() {
|
|
||||||
uint32_t minReportingTime = 30*60*1000; // 30 minutes // from .json and CONFIGURATION?????
|
|
||||||
for (int i=0; i<lastHeardStation.size(); i++) {
|
|
||||||
String deltaTimeString = lastHeardStation[i].substring(lastHeardStation[i].indexOf(",")+1);
|
|
||||||
uint32_t deltaTime = deltaTimeString.toInt();
|
|
||||||
if ((millis() - deltaTime) < minReportingTime) {
|
|
||||||
lastHeardStation_temp.push_back(lastHeardStation[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lastHeardStation.clear();
|
|
||||||
for (int j=0; j<lastHeardStation_temp.size(); j++) {
|
|
||||||
lastHeardStation.push_back(lastHeardStation_temp[j]);
|
|
||||||
}
|
|
||||||
lastHeardStation_temp.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void updateLastHeardStation(String station) {
|
|
||||||
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("");
|
|
||||||
}
|
|
||||||
|
|
||||||
String processQueryAnswer(String query, String station, String queryOrigin) {
|
String processQueryAnswer(String query, String station, String queryOrigin) {
|
||||||
String processedQuery, queryAnswer;
|
String processedQuery, queryAnswer;
|
||||||
if (query=="?APRS?" || query=="?aprs?" || query=="?Aprs?" || query=="H" || query=="h" || query=="Help" || query=="help" || query=="?") {
|
if (query=="?APRS?" || query=="?aprs?" || query=="?Aprs?" || query=="H" || query=="h" || query=="Help" || query=="help" || query=="?") {
|
||||||
|
|
@ -182,8 +133,9 @@ void checkReceivedPacket(String packet) {
|
||||||
lastRxTxTime = millis();
|
lastRxTxTime = millis();
|
||||||
espClient.write(aprsPacket.c_str());
|
espClient.write(aprsPacket.c_str());
|
||||||
Serial.println(" ---> Uploaded to APRS-IS");
|
Serial.println(" ---> Uploaded to APRS-IS");
|
||||||
deleteNotHeardStation();
|
//STATION_Utils::deleteNotHeardStation();
|
||||||
updateLastHeardStation(Sender);
|
//updateLastHeardStation(Sender);
|
||||||
|
STATION_Utils::updateLastHeard(Sender);
|
||||||
if (aprsPacket.indexOf("::") >= 10) {
|
if (aprsPacket.indexOf("::") >= 10) {
|
||||||
show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> MESSAGE", 1000);
|
show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> MESSAGE", 1000);
|
||||||
} else if (aprsPacket.indexOf(":>") >= 10) {
|
} else if (aprsPacket.indexOf(":>") >= 10) {
|
||||||
|
|
@ -206,7 +158,6 @@ String processAPRSISPacket(String aprsisMessage) {
|
||||||
firstPart = aprsisMessage.substring(0, aprsisMessage.indexOf(","));
|
firstPart = aprsisMessage.substring(0, aprsisMessage.indexOf(","));
|
||||||
messagePart = aprsisMessage.substring(aprsisMessage.indexOf("::")+2);
|
messagePart = aprsisMessage.substring(aprsisMessage.indexOf("::")+2);
|
||||||
newLoraPacket = firstPart + ",TCPIP," + Config.callsign + "::" + messagePart;
|
newLoraPacket = firstPart + ",TCPIP," + Config.callsign + "::" + messagePart;
|
||||||
Serial.print("Received from APRS-IS : " + aprsisMessage);
|
|
||||||
return newLoraPacket;
|
return newLoraPacket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -249,7 +200,7 @@ void loop() {
|
||||||
if (!espClient.connected()) {
|
if (!espClient.connected()) {
|
||||||
APRS_IS_Utils::connect();
|
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);
|
show_display(firstLine, secondLine, thirdLine, fourthLine, 0);
|
||||||
|
|
||||||
while (espClient.connected()) {
|
while (espClient.connected()) {
|
||||||
|
|
@ -330,10 +281,9 @@ void loop() {
|
||||||
show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> QUERY", 1000);
|
show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> QUERY", 1000);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newLoraPacket = processAPRSISPacket(aprsisPacket);
|
Serial.print("Received from APRS-IS : " + aprsisPacket);
|
||||||
deleteNotHeardStation();
|
if (STATION_Utils::wasHeard(Addressee)) {
|
||||||
validHeardStation = checkValidHeardStation(Addressee);
|
newLoraPacket = processAPRSISPacket(aprsisPacket);
|
||||||
if (validHeardStation) {
|
|
||||||
LoRaUtils::sendNewPacket("APRS", newLoraPacket);
|
LoRaUtils::sendNewPacket("APRS", newLoraPacket);
|
||||||
display_toggle(true);
|
display_toggle(true);
|
||||||
lastRxTxTime = millis();
|
lastRxTxTime = millis();
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ void Configuration::readFile(fs::FS &fs, const char *fileName) {
|
||||||
callsign = data["callsign"].as<String>();
|
callsign = data["callsign"].as<String>();
|
||||||
comment = data["comment"].as<String>();
|
comment = data["comment"].as<String>();
|
||||||
beaconInterval = data["other"]["beaconInterval"].as<int>();
|
beaconInterval = data["other"]["beaconInterval"].as<int>();
|
||||||
|
rememberStationTime = data["other"]["rememberStationTime"].as<int>();
|
||||||
statusAfterBoot = data["other"]["statusAfterBoot"].as<bool>();
|
statusAfterBoot = data["other"]["statusAfterBoot"].as<bool>();
|
||||||
defaultStatus = data["other"]["defaultStatus"].as<String>();
|
defaultStatus = data["other"]["defaultStatus"].as<String>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ public:
|
||||||
String callsign;
|
String callsign;
|
||||||
String comment;
|
String comment;
|
||||||
int beaconInterval;
|
int beaconInterval;
|
||||||
|
int rememberStationTime;
|
||||||
bool statusAfterBoot;
|
bool statusAfterBoot;
|
||||||
String defaultStatus;
|
String defaultStatus;
|
||||||
std::vector<WiFi_AP> wifiAPs;
|
std::vector<WiFi_AP> wifiAPs;
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,22 @@
|
||||||
#include "station_utils.h"
|
#include "station_utils.h"
|
||||||
|
#include <vector>
|
||||||
|
#include "configuration.h"
|
||||||
/*#include <WiFi.h>
|
/*#include <WiFi.h>
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
|
||||||
extern Configuration Config;
|
|
||||||
extern WiFiClient espClient;
|
extern WiFiClient espClient;
|
||||||
extern int internalLedPin;
|
extern int internalLedPin;
|
||||||
extern uint32_t lastRxTxTime;*/
|
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 deleteNotHeard() {
|
||||||
void deleteNotHeardStation() {
|
uint32_t minReportingTime = Config.rememberStationTime*60*1000;
|
||||||
uint32_t minReportingTime = 30*60*1000; // 30 minutes // from .json and CONFIGURATION?????
|
|
||||||
for (int i=0; i<lastHeardStation.size(); i++) {
|
for (int i=0; i<lastHeardStation.size(); i++) {
|
||||||
String deltaTimeString = lastHeardStation[i].substring(lastHeardStation[i].indexOf(",")+1);
|
String deltaTimeString = lastHeardStation[i].substring(lastHeardStation[i].indexOf(",")+1);
|
||||||
uint32_t deltaTime = deltaTimeString.toInt();
|
uint32_t deltaTime = deltaTimeString.toInt();
|
||||||
|
|
@ -27,4 +31,40 @@ void deleteNotHeardStation() {
|
||||||
lastHeardStation_temp.clear();
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -5,7 +5,9 @@
|
||||||
|
|
||||||
namespace STATION_Utils {
|
namespace STATION_Utils {
|
||||||
|
|
||||||
void deleteNotHeardStation();
|
void deleteNotHeard();
|
||||||
|
void updateLastHeard(String station);
|
||||||
|
bool wasHeard(String station);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue