mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-03-28 16:52:33 +01:00
packet buffer added
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user