diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index e21938b..7bde097 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -11,7 +11,6 @@ #include "lora_utils.h" #include "wifi_utils.h" #include "digi_utils.h" -#include "time_utils.h" #include "gps_utils.h" #include "display.h" #include "utils.h" @@ -20,7 +19,7 @@ Configuration Config; WiFiClient espClient; -String versionDate = "2023.06.16"; +String versionDate = "2023.06.17"; int myWiFiAPIndex = 0; int myWiFiAPSize = Config.wifiAPs.size(); WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex]; @@ -43,7 +42,6 @@ void setup() { delay(1000); Utils::setupDiplay(); WIFI_Utils::setup(); - TIME_Utils::setup(); LoRa_Utils::setup(); Utils::validateDigiFreqs(); iGateBeaconPacket = GPS_Utils::generateBeacon(); @@ -60,7 +58,6 @@ void loop() { APRS_IS_Utils::checkStatus(); show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, eigthLine, 0); while (espClient.connected()) { - TIME_Utils::getDateTime(); Utils::checkDisplayInterval(); Utils::checkBeaconInterval(); APRS_IS_Utils::processLoRaPacket(LoRa_Utils::receivePacket()); diff --git a/src/aprs_is_utils.cpp b/src/aprs_is_utils.cpp index 838d3b2..cf2ae47 100644 --- a/src/aprs_is_utils.cpp +++ b/src/aprs_is_utils.cpp @@ -128,7 +128,7 @@ void processLoRaPacket(String packet) { espClient.write(aprsPacket.c_str()); Serial.println(" ---> Uploaded to APRS-IS"); STATION_Utils::updateLastHeard(Sender); - Utils::typeOfPacket(aprsPacket); + Utils::typeOfPacket(aprsPacket, "LoRa-APRS"); show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, eigthLine, 0); } } @@ -180,8 +180,8 @@ void processAPRSISPacket(String packet) { LoRa_Utils::sendNewPacket("APRS", LoRa_Utils::generatePacket(packet)); display_toggle(true); lastScreenOn = millis(); - Utils::typeOfPacket(packet); - seventhLine = Sender + " -> " + Addressee; + Utils::typeOfPacket(packet, "APRS-LoRa"); + show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, eigthLine, 0); } } } diff --git a/src/digi_utils.cpp b/src/digi_utils.cpp index 25e04e8..032dfec 100644 --- a/src/digi_utils.cpp +++ b/src/digi_utils.cpp @@ -17,7 +17,7 @@ void processPacket(String packet) { if ((packet.substring(0, 3) == "\x3c\xff\x01") && (packet.indexOf("NOGATE") == -1)) { Serial.println(" ---> APRS LoRa Packet"); if ((stationMode==3) && (packet.indexOf("WIDE1-1") > 10)) { - Utils::typeOfPacket(packet); + Utils::typeOfPacket(packet, "Digi"); loraPacket = packet.substring(3); loraPacket.replace("WIDE1-1", Config.callsign + "*"); delay(500); @@ -25,7 +25,7 @@ void processPacket(String packet) { display_toggle(true); lastScreenOn = millis(); } else if (stationMode ==4){ - Utils::typeOfPacket(packet); + Utils::typeOfPacket(packet, "Digi"); if (packet.indexOf("WIDE1-1") == -1) { loraPacket = packet.substring(3,packet.indexOf(":")) + "," + Config.callsign + "*" + packet.substring(packet.indexOf(":")); } else { diff --git a/src/station_utils.cpp b/src/station_utils.cpp index 858d4e7..96d837b 100644 --- a/src/station_utils.cpp +++ b/src/station_utils.cpp @@ -5,6 +5,7 @@ extern Configuration Config; extern std::vector lastHeardStation; extern std::vector lastHeardStation_temp; +extern String fifthLine; namespace STATION_Utils { @@ -42,6 +43,11 @@ void updateLastHeard(String station) { Serial.print(lastHeardStation[k].substring(0,lastHeardStation[k].indexOf(","))); Serial.print(" "); } Serial.println(""); + if (lastHeardStation.size() < 10) { + fifthLine = "Stations (30min) = " + String(lastHeardStation.size()); + } else { + fifthLine = "Stations (30min) = " + String(lastHeardStation.size()); + } } bool wasHeard(String station) { diff --git a/src/time_utils.cpp b/src/time_utils.cpp deleted file mode 100644 index b4dbb6f..0000000 --- a/src/time_utils.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include "time_utils.h" -#include "display.h" -#include "time.h" - -extern String firstLine; -extern String secondLine; -extern String thirdLine; -extern String fourthLine; -extern String fifthLine; -extern String sixthLine; -extern String seventhLine; -extern String eigthLine; - -namespace TIME_Utils { - -void getDateTime() { - struct tm timeinfo; - String year, month, day, hour, minute, seconds; - if(!getLocalTime(&timeinfo)){ - Serial.println("Failed to obtain time"); - fourthLine = "no time info... restarting"; - ESP.restart(); - } - - year = (String)(timeinfo.tm_year + 1900); - - month = (String)(timeinfo.tm_mon+1); - if (month.length() == 1) { - month = "0" + month; - } - - day = (String)(timeinfo.tm_mday); - if (day.length() == 1) { - day = "0" + day; - } - - hour = (String)(timeinfo.tm_hour); - if (hour == 0) { - hour = "00"; - } else if (hour.length() == 1) { - hour = "0" + hour; - } - - minute = (String)(timeinfo.tm_min); - if (minute == 0) { - minute = "00"; - } else if (minute.length() == 1) { - minute = "0" + minute; - } - - seconds = (String)(timeinfo.tm_sec); - if (seconds == 0) { - seconds = "00"; - } else if (seconds.length() == 1) { - seconds = "0" + seconds; - } - - fourthLine = year + "/" + month + "/" + day + " - " + hour + ":" + minute + ":" + seconds; - show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, eigthLine, 0); -} - -void setup() { - const char* ntpServer = "pool.ntp.org"; - const long GMT = 0; // for receiving UTC time - const long gmtOffset_sec = GMT*60*60; - const int daylightOffset_sec = 3600; - - configTime(gmtOffset_sec, daylightOffset_sec, ntpServer); - //configTime(gmtOffset_sec, daylightOffset_sec, ntpServer); - getDateTime(); -} - - - -} diff --git a/src/time_utils.h b/src/time_utils.h deleted file mode 100644 index 14783ff..0000000 --- a/src/time_utils.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef TIME_UTILS_H_ -#define TIME_UTILS_H_ - -#include - -namespace TIME_Utils { - -void getDateTime(); -void setup(); - -} - -#endif \ No newline at end of file diff --git a/src/utils.cpp b/src/utils.cpp index f66d6b1..45c5459 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -14,23 +14,24 @@ AsyncWebServer server(80); -extern WiFiClient espClient; -extern Configuration Config; -extern String versionDate; -extern bool statusAfterBoot; -extern String firstLine; -extern String secondLine; -extern String thirdLine; -extern String fourthLine; -extern String fifthLine; -extern String sixthLine; -extern String seventhLine; -extern String eigthLine; -extern uint32_t lastBeaconTx; -extern uint32_t lastScreenOn; -extern bool beacon_update; -extern int stationMode; -extern String iGateBeaconPacket; +extern WiFiClient espClient; +extern Configuration Config; +extern String versionDate; +extern bool statusAfterBoot; +extern String firstLine; +extern String secondLine; +extern String thirdLine; +extern String fourthLine; +extern String fifthLine; +extern String sixthLine; +extern String seventhLine; +extern String eigthLine; +extern uint32_t lastBeaconTx; +extern uint32_t lastScreenOn; +extern bool beacon_update; +extern int stationMode; +extern String iGateBeaconPacket; +extern std::vector lastHeardStation; namespace Utils { @@ -56,7 +57,7 @@ void processStatus() { } String getLocalIP() { - return "IP : " + String(WiFi.localIP()[0]) + "." + String(WiFi.localIP()[1]) + "." + String(WiFi.localIP()[2]) + "." + String(WiFi.localIP()[3]); + return "IP : " + String(WiFi.localIP()[0]) + "." + String(WiFi.localIP()[1]) + "." + String(WiFi.localIP()[2]) + "." + String(WiFi.localIP()[3]); } void setupDiplay() { @@ -70,7 +71,7 @@ void setupDiplay() { secondLine = ""; } else { secondLine = ""; - } + } seventhLine = ""; eigthLine = " listening..."; } @@ -85,12 +86,21 @@ void checkBeaconInterval() { Serial.println("---- Sending iGate Beacon ----"); if (stationMode==1 || stationMode==2) { thirdLine = getLocalIP(); + if (lastHeardStation.size() < 10) { + fifthLine = "Stations (30min) = " + String(lastHeardStation.size()); + } else { + fifthLine = "Stations (30min) = " + String(lastHeardStation.size()); + } + //fifthLine = ""; + sixthLine = ""; seventhLine = ""; show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, "SENDING iGate BEACON", 1000); eigthLine = " listening..."; espClient.write((iGateBeaconPacket + "\n").c_str()); show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, eigthLine, 0); } else if (stationMode==3 || stationMode==4) { + fifthLine = ""; + sixthLine = ""; seventhLine = ""; show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, "SENDING iGate BEACON", 0); eigthLine = " listening..."; @@ -130,20 +140,42 @@ void validateDigiFreqs() { } } -void typeOfPacket(String packet) { +void typeOfPacket(String packet, String packetType) { + String sender; if (stationMode==1 || stationMode==2) { - seventhLine = "Callsign = " + packet.substring(0,packet.indexOf(">")); + if (packetType == "LoRa-APRS") { + sixthLine = "LoRa Rx ----> APRS-IS"; + } else if (packetType == "APRS-LoRa") { + sixthLine = "APRS-IS ----> LoRa Tx"; + } + sender = packet.substring(0,packet.indexOf(">")); } else { - seventhLine = "Callsign = " + packet.substring(3,packet.indexOf(">")); + sixthLine = "LoRa Rx ----> LoRa Tx"; + sender = packet.substring(3,packet.indexOf(">")); + } + for (int i=sender.length();i<9;i++) { + sender += " "; } if (packet.indexOf("::") >= 10) { - eigthLine = "TYPE ----> MESSAGE"; + if (packetType == "APRS-LoRa") { + String addresseeAndMessage = packet.substring(packet.indexOf("::")+2); + String addressee = addresseeAndMessage.substring(0, addresseeAndMessage.indexOf(":")); + addressee.trim(); + seventhLine = sender + " > " + addressee; + Serial.println("mensaje desde " + seventhLine); + } else { + seventhLine = sender + "> MESSAGE"; + } + eigthLine = "RSSI: 38dBm SNR: 6dBm"; } else if (packet.indexOf(":>") >= 10) { - eigthLine = "TYPE ----> NEW STATUS"; + seventhLine = sender + "> NEW STATUS"; + eigthLine = "RSSI: 38dBm SNR: 6dBm"; } else if (packet.indexOf(":!") >= 10 || packet.indexOf(":=") >= 10) { - eigthLine = "TYPE ----> GPS BEACON"; + seventhLine = sender + "> GPS BEACON"; + eigthLine = "RSSI:38dBm D: 25.6km"; } else { - eigthLine = "TYPE ----> ??????????"; + seventhLine = sender + "> ??????????"; + eigthLine = "RSSI: 38dBm SNR: 6dBm"; } } diff --git a/src/utils.h b/src/utils.h index 78758f8..81b87fa 100644 --- a/src/utils.h +++ b/src/utils.h @@ -11,7 +11,7 @@ void setupDiplay(); void checkBeaconInterval(); void checkDisplayInterval(); void validateDigiFreqs(); -void typeOfPacket(String packet); +void typeOfPacket(String packet, String packetType); void startOTAServer(); } diff --git a/src/wifi_utils.cpp b/src/wifi_utils.cpp index a25cca0..30b224a 100644 --- a/src/wifi_utils.cpp +++ b/src/wifi_utils.cpp @@ -56,7 +56,7 @@ void startWiFi() { digitalWrite(greenLed,LOW); Serial.print("Connected as "); Serial.println(WiFi.localIP()); - show_display("", "", " Connected!!", "" , " loading programs...", 1000); + show_display("", "", " Connected!!", "" , " loading ...", 1000); } void setup() {