packetSanitization

This commit is contained in:
richonguzman 2024-01-25 22:35:15 -03:00
parent b807ff7321
commit df4e75a00c
2 changed files with 18 additions and 0 deletions

View file

@ -133,6 +133,20 @@ namespace LoRa_Utils {
return firstPart + ",TCPIP,WIDE1-1," + Config.callsign + "::" + messagePart;
}
String packetSanitization(String packet) {
Serial.println(packet);
if (packet.indexOf("\0")>0) {
packet.replace("\0","000");
}
if (packet.indexOf("\r")>0) {
packet.replace("\r","RRR");
}
if (packet.indexOf("\n")>0) {
packet.replace("\n","NNN");
}
return packet;
}
String receivePacket() {
String loraPacket = "";
#if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2) || defined(ESP32_DIY_LoRa) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2)
@ -167,6 +181,9 @@ namespace LoRa_Utils {
}
}
#endif
if ((loraPacket.indexOf("\0")!=-1) || (loraPacket.indexOf("\r")!=-1) || (loraPacket.indexOf("\n")!=-1)) {
loraPacket = packetSanitization(loraPacket);
}
#ifndef TextSerialOutputForApp
if (loraPacket!="") {
Serial.println("(RSSI:" +String(rssi) + " / SNR:" + String(snr) + " / FreqErr:" + String(freqError) + ")");

View file

@ -8,6 +8,7 @@ namespace LoRa_Utils {
void setup();
void sendNewPacket(const String &typeOfMessage, const String &newPacket);
String generatePacket(String aprsisPacket);
String packetSanitization(String packet);
String receivePacket();
void changeFreqTx();
void changeFreqRx();