diff --git a/include/gps_utils.h b/include/gps_utils.h index 384286b..25d7edf 100644 --- a/include/gps_utils.h +++ b/include/gps_utils.h @@ -25,13 +25,7 @@ namespace GPS_Utils { String getiGateLoRaBeaconPacket(); - char *ax25_base91enc(char *s, uint8_t n, uint32_t v); - String encodeGPS(float latitude, float longitude, const String& overlay, const String& symbol); - void generateBeaconFirstPart(); void generateBeacons(); - String decodeEncodedGPS(const String& packet); - String getReceivedGPS(const String& packet); - String getDistanceAndComment(const String& packet); String buildDistanceAndComment(float latitude, float longitude, const String& comment); void setup(); diff --git a/include/network_manager.h b/include/network_manager.h index 086a521..512fc52 100644 --- a/include/network_manager.h +++ b/include/network_manager.h @@ -84,7 +84,6 @@ public: // Ethernet methods bool ethernetConnect(eth_phy_type_t type, uint8_t phy_addr, uint8_t mdc, uint8_t mdio, int power, eth_clock_mode_t clock_mode, bool use_mac_from_efuse = false); bool setEthernetIP(const String& staticIP, const String& gateway, const String& subnet, const String& dns1, const String& dns2); - bool ethernetDisconnect(); IPAddress getEthernetIP() const; String getEthernetMACAddress() const; diff --git a/include/utils.h b/include/utils.h index 0a653bd..68fa1c1 100644 --- a/include/utils.h +++ b/include/utils.h @@ -19,9 +19,9 @@ #ifndef UTILS_H_ #define UTILS_H_ +#include #include - class ReceivedPacket { public: String rxTime; @@ -39,7 +39,8 @@ namespace Utils { void checkBeaconInterval(); void checkDisplayInterval(); void validateFreqs(); - void typeOfPacket(const String& packet, const uint8_t packetType); + void updateLoRaPacketDisplayInfo(APRSPacket& aprsPacket, const uint8_t packetType); + void updateAPRSISPacketDisplayInfo(const String& packet); void print(const String& text); void println(const String& text); void checkRebootMode(); diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index d3e793d..fb84dbe 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -68,7 +68,7 @@ ___________________________________________________________________*/ #endif -String versionDate = "2026-09-22"; +String versionDate = "2026-09-23"; String versionNumber = "4.0.1"; Configuration Config; WiFiClient aprsIsClient; diff --git a/src/aprs_is_utils.cpp b/src/aprs_is_utils.cpp index 9c5af8e..96c6d64 100644 --- a/src/aprs_is_utils.cpp +++ b/src/aprs_is_utils.cpp @@ -199,7 +199,7 @@ namespace APRS_IS_Utils { if (lastAprsPacket.header == "" && lastAprsPacket.path.indexOf("TCPIP") == -1) { if (lastAprsPacket.sender != Config.callsign && Utils::callsignIsValid(lastAprsPacket.sender)) { STATION_Utils::updateLastHeard(lastAprsPacket.sender); - Utils::typeOfPacket(packet.substring(3), 0); // LoRa-APRS + Utils::updateLoRaPacketDisplayInfo(lastAprsPacket, 0); // LoRa-APRS bool queryMessage = false; if (lastAprsPacket.type == 1 && lastAprsPacket.addressee == Config.callsign) { // its a message for me! String AddresseeAndMessage = lastAprsPacket.addressee + ":" + lastAprsPacket.payload; @@ -358,7 +358,7 @@ namespace APRS_IS_Utils { STATION_Utils::addToOutputPacketBuffer(buildPacketToTx(packet, 1)); displayToggle(true); lastScreenOn = currentTime; - Utils::typeOfPacket(packet, 1); // APRS-LoRa + Utils::updateAPRSISPacketDisplayInfo(packet); // APRS-LoRa displayShow(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0); } } @@ -368,7 +368,7 @@ namespace APRS_IS_Utils { STATION_Utils::addToOutputPacketBuffer(buildPacketToTx(packet, 5)); displayToggle(true); lastScreenOn = currentTime; - Utils::typeOfPacket(packet, 1); // APRS-LoRa + Utils::updateAPRSISPacketDisplayInfo(packet); // APRS-LoRa Serial.println(); } else { Serial.println(" ---> Rejected (Time): No Tx"); diff --git a/src/digi_utils.cpp b/src/digi_utils.cpp index 19400c6..a76a21d 100644 --- a/src/digi_utils.cpp +++ b/src/digi_utils.cpp @@ -201,12 +201,12 @@ namespace DIGI_Utils { if (STATION_Utils::isIn25SegHashBuffer(lastAprsPacket.sender, temp.substring(temp.indexOf(":") + 2))) return; STATION_Utils::updateLastHeard(lastAprsPacket.sender); - Utils::typeOfPacket(temp, 2); // Digi + Utils::updateLoRaPacketDisplayInfo(lastAprsPacket, 1); // Digi bool queryMessage = false; if (lastAprsPacket.type == 1) { // MESSAGE if (lastAprsPacket.addressee == stationCallsign) { // it's a message for me! String AddresseeAndMessage = lastAprsPacket.addressee + ":" + lastAprsPacket.payload; - queryMessage = APRS_IS_Utils::processReceivedLoRaMessage(lastAprsPacket.sender, AddresseeAndMessage); + queryMessage = APRS_IS_Utils::processReceivedLoRaMessage(lastAprsPacket.sender, APRSPacketLib::checkForStartingBytes(AddresseeAndMessage)); } } if (queryMessage) return; // answer should not be repeated. diff --git a/src/gps_utils.cpp b/src/gps_utils.cpp index a711535..ef5e974 100644 --- a/src/gps_utils.cpp +++ b/src/gps_utils.cpp @@ -101,83 +101,6 @@ namespace GPS_Utils { } - String decodeEncodedGPS(const String& packet) { - int indexOfExclamation = packet.indexOf(":!"); - int indexOfEqual = packet.indexOf(":="); - - const uint8_t OFFSET = 3; // Offset for encoded data in the packet - String infoGPS; - if (indexOfExclamation > 10) { - infoGPS = packet.substring(indexOfExclamation + OFFSET); - } else if (indexOfEqual > 10) { - infoGPS = packet.substring(indexOfEqual + OFFSET); - } - - float decodedLatitude = APRSPacketLib::decodeBase91EncodedLatitude(infoGPS.substring(0,4)); - float decodedLongitude = APRSPacketLib::decodeBase91EncodedLongitude(infoGPS.substring(4,8)); - - return buildDistanceAndComment(decodedLatitude, decodedLongitude, infoGPS.substring(12)); - } - - String getReceivedGPS(const String& packet) { - int indexOfExclamation = packet.indexOf(":!"); - int indexOfEqual = packet.indexOf(":="); - int indexOfAt = packet.indexOf(":@"); - - String infoGPS; - if (indexOfExclamation > 10) { - infoGPS = packet.substring(indexOfExclamation + 2); - } else if (indexOfEqual > 10) { - infoGPS = packet.substring(indexOfEqual + 2); - } else if (indexOfAt > 10) { - infoGPS = packet.substring(indexOfAt + 9); // 9 = 2+7 (when 7 is timestamp characters) - } - - String Latitude = infoGPS.substring(0,8); // First 8 characters are Latitude - int latitudeColonIndex = Latitude.indexOf("."); - float convertedLatitude = Latitude.substring(0,2).toFloat(); // First 2 digits (Degrees) - convertedLatitude += Latitude.substring(2,4).toFloat() / 60; // Next 2 digits (Minutes) - convertedLatitude += Latitude.substring(latitudeColonIndex + 1, latitudeColonIndex + 3).toFloat() / (60*100); - if (Latitude.endsWith("S")) convertedLatitude = -convertedLatitude; // Handle Southern Hemisphere - - String Longitude = infoGPS.substring(9,18); // Next 9 characters are Longitude - int longitudeColonIndex = Longitude.indexOf("."); - float convertedLongitude = Longitude.substring(0,3).toFloat(); // First 3 digits (Degrees) - convertedLongitude += Longitude.substring(3,5).toFloat() / 60; // Next 2 digits (Minutes) - convertedLongitude += Longitude.substring(longitudeColonIndex + 1, longitudeColonIndex + 3).toFloat() / (60*100); - if (Longitude.endsWith("W")) convertedLongitude = -convertedLongitude; // Handle Western Hemisphere - - return buildDistanceAndComment(convertedLatitude, convertedLongitude, infoGPS.substring(19)); - } - - String getDistanceAndComment(const String& packet) { - int indexOfAt = packet.indexOf(":@"); - if (indexOfAt > 10) return getReceivedGPS(packet); - - int indexOfExclamation = packet.indexOf(":!"); - int indexOfEqual = packet.indexOf(":="); - int baseIndex = - 1; - if (indexOfExclamation > 10) { - baseIndex = indexOfExclamation; - } else if (indexOfEqual > 10) { - baseIndex = indexOfEqual; - } - if (baseIndex == -1) return " _ / _ / _ "; - - int packetLength = packet.length(); - if (baseIndex + 2 >= packetLength) return " _ / _ / _ "; - - // Spec-based: the first character right after the DTI decides the format. - // Uncompressed positions always start with a latitude digit. - // Compressed positions always start with the symbol table id: '/', '\', or an overlay A-Z/a-j. - char firstInfoChar = packet[baseIndex + 2]; - if (firstInfoChar >= '0' && firstInfoChar <= '9') return getReceivedGPS(packet); - if (firstInfoChar == '/' || firstInfoChar == '\\' || - (firstInfoChar >= 'A' && firstInfoChar <= 'Z') || - (firstInfoChar >= 'a' && firstInfoChar <= 'j')) return decodeEncodedGPS(packet); - return " _ / _ / _ "; - } - void setup() { #ifdef HAS_GPS if (Config.beacon.gpsActive && Config.digi.ecoMode != 1) { diff --git a/src/utils.cpp b/src/utils.cpp index 0bb22b4..4435f29 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -325,21 +325,65 @@ namespace Utils { } } - void typeOfPacket(const String& packet, const uint8_t packetType) { + void updateLoRaPacketDisplayInfo(APRSPacket& aprsPacket, const uint8_t packetType) { switch (packetType) { case 0: // LoRa-APRS fifthLine = "LoRa Rx ----> APRS-IS"; break; - case 1: // APRS-LoRa - fifthLine = "APRS-IS ----> LoRa Tx"; - break; - case 2: // Digipeater + case 1: // Digipeater fifthLine = "LoRa Rx ----> LoRa Tx"; break; } - int firstColonIndex = packet.indexOf(":"); - char nextChar = packet[firstColonIndex + 1]; + String sender = aprsPacket.sender; + for (int i = sender.length(); i < 9; i++) { + sender += " "; + } + sixthLine = sender; + + switch (aprsPacket.type) { + case 1: // MESSAGE + sixthLine += "> MESSAGE"; + break; + case 2: // STATUS + sixthLine += "> NEW STATUS"; + break; + case 0: // GPS + sixthLine += "> GPS BEACON"; + if (!Config.syslog.active) GPS_Utils::buildDistanceAndComment(aprsPacket.latitude, aprsPacket.longitude, aprsPacket.payload); + seventhLine = "RSSI:"; + seventhLine += String(rssi); + seventhLine += "dBm"; + seventhLine += (rssi <= -100) ? " " : " "; + if (distance.indexOf(".") == 1) seventhLine += " "; + seventhLine += "D:"; + seventhLine += distance; + seventhLine += "km"; + break; + case 3: // TELEMETRY + sixthLine += "> TELEMETRY"; + break; + case 4: // MIC-E + sixthLine += "> MIC-E"; + break; + case 5: // OBJECT + sixthLine += "> OBJECT"; + break; + default: // unrecognized + sixthLine += "> ?????????"; + break; + } + if (aprsPacket.type != 0) { // Common assignment for non-GPS cases + seventhLine = "RSSI:"; + seventhLine += String(rssi); + seventhLine += "dBm SNR: "; + seventhLine += String(snr); + seventhLine += "dBm"; + } + } + + void updateAPRSISPacketDisplayInfo(const String& packet) { + fifthLine = "APRS-IS ----> LoRa Tx"; String sender = packet.substring(0,packet.indexOf(">")); for (int i = sender.length(); i < 9; i++) { @@ -347,37 +391,12 @@ namespace Utils { } sixthLine = sender; - if (nextChar == ':') { + if (packet.indexOf("::") > 0) { sixthLine += "> MESSAGE"; - } else if (nextChar == '>') { - sixthLine += "> NEW STATUS"; - } else if (nextChar == '!' || nextChar == '=' || nextChar == '@') { - sixthLine += "> GPS BEACON"; - if (!Config.syslog.active) GPS_Utils::getDistanceAndComment(packet); // to be checked!!! - seventhLine = "RSSI:"; - seventhLine += String(rssi); - seventhLine += "dBm"; - seventhLine += (rssi <= -100) ? " " : " "; - if (distance.indexOf(".") == 1) seventhLine += " "; - seventhLine += "D:"; - seventhLine += distance; - seventhLine += "km"; - } else if (nextChar == '`' || nextChar == '\'') { - sixthLine += "> MIC-E"; - } else if (nextChar == ';') { - sixthLine += "> OBJECT"; - } else if (packet.indexOf(":T#") >= 10 && packet.indexOf(":=/") == -1) { - sixthLine += "> TELEMETRY"; } else { - sixthLine += "> ??????????"; - } - if (nextChar != '!' && nextChar != '=' && nextChar != '@') { // Common assignment for non-GPS cases - seventhLine = "RSSI:"; - seventhLine += String(rssi); - seventhLine += "dBm SNR: "; - seventhLine += String(snr); - seventhLine += "dBm"; + sixthLine += "> OBJECT"; } + seventhLine = ""; } void print(const String& text) {