From 27f73d0a11e0a5b393f8239fc009b17dc1a3ccb3 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Tue, 6 Jun 2023 12:37:22 -0400 Subject: [PATCH] aprs is check status --- src/LoRa_APRS_iGate.cpp | 19 +++++-------------- src/aprs_is_utils.cpp | 25 +++++++++++++++++++++++++ src/aprs_is_utils.h | 1 + src/display.cpp | 2 +- 4 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index a8a9fb8..4cf7c75 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -25,7 +25,7 @@ Configuration Config(ConfigurationFilePath); uint32_t lastTxTime = 0; static bool beacon_update = true; unsigned long previousWiFiMillis = 0; -static uint32_t lastRxTxTime = millis(); +uint32_t lastRxTxTime = millis(); int myWiFiAPIndex = 0; int myWiFiAPSize = Config.wifiAPs.size(); @@ -35,7 +35,7 @@ bool statusAfterBoot = Config.statusAfterBoot; std::vector lastHeardStation; std::vector lastHeardStation_temp; -String firstLine, secondLine, thirdLine, fourthLine, iGateBeaconPacket; //iGateLatitude, iGateLongitude; +String firstLine, secondLine, thirdLine, fourthLine, iGateBeaconPacket; String createAPRSPacket(String unprocessedPacket) { String callsign_and_path_tracker, payload_tracker, processedPacket; @@ -229,8 +229,6 @@ void setup() { LoRaUtils::setup(); iGateBeaconPacket = GPS_Utils::generateBeacon(); - //iGateLatitude = GPS_Utils::processLatitudeAPRS(); - //iGateLongitude = GPS_Utils::processLongitudeAPRS(); } void loop() { @@ -253,7 +251,7 @@ void loop() { APRS_IS_Utils::connect(); } - if (WiFi.status() == WL_CONNECTED) { + /*if (WiFi.status() == WL_CONNECTED) { wifiState = "OK"; } else { wifiState = "--"; @@ -270,8 +268,8 @@ void loop() { display_toggle(true); } lastRxTxTime = millis(); - } - secondLine = "WiFi: " + wifiState + "/ APRS-IS: " + aprsisState; + }*/ + secondLine = APRS_IS_Utils::checkStatus();// "WiFi: " + wifiState + "/ APRS-IS: " + aprsisState; show_display(firstLine, secondLine, thirdLine, fourthLine, 0); @@ -296,13 +294,6 @@ void loop() { if (beacon_update) { display_toggle(true); Serial.println("---- Sending iGate Beacon ----"); - /*String iGateBeaconPacket = Config.callsign + ">APLR10,qAC:="; - if (Config.loramodule.enableTx) { - iGateBeaconPacket += iGateLatitude + "L" + iGateLongitude + "a"; - } else { - iGateBeaconPacket += iGateLatitude + "L" + iGateLongitude + "&"; - } - iGateBeaconPacket += Config.comment;*/ //Serial.println(iGateBeaconPacket); espClient.write((iGateBeaconPacket + "\n").c_str()); lastTxTime = millis(); diff --git a/src/aprs_is_utils.cpp b/src/aprs_is_utils.cpp index a520af4..7b8b910 100644 --- a/src/aprs_is_utils.cpp +++ b/src/aprs_is_utils.cpp @@ -1,10 +1,12 @@ #include "aprs_is_utils.h" #include #include "configuration.h" +#include "display.h" extern Configuration Config; extern WiFiClient espClient; extern int internalLedPin; +extern uint32_t lastRxTxTime; namespace APRS_IS_Utils { @@ -32,6 +34,29 @@ void connect(){ } } +String checkStatus() { + String wifiState, aprsisState; + if (WiFi.status() == WL_CONNECTED) { + wifiState = "OK"; + } else { + wifiState = "--"; + if (!Config.display.alwaysOn) { + display_toggle(true); + } + lastRxTxTime = millis(); + } + if (espClient.connected()) { + aprsisState = "OK"; + } else { + aprsisState = "--"; + if (!Config.display.alwaysOn) { + display_toggle(true); + } + lastRxTxTime = millis(); + } + return "WiFi: " + wifiState + "/ APRS-IS: " + aprsisState; +} + /*void processSplitedMessage(String addressee, String message1, String message2) { espClient.write((Config.callsign + ">APRS,qAC::" + addressee + ":" + message1 + "\n").c_str()); Serial.println("-------> " + message1); diff --git a/src/aprs_is_utils.h b/src/aprs_is_utils.h index db3f602..bbfdfc8 100644 --- a/src/aprs_is_utils.h +++ b/src/aprs_is_utils.h @@ -6,6 +6,7 @@ namespace APRS_IS_Utils { void connect(); +String checkStatus(); //void processSplitedMessage(String addressee, String message1, String message2); } diff --git a/src/display.cpp b/src/display.cpp index e9fc2ba..dae5282 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -22,7 +22,7 @@ void setup_display() { display.ssd1306_command(SSD1306_SETCONTRAST); display.ssd1306_command(1); display.display(); - delay(4000); + delay(1000); } void display_toggle(bool toggle) {