packet buffer added

This commit is contained in:
richonguzman 2023-09-05 01:08:18 -03:00
parent 93ada6a7cd
commit c6094c59e8
5 changed files with 46 additions and 4 deletions

View file

@ -1,6 +1,6 @@
{
"callsign": "CD2RXU-11",
"stationMode": 2,
"stationMode": 3,
"iGateComment": "LoRa_APRS_iGate",
"wifi": {
"AP": [
@ -18,8 +18,8 @@
},
"digi": {
"comment": "LoRa_APRS_Digirepeater",
"latitude": 0.0000000,
"longitude": 0.0000000
"latitude": -32.8805195,
"longitude": -71.4282433
},
"aprs_is": {
"passcode": "23201",

View file

@ -20,7 +20,7 @@
Configuration Config;
WiFiClient espClient;
String versionDate = "2023.09.03";
String versionDate = "2023.09.05";
int myWiFiAPIndex = 0;
int myWiFiAPSize = Config.wifiAPs.size();
WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex];
@ -40,6 +40,8 @@ String batteryVoltage;
std::vector<String> lastHeardStation;
std::vector<String> lastHeardStation_temp;
std::vector<String> packetBuffer;
std::vector<String> packetBuffer_temp;
String firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, iGateBeaconPacket;

View file

@ -29,6 +29,7 @@ void processPacket(String packet) {
Serial.println(" ---> APRS LoRa Packet");
String sender = packet.substring(3,packet.indexOf(">"));
STATION_Utils::updateLastHeard(sender);
STATION_Utils::updatePacketBuffer(packet);
Utils::typeOfPacket(packet, "Digi");
if ((stationMode==3 || stationMode==5) && (packet.indexOf("WIDE1-1") > 10)) {
loraPacket = packet.substring(3);

View file

@ -5,6 +5,8 @@
extern Configuration Config;
extern std::vector<String> lastHeardStation;
extern std::vector<String> lastHeardStation_temp;
extern std::vector<String> packetBuffer;
extern std::vector<String> packetBuffer_temp;
extern String fourthLine;
namespace STATION_Utils {
@ -63,4 +65,39 @@ bool wasHeard(String station) {
return false;
}
void checkBuffer() {
for (int i=0; i<packetBuffer.size(); i++) {
String deltaTimeString = packetBuffer[i].substring(0,packetBuffer[i].indexOf(","));
uint32_t deltaTime = deltaTimeString.toInt();
if ((millis() - deltaTime) < 60*1000) { // cambiar a 15 segundos?
packetBuffer_temp.push_back(packetBuffer[i]);
}
}
packetBuffer.clear();
for (int j=0; j<packetBuffer_temp.size(); j++) {
packetBuffer.push_back(packetBuffer_temp[j]);
}
packetBuffer_temp.clear();
// BORRAR ESTO !!
for (int i=0; i<packetBuffer.size(); i++) {
Serial.println(packetBuffer[i]);
}
//
}
void updatePacketBuffer(String packet) {
if ((packet.indexOf(":!") == -1) && (packet.indexOf(":=") == -1) && (packet.indexOf(":>") == -1)) {
String sender = packet.substring(3,packet.indexOf(">"));
String tempAddressee = packet.substring(packet.indexOf("::") + 2);
String addressee = tempAddressee.substring(0,tempAddressee.indexOf(":"));
addressee.trim();
String message = tempAddressee.substring(tempAddressee.indexOf(":")+1);
//Serial.println(String(millis()) + "," + sender + "," + addressee + "," + message);
packetBuffer.push_back(String(millis()) + "," + sender + "," + addressee + "," + message);
checkBuffer();
}
}
}

View file

@ -8,6 +8,8 @@ namespace STATION_Utils {
void deleteNotHeard();
void updateLastHeard(String station);
bool wasHeard(String station);
void checkBuffer();
void updatePacketBuffer(String packet);
}