diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index e501d05..9fba14e 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -48,7 +48,7 @@ ___________________________________________________________________*/ #include "A7670_utils.h" #endif -String versionDate = "2025.01.22"; +String versionDate = "2025.02.12"; Configuration Config; WiFiClient espClient; #ifdef HAS_GPS diff --git a/src/ota_utils.cpp b/src/ota_utils.cpp index 992b4f1..c041651 100644 --- a/src/ota_utils.cpp +++ b/src/ota_utils.cpp @@ -48,13 +48,13 @@ namespace OTA_Utils { void onOTAEnd(bool success) { displayToggle(true); lastScreenOn = millis(); - if (success) { - Serial.println("OTA update finished successfully!"); - displayShow("", "", " OTA update success!", "", " Rebooting ...", "", "", 4000); - } else { - Serial.println("There was an error during OTA update!"); - displayShow("", "", " OTA update fail!", "", "", "", "", 4000); - } + + String statusMessage = success ? "OTA update success!" : "OTA update fail!"; + String rebootMessage = success ? "Rebooting ..." : ""; + + Serial.println(success ? "OTA update finished successfully!" : "There was an error during OTA update!"); + displayShow("", "", statusMessage, "", rebootMessage, "", "", 4000); + isUpdatingOTA = false; } diff --git a/src/station_utils.cpp b/src/station_utils.cpp index 8084027..e992cbc 100644 --- a/src/station_utils.cpp +++ b/src/station_utils.cpp @@ -81,13 +81,9 @@ namespace STATION_Utils { lastHeardStations.push_back(lastStation); } - fourthLine = "Stations ("; - fourthLine += String(Config.rememberStationTime); - fourthLine += "min) = "; - if (lastHeardStations.size() < 10) { - fourthLine += " "; - } - fourthLine += String(lastHeardStations.size()); + char buffer[30]; // Adjust size as needed + sprintf(buffer, "Stations (%dmin) = %2d", Config.rememberStationTime, lastHeardStations.size()); + fourthLine = buffer; } bool wasHeard(const String& station) { diff --git a/src/syslog_utils.cpp b/src/syslog_utils.cpp index 5d49f3e..707c4d8 100644 --- a/src/syslog_utils.cpp +++ b/src/syslog_utils.cpp @@ -20,6 +20,10 @@ namespace SYSLOG_Utils { char signalData[35]; snprintf(signalData, sizeof(signalData), " / %ddBm / %.2fdB / %dHz", rssi, snr, freqError); + int colonIndex = packet.indexOf(":"); + char nextChar = packet[colonIndex + 1]; + String sender = packet.substring(3, packet.indexOf(">")); + switch (type) { case 0: // CRC syslogPacket.concat("CRC / CRC-ERROR / "); @@ -28,59 +32,56 @@ namespace SYSLOG_Utils { break; case 1: // RX syslogPacket.concat("RX / "); - if (packet.indexOf("::") > 10) { + if (nextChar == ':') { syslogPacket.concat("MESSAGE / "); - syslogPacket.concat(packet.substring(3, packet.indexOf(">"))); - syslogPacket.concat(" ---> "); syslogPacket.concat(packet.substring(packet.indexOf("::") + 2)); - syslogPacket.concat(signalData); - } else if (packet.indexOf(":!") > 10 || packet.indexOf(":=") > 10) { + syslogPacket.concat(sender); + syslogPacket.concat(" ---> "); + syslogPacket.concat(packet.substring(colonIndex + 2)); + } else if (nextChar == '!' || nextChar == '=') { syslogPacket.concat("GPS / "); - syslogPacket.concat(packet.substring(3, packet.indexOf(">"))); + syslogPacket.concat(sender); syslogPacket.concat(" / "); if (packet.indexOf("WIDE1-1") > 10) { syslogPacket.concat(packet.substring(packet.indexOf(">") + 1, packet.indexOf(","))); syslogPacket.concat(" / WIDE1-1"); } else { - syslogPacket.concat(packet.substring(packet.indexOf(">") + 1, packet.indexOf(":"))); + syslogPacket.concat(packet.substring(packet.indexOf(">") + 1, colonIndex)); syslogPacket.concat(" / -"); } - syslogPacket.concat(signalData); - syslogPacket.concat(" / "); - syslogPacket.concat(GPS_Utils::getDistanceAndComment(packet)); - } else if (packet.indexOf(":>") > 10) { + } else if (nextChar == '>') { syslogPacket.concat("STATUS / "); - syslogPacket.concat(packet.substring(3, packet.indexOf(">"))); + syslogPacket.concat(sender); syslogPacket.concat(" ---> "); - syslogPacket.concat(packet.substring(packet.indexOf(":>") + 2)); - syslogPacket.concat(signalData); - } else if (packet.indexOf(":`") > 10) { + syslogPacket.concat(packet.substring(colonIndex + 2)); + } else if (nextChar == '`') { syslogPacket.concat("MIC-E / "); - syslogPacket.concat(packet.substring(3, packet.indexOf(">"))); + syslogPacket.concat(sender); syslogPacket.concat(" ---> "); - syslogPacket.concat(packet.substring(packet.indexOf(":`") + 2)); - syslogPacket.concat(signalData); + syslogPacket.concat(packet.substring(colonIndex + 2)); + } else if (nextChar == ';') { + syslogPacket.concat("OBJECT / "); + syslogPacket.concat(sender); + syslogPacket.concat(" ---> "); + syslogPacket.concat(packet.substring(colonIndex + 2)); } else if (packet.indexOf(":T#") >= 10 && packet.indexOf(":=/") == -1) { syslogPacket.concat("TELEMETRY / "); - syslogPacket.concat(packet.substring(3, packet.indexOf(">"))); + syslogPacket.concat(sender); syslogPacket.concat(" ---> "); syslogPacket.concat(packet.substring(packet.indexOf(":T#") + 3)); - syslogPacket.concat(signalData); - } else if (packet.indexOf(":;") > 10) { - syslogPacket.concat("OBJECT / "); - syslogPacket.concat(packet.substring(3, packet.indexOf(">"))); - syslogPacket.concat(" ---> "); - syslogPacket.concat(packet.substring(packet.indexOf(":;") + 2)); - syslogPacket.concat(signalData); } else { syslogPacket.concat(packet); - syslogPacket.concat(signalData); + } + syslogPacket.concat(signalData); + if (nextChar == '!' || nextChar == '=') { + syslogPacket.concat(" / "); + syslogPacket.concat(GPS_Utils::getDistanceAndComment(packet)); } break; case 2: // APRSIS TX syslogPacket.concat("APRSIS TX / "); - if (packet.indexOf(":>") > 10) { + if (nextChar == '>') { syslogPacket.concat("StartUp_Status / "); - syslogPacket.concat(packet.substring(packet.indexOf(":>") + 2)); + syslogPacket.concat(packet.substring(colonIndex + 2)); } else { syslogPacket.concat("QUERY / "); syslogPacket.concat(packet); @@ -91,11 +92,11 @@ namespace SYSLOG_Utils { if (packet.indexOf("RFONLY") > 10) { syslogPacket.concat("RFONLY / "); syslogPacket.concat(packet); - } else if (packet.indexOf("::") > 10) { + } else if (nextChar == ':') { syslogPacket.concat("MESSAGE / "); - syslogPacket.concat(packet.substring(0,packet.indexOf(">"))); + syslogPacket.concat(sender); syslogPacket.concat(" ---> "); - syslogPacket.concat(packet.substring(packet.indexOf("::") + 2)); + syslogPacket.concat(packet.substring(colonIndex + 2)); } else { syslogPacket.concat(packet); } diff --git a/src/tnc_utils.cpp b/src/tnc_utils.cpp index 3220a8b..ac85394 100644 --- a/src/tnc_utils.cpp +++ b/src/tnc_utils.cpp @@ -44,16 +44,9 @@ namespace TNC_Utils { } void handleInputData(char character, int bufferIndex) { - String* data; - if (bufferIndex == -1) { - data = &inputSerialBuffer; - } else { - data = &inputServerBuffer[bufferIndex]; - } - if (data->length() == 0 && character != (char)FEND) { - return; - } - + String* data = (bufferIndex == -1) ? &inputSerialBuffer : &inputServerBuffer[bufferIndex]; + if (data->length() == 0 && character != (char)FEND) return; + data->concat(character); if (character == (char)FEND && data->length() > 3) {