diff --git a/src/LoRa_APRS_Tracker.cpp b/src/LoRa_APRS_Tracker.cpp index b3f6daf..c1060f2 100644 --- a/src/LoRa_APRS_Tracker.cpp +++ b/src/LoRa_APRS_Tracker.cpp @@ -33,7 +33,7 @@ BluetoothSerial SerialBT; OneButton userButton = OneButton(BUTTON_PIN, true, true); #endif -String versionDate = "2023.12.26"; +String versionDate = "2023.12.27"; int myBeaconsIndex = 0; int myBeaconsSize = Config.beacons.size(); @@ -91,6 +91,8 @@ bool disableGPS; bool miceActive = false; +APRSPacket lastReceivedPacket; + logging::Logger logger; void setup() { diff --git a/src/keyboard_utils.cpp b/src/keyboard_utils.cpp index a5d7b7d..109db38 100644 --- a/src/keyboard_utils.cpp +++ b/src/keyboard_utils.cpp @@ -67,7 +67,12 @@ namespace KEYBOARD_Utils { if (menuDisplay < 220) { menuDisplay = 221; } - } else if (menuDisplay >= 60 && menuDisplay <= 61) { + } else if (menuDisplay >= 30 && menuDisplay <= 31) { + menuDisplay--; + if (menuDisplay < 30) { + menuDisplay = 31; + } + }else if (menuDisplay >= 60 && menuDisplay <= 61) { menuDisplay--; if (menuDisplay < 60) { menuDisplay = 61; @@ -133,9 +138,12 @@ namespace KEYBOARD_Utils { menuDisplay = 220; } } - - else if (menuDisplay == 30) { - menuDisplay = 3; + + else if (menuDisplay >= 30 && menuDisplay <= 31) { + menuDisplay++; + if (menuDisplay > 31) { + menuDisplay = 30; + } } else if (menuDisplay == 40) { @@ -162,7 +170,7 @@ namespace KEYBOARD_Utils { } else if (menuDisplay==1300) { messageText = ""; menuDisplay = 130; - } else if ((menuDisplay>=10 && menuDisplay<=13) || (menuDisplay>=20 && menuDisplay<=29) || (menuDisplay==120) || (menuDisplay>=130 && menuDisplay<=132) || (menuDisplay>=200 && menuDisplay<=290) || (menuDisplay>=60 && menuDisplay<=61) || (menuDisplay==30) || (menuDisplay==40)) { + } else if ((menuDisplay>=10 && menuDisplay<=13) || (menuDisplay>=20 && menuDisplay<=29) || (menuDisplay==120) || (menuDisplay>=130 && menuDisplay<=132) || (menuDisplay>=200 && menuDisplay<=290) || (menuDisplay>=60 && menuDisplay<=61) || (menuDisplay>=30 && menuDisplay<=31) || (menuDisplay>=300 && menuDisplay<=310) || (menuDisplay==40)) { menuDisplay = int(menuDisplay/10); } /* winlinkMailNumber = "";*/ @@ -181,7 +189,7 @@ namespace KEYBOARD_Utils { statusTime = millis(); show_display("__ INFO __", "", " CHANGING CALLSIGN!", 1000); STATION_Utils::saveCallsingIndex(myBeaconsIndex); - } else if ((menuDisplay>=1 && menuDisplay<=3) || (menuDisplay>=11 &&menuDisplay<=13) || (menuDisplay>=20 && menuDisplay<=29)) { + } else if ((menuDisplay>=1 && menuDisplay<=3) || (menuDisplay>=11 &&menuDisplay<=13) || (menuDisplay>=20 && menuDisplay<=29) || (menuDisplay>=30 && menuDisplay<=31)) { menuDisplay = menuDisplay*10; } else if (menuDisplay == 10) { MSG_Utils::loadMessagesFromMemory(); diff --git a/src/menu_utils.cpp b/src/menu_utils.cpp index be7bd5d..6056560 100644 --- a/src/menu_utils.cpp +++ b/src/menu_utils.cpp @@ -4,6 +4,7 @@ #include "custom_characters.h" #include "station_utils.h" #include "configuration.h" +#include "APRSPacketLib.h" #include "power_utils.h" #include "menu_utils.h" #include "msg_utils.h" @@ -30,6 +31,7 @@ extern bool bluetoothActive; extern bool displayEcoMode; extern bool screenBrightness; extern bool disableGPS; +extern APRSPacket lastReceivedPacket; namespace MENU_Utils { @@ -58,9 +60,9 @@ namespace MENU_Utils { } void showOnScreen() { - String lastLine; + String lastLine, firstLineDecoder, courseSpeedAltitude, speedPacketDec, coursePacketDec, pathDec; uint32_t lastMenuTime = millis() - menuTime; - if (!(menuDisplay==0) && !(menuDisplay==30) && !(menuDisplay==40) && lastMenuTime > 30*1000) { + if (!(menuDisplay==0) && !(menuDisplay==300) && !(menuDisplay==310) && !(menuDisplay==40) && lastMenuTime > 30*1000) { menuDisplay = 0; messageCallsign = ""; messageText = ""; @@ -232,10 +234,63 @@ namespace MENU_Utils { break; - case 30: //3.Stations ---> Display Heared Tracker/Stations - show_display("LISTENING>", STATION_Utils::getFirstNearTracker(), STATION_Utils::getSecondNearTracker(), STATION_Utils::getThirdNearTracker(), STATION_Utils::getFourthNearTracker(), " Packet Decoder + show_display("STATIONS>", "", "> Packet Decoder", " Near By Stations", "", " Near By Stations + show_display("STATIONS>", "", " Packet Decoder", "> Near By Stations", "", " Packet Decoder + firstLineDecoder = lastReceivedPacket.sender; + for(int i=firstLineDecoder.length();i<9;i++) { + firstLineDecoder += ' '; + } + firstLineDecoder += lastReceivedPacket.symbol; + + if (lastReceivedPacket.type==0 || lastReceivedPacket.type==4) { // gps and Mic-E gps + courseSpeedAltitude = String(lastReceivedPacket.altitude); + for(int j=courseSpeedAltitude.length();j<4;j++) { + courseSpeedAltitude = '0' + courseSpeedAltitude; + } + courseSpeedAltitude = "A=" + courseSpeedAltitude + "m "; + speedPacketDec = String(lastReceivedPacket.speed); + for (int k=speedPacketDec.length();k<3;k++) { + speedPacketDec = ' ' + speedPacketDec; + } + courseSpeedAltitude += speedPacketDec + "km/h "; + for(int l=courseSpeedAltitude.length();l<17;l++) { + courseSpeedAltitude += ' '; + } + coursePacketDec = String(lastReceivedPacket.course); + for(int m=coursePacketDec.length();m<3;m++) { + coursePacketDec = ' ' + coursePacketDec; + } + courseSpeedAltitude += coursePacketDec; + + double distanceKm = TinyGPSPlus::distanceBetween(gps.location.lat(), gps.location.lng(), lastReceivedPacket.latitude, lastReceivedPacket.longitude) / 1000.0; + double courseTo = TinyGPSPlus::courseTo(gps.location.lat(), gps.location.lng(), lastReceivedPacket.latitude, lastReceivedPacket.longitude); + + if (lastReceivedPacket.path.length()>14) { + pathDec = "P:" + lastReceivedPacket.path; + } else { + pathDec = "PATH: " +lastReceivedPacket.path; + } + + show_display(firstLineDecoder, "GPS " + String(lastReceivedPacket.latitude,2) + " " + String(lastReceivedPacket.longitude,2), courseSpeedAltitude, String(distanceKm) + "km " + String(courseTo,0), pathDec, "< RSSI:" + String(lastReceivedPacket.rssi) + " SNR:" + String(lastReceivedPacket.snr)); + } else if (lastReceivedPacket.type==1) { // message + show_display(firstLineDecoder, "ADDRESSEE: " + lastReceivedPacket.addressee, "MSG: " + lastReceivedPacket.message, "", "", "< RSSI:" + String(lastReceivedPacket.rssi) + " SNR:" + String(lastReceivedPacket.snr)); + } else if (lastReceivedPacket.type==2) { // status + show_display(firstLineDecoder, "-------STATUS-------", lastReceivedPacket.message, "", "", "< RSSI:" + String(lastReceivedPacket.rssi) + " SNR:" + String(lastReceivedPacket.snr)); + } else if (lastReceivedPacket.type==3) { // telemetry + show_display(firstLineDecoder, "------TELEMETRY------", "", "", "", "< RSSI:" + String(lastReceivedPacket.rssi) + " SNR:" + String(lastReceivedPacket.snr)); + } else if (lastReceivedPacket.type==5) { // object + show_display(firstLineDecoder, "-------OBJECT-------", "", "", "", "< RSSI:" + String(lastReceivedPacket.rssi) + " SNR:" + String(lastReceivedPacket.snr)); + } + break; + case 310: //3.Stations ---> Near By Stations + show_display("NEAR BY >", STATION_Utils::getFirstNearTracker(), STATION_Utils::getSecondNearTracker(), STATION_Utils::getThirdNearTracker(), STATION_Utils::getFourthNearTracker(), "callsign) { + lastReceivedPacket = APRSPacketLib::processReceivedPacket(packet.text.substring(3),packet.rssi, packet.snr, packet.freqError); + if (lastReceivedPacket.sender!=currentBeacon->callsign) { if (Config.bluetoothType==0) { BLE_Utils::sendToPhone(packet.text.substring(3)); } else { BLUETOOTH_Utils::sendPacket(packet.text.substring(3)); } - if (digirepeaterActive && aprsPacket.addressee!=currentBeacon->callsign) { - String digiRepeatedPacket = APRSPacketLib::generateDigiRepeatedPacket(aprsPacket, currentBeacon->callsign); + if (digirepeaterActive && lastReceivedPacket.addressee!=currentBeacon->callsign) { + String digiRepeatedPacket = APRSPacketLib::generateDigiRepeatedPacket(lastReceivedPacket, currentBeacon->callsign); if (digiRepeatedPacket == "X") { logger.log(logging::LoggerLevel::LOGGER_LEVEL_WARN, "Main", "%s", "Packet won't be Repeated (Missing WIDE1-X)"); } else { @@ -180,27 +181,27 @@ namespace MSG_Utils { LoRa_Utils::sendNewPacket(digiRepeatedPacket); } } - lastHeardTracker = aprsPacket.sender; - if (aprsPacket.type==1 && aprsPacket.addressee==currentBeacon->callsign) { - if (aprsPacket.message.indexOf("{")>=0) { - String ackMessage = "ack" + aprsPacket.message.substring(aprsPacket.message.indexOf("{")+1); + lastHeardTracker = lastReceivedPacket.sender; + if (lastReceivedPacket.type==1 && lastReceivedPacket.addressee==currentBeacon->callsign) { + if (lastReceivedPacket.message.indexOf("{")>=0) { + String ackMessage = "ack" + lastReceivedPacket.message.substring(lastReceivedPacket.message.indexOf("{")+1); ackMessage.trim(); delay(4000); - sendMessage(aprsPacket.sender, ackMessage); - aprsPacket.message = aprsPacket.message.substring(aprsPacket.message.indexOf(":")+1, aprsPacket.message.indexOf("{")); + sendMessage(lastReceivedPacket.sender, ackMessage); + lastReceivedPacket.message = lastReceivedPacket.message.substring(lastReceivedPacket.message.indexOf(":")+1, lastReceivedPacket.message.indexOf("{")); } else { - aprsPacket.message = aprsPacket.message.substring(aprsPacket.message.indexOf(":")+1); + lastReceivedPacket.message = lastReceivedPacket.message.substring(lastReceivedPacket.message.indexOf(":")+1); } if (Config.notification.buzzerActive && Config.notification.messageRxBeep) { NOTIFICATION_Utils::messageBeep(); } - if (aprsPacket.message.indexOf("ping")==0 || aprsPacket.message.indexOf("Ping")==0 || aprsPacket.message.indexOf("PING")==0) { + if (lastReceivedPacket.message.indexOf("ping")==0 || lastReceivedPacket.message.indexOf("Ping")==0 || lastReceivedPacket.message.indexOf("PING")==0) { delay(4000); - sendMessage(aprsPacket.sender, "pong, 73!"); + sendMessage(lastReceivedPacket.sender, "pong, 73!"); } - if (aprsPacket.sender == "CD2RXU-15" && aprsPacket.message.indexOf("WX")==0) { // WX = WeatherReport + if (lastReceivedPacket.sender == "CD2RXU-15" && lastReceivedPacket.message.indexOf("WX")==0) { // WX = WeatherReport Serial.println("Weather Report Received"); - String wxCleaning = aprsPacket.message.substring(aprsPacket.message.indexOf("WX ")+3); + String wxCleaning = lastReceivedPacket.message.substring(lastReceivedPacket.message.indexOf("WX ")+3); String place = wxCleaning.substring(0,wxCleaning.indexOf(",")); String placeCleaning = wxCleaning.substring(wxCleaning.indexOf(",")+1); String summary = placeCleaning.substring(0,placeCleaning.indexOf(",")); @@ -217,18 +218,18 @@ namespace MSG_Utils { String fifthLineWR = temperature + "C " + pressure + "hPa " + humidity +"%"; String sixthLineWR = "(wind " + windSpeed + "m/s " + windDegrees + "deg)"; - show_display("", "From --> " + aprsPacket.sender, place, summary, fifthLineWR, sixthLineWR); + show_display("", "From --> " + lastReceivedPacket.sender, place, summary, fifthLineWR, sixthLineWR); menuDisplay = 40; menuTime = millis(); } else { - show_display("< MSG Rx >", "From --> " + aprsPacket.sender, "", aprsPacket.message , 3000); + show_display("< MSG Rx >", "From --> " + lastReceivedPacket.sender, "", lastReceivedPacket.message , 3000); if (!Config.simplifiedTrackerMode) { - saveNewMessage("APRS", aprsPacket.sender, aprsPacket.message); + saveNewMessage("APRS", lastReceivedPacket.sender, lastReceivedPacket.message); } } } else { - if (aprsPacket.type==0 && !Config.simplifiedTrackerMode) { - GPS_Utils::calculateDistanceCourse(aprsPacket.sender, aprsPacket.latitude, aprsPacket.longitude); + if ((lastReceivedPacket.type==0 || lastReceivedPacket.type==4) && !Config.simplifiedTrackerMode) { + GPS_Utils::calculateDistanceCourse(lastReceivedPacket.sender, lastReceivedPacket.latitude, lastReceivedPacket.longitude); } if (Config.notification.buzzerActive && Config.notification.stationBeep && !digirepeaterActive) { NOTIFICATION_Utils::stationHeardBeep();