From 783ec7c6644e5587370466449466f27c153f2978 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Sun, 4 Jun 2023 14:54:11 -0400 Subject: [PATCH] update keep last packet on screen --- data/igate_conf.json | 1 + src/LoRa_APRS_iGate.cpp | 27 +++++++++++++++------------ src/igate_config.h | 40 +++++++++++++++++++++------------------- src/utils.cpp | 41 ++++++++++++----------------------------- src/utils.h | 5 +---- 5 files changed, 50 insertions(+), 64 deletions(-) diff --git a/data/igate_conf.json b/data/igate_conf.json index 09358f5..658425a 100644 --- a/data/igate_conf.json +++ b/data/igate_conf.json @@ -33,6 +33,7 @@ }, "display": { "alwaysOn": true, + "keepLastPacketOnScreen": true, "timeout": 2 }, "other": { diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 5765326..3ae26cc 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -7,6 +7,7 @@ #include "igate_config.h" #include "display.h" #include "lora_utils.h" +#include "utils.h" #define VERSION "2023.06.04" @@ -214,7 +215,7 @@ void checkReceivedPacket(String packet) { } lastRxTxTime = millis(); LoRaUtils::sendNewPacket("APRS", queryAnswer); - show_display(firstLine, secondLine, "Callsign = " + Sender, "Type --> QUERY", 1000); + show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> QUERY", 1000); } } } @@ -230,13 +231,13 @@ void checkReceivedPacket(String packet) { deleteNotHeardStation(); updateLastHeardStation(Sender); if (aprsPacket.indexOf("::") >= 10) { - show_display(firstLine, secondLine, "Callsign = " + Sender, "Type --> MESSAGE", 1000); + show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> MESSAGE", 1000); } else if (aprsPacket.indexOf(":>") >= 10) { - show_display(firstLine, secondLine, "Callsign = " + Sender, "Type --> NEW STATUS", 1000); + show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> NEW STATUS", 1000); } else if (aprsPacket.indexOf(":!") >= 10) { - show_display(firstLine, secondLine, "Callsign = " + Sender, "Type --> GPS BEACON", 1000); + show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> GPS BEACON", 1000); } else { - show_display(firstLine, secondLine, "Callsign = " + Sender, "Type --> ??????????", 1000); + show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> ??????????", 1000); } } } @@ -384,7 +385,10 @@ void loop() { thirdLine = ""; fourthLine = ""; - show_display(firstLine, secondLine, thirdLine, fourthLine, 0); + if (!Config.display.keepLastPacketOnScreen) { + show_display(firstLine, secondLine, thirdLine, fourthLine, 0); + } + uint32_t lastTx = millis() - lastTxTime; if (lastTx >= Config.beaconInterval*60*1000) { beacon_update = true; @@ -403,6 +407,7 @@ void loop() { lastTxTime = millis(); lastRxTxTime = millis(); show_display(firstLine, secondLine, thirdLine, "SENDING iGate BEACON", 1000); + show_display(firstLine, secondLine, thirdLine, fourthLine, 0); beacon_update = false; } @@ -452,7 +457,7 @@ void loop() { lastRxTxTime = millis(); delay(500); espClient.write(queryAnswer.c_str()); - show_display(firstLine, secondLine, "Callsign = " + Sender, "Type --> QUERY", 1000); + show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> QUERY", 1000); } } else { newLoraPacket = processAPRSISPacket(aprsisPacket); @@ -462,17 +467,15 @@ void loop() { LoRaUtils::sendNewPacket("APRS", newLoraPacket); display_toggle(true); lastRxTxTime = millis(); - show_display(firstLine, secondLine, Sender + " -> " + Addressee, receivedMessage, 2000); + receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":")+1); + show_display(firstLine, secondLine, Sender + " -> " + Addressee, receivedMessage, 1000); } } } } } if (statusAfterBoot) { - delay(1000); - String startupStatus = Config.callsign + ">APLR10,qAC:>" + Config.defaultStatus; - espClient.write((startupStatus + "\n").c_str()); - statusAfterBoot = false; + utils::processStatus(); } } } \ No newline at end of file diff --git a/src/igate_config.h b/src/igate_config.h index 6648259..c412907 100644 --- a/src/igate_config.h +++ b/src/igate_config.h @@ -38,6 +38,7 @@ public: class Display { public: bool alwaysOn; + bool keepLastPacketOnScreen; int timeout; }; @@ -85,28 +86,29 @@ private: wifiAPs.push_back(wifiap); } - callsign = data["callsign"].as(); - comment = data["comment"].as(); - beaconInterval = data["other"]["beaconInterval"].as(); - statusAfterBoot = data["other"]["statusAfterBoot"].as(); - defaultStatus = data["other"]["defaultStatus"].as(); + callsign = data["callsign"].as(); + comment = data["comment"].as(); + beaconInterval = data["other"]["beaconInterval"].as(); + statusAfterBoot = data["other"]["statusAfterBoot"].as(); + defaultStatus = data["other"]["defaultStatus"].as(); - aprs_is.passcode = data["aprs_is"]["passcode"].as(); - aprs_is.server = data["aprs_is"]["server"].as(); - aprs_is.port = data["aprs_is"]["port"].as(); - aprs_is.softwareName = data["aprs_is"]["softwareName"].as(); - aprs_is.softwareVersion = data["aprs_is"]["softwareVersion"].as(); - aprs_is.reportingDistance = data["aprs_is"]["reportingDistance"].as(); + aprs_is.passcode = data["aprs_is"]["passcode"].as(); + aprs_is.server = data["aprs_is"]["server"].as(); + aprs_is.port = data["aprs_is"]["port"].as(); + aprs_is.softwareName = data["aprs_is"]["softwareName"].as(); + aprs_is.softwareVersion = data["aprs_is"]["softwareVersion"].as(); + aprs_is.reportingDistance = data["aprs_is"]["reportingDistance"].as(); - loramodule.enableTx = data["lora"]["enableTx"].as(); - loramodule.frequency = data["lora"]["frequency"].as(); - loramodule.spreadingFactor = data["lora"]["spreadingFactor"].as(); - loramodule.signalBandwidth = data["lora"]["signalBandwidth"].as(); - loramodule.codingRate4 = data["lora"]["codingRate4"].as(); - loramodule.power = data["lora"]["power"].as(); + loramodule.enableTx = data["lora"]["enableTx"].as(); + loramodule.frequency = data["lora"]["frequency"].as(); + loramodule.spreadingFactor = data["lora"]["spreadingFactor"].as(); + loramodule.signalBandwidth = data["lora"]["signalBandwidth"].as(); + loramodule.codingRate4 = data["lora"]["codingRate4"].as(); + loramodule.power = data["lora"]["power"].as(); - display.alwaysOn = data["display"]["alwaysOn"].as(); - display.timeout = data["display"]["timeout"].as(); + display.alwaysOn = data["display"]["alwaysOn"].as(); + display.keepLastPacketOnScreen = data["display"]["keepLastPacketOnScreen"].as(); + display.timeout = data["display"]["timeout"].as(); configFile.close(); } diff --git a/src/utils.cpp b/src/utils.cpp index 9ba4f8e..45e23fb 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1,36 +1,19 @@ +#include +#include +#include #include "utils.h" +extern WiFiClient espClient; +extern Configuration Config; +extern bool statusAfterBoot; + namespace utils { -char *ax25_base91enc(char *s, uint8_t n, uint32_t v) { - /* Creates a Base-91 representation of the value in v in the string */ - /* pointed to by s, n-characters long. String length should be n+1. */ - for(s += n, *s = '\0'; n; n--) { - *(--s) = v % 91 + 33; - v /= 91; - } - return(s); -} - -static String padding(unsigned int number, unsigned int width) { - String result; - String num(number); - if (num.length() > width) { - width = num.length(); - } - for (unsigned int i = 0; i < width - num.length(); i++) { - result.concat('0'); - } - result.concat(num); - return result; -} - -String createDateString(time_t t) { - return String(padding(year(t), 4) + "-" + padding(month(t), 2) + "-" + padding(day(t), 2)); -} - -String createTimeString(time_t t) { - return String(padding(hour(t), 2) + ":" + padding(minute(t), 2) + ":" + padding(second(t), 2)); +void processStatus() { + delay(1000); + String startupStatus = Config.callsign + ">APLR10,qAC:>" + Config.defaultStatus; + espClient.write((startupStatus + "\n").c_str()); + statusAfterBoot = false; } } \ No newline at end of file diff --git a/src/utils.h b/src/utils.h index 8b992f2..e232d26 100644 --- a/src/utils.h +++ b/src/utils.h @@ -2,13 +2,10 @@ #define UTILS_H_ #include -#include namespace utils { -char *ax25_base91enc(char *s, uint8_t n, uint32_t v); -String createDateString(time_t t); -String createTimeString(time_t t); +void processStatus(); } #endif \ No newline at end of file