From d1732a6bba92881ef36f89656f851674903ceae9 Mon Sep 17 00:00:00 2001 From: S57PNX Date: Thu, 15 Aug 2024 20:54:26 +0200 Subject: [PATCH 1/2] Correct logic of serial notifications for APRS-IS and RF beacons --- src/utils.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils.cpp b/src/utils.cpp index 18cb8f59..111a8284 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -112,8 +112,7 @@ namespace Utils { if (!Config.display.alwaysOn && Config.display.timeout != 0) { displayToggle(true); } - Utils::println("-- Sending Beacon to APRSIS --"); - + STATION_Utils::deleteNotHeard(); activeStations(); @@ -172,6 +171,7 @@ namespace Utils { } if (Config.aprs_is.active && Config.beacon.sendViaAPRSIS && !backUpDigiMode) { + Utils::println("-- Sending Beacon to APRSIS --"); displayShow(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING IGATE BEACON", 0); seventhLine = " listening..."; #ifdef HAS_A7670 @@ -182,6 +182,7 @@ namespace Utils { } if (Config.beacon.sendViaRF || backUpDigiMode) { + Utils::println("-- Sending Beacon to RF --"); displayShow(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING DIGI BEACON", 0); seventhLine = " listening..."; STATION_Utils::addToOutputPacketBuffer(secondaryBeaconPacket); From c11dbc1ea23a79120439ae1944b174e1a523414a Mon Sep 17 00:00:00 2001 From: S57PNX Date: Fri, 16 Aug 2024 18:21:33 +0200 Subject: [PATCH 2/2] Make AP run only once. Change logic and adjust display. --- src/aprs_is_utils.cpp | 11 ++++++++--- src/utils.cpp | 12 +++++++++--- src/wifi_utils.cpp | 24 ++++++++++++++++-------- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/aprs_is_utils.cpp b/src/aprs_is_utils.cpp index 4290aea1..63168220 100644 --- a/src/aprs_is_utils.cpp +++ b/src/aprs_is_utils.cpp @@ -21,6 +21,7 @@ extern String sixthLine; extern String seventhLine; extern bool modemLoggedToAPRSIS; extern bool backUpDigiMode; +extern bool WiFiAutoAPStarted; uint32_t lastRxTime = millis(); @@ -72,10 +73,14 @@ namespace APRS_IS_Utils { wifiState = "OK"; } else { if (backUpDigiMode) { - wifiState = "--"; - } else { + wifiState = "BK"; + } else if (WiFiAutoAPStarted){ wifiState = "AP"; - } + } + else { + wifiState = "--"; + } + if (!Config.display.alwaysOn && Config.display.timeout != 0) { displayToggle(true); } diff --git a/src/utils.cpp b/src/utils.cpp index 111a8284..d20adc0e 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -35,6 +35,7 @@ extern int wxModuleType; extern bool backUpDigiMode; extern bool shouldSleepLowVoltage; extern bool transmitFlag; +extern bool WiFiAutoAPStarted; bool statusAfterBoot = true; bool beaconUpdate = true; @@ -69,11 +70,16 @@ namespace Utils { } String getLocalIP() { - if (!WiFiConnected) { + if (!WiFiConnected && WiFiAutoAPStarted) { return "IP : 192.168.4.1"; - } else if (backUpDigiMode) { + } + else if (backUpDigiMode) { return "- BACKUP DIGI MODE -"; - } else { + } + else if (!WiFiConnected) { + return "IP : -"; + } + else { return "IP : " + String(WiFi.localIP()[0]) + "." + String(WiFi.localIP()[1]) + "." + String(WiFi.localIP()[2]) + "." + String(WiFi.localIP()[3]); } } diff --git a/src/wifi_utils.cpp b/src/wifi_utils.cpp index 4c9035e2..646e5db6 100644 --- a/src/wifi_utils.cpp +++ b/src/wifi_utils.cpp @@ -18,6 +18,7 @@ bool WiFiAutoAPStarted = false; uint32_t previousWiFiMillis = 0; uint8_t wifiCounter = 0; uint32_t lastBackupDigiTime = millis(); +bool WiFiAutoAPFirsttime = true; namespace WIFI_Utils { @@ -62,12 +63,15 @@ namespace WIFI_Utils { WiFiAutoAPTime = millis(); WiFiAutoAPStarted = true; + WiFiAutoAPFirsttime = false; } void startWiFi() { bool startAP = false; - if (currentWiFi->ssid == "") { + if (currentWiFi->ssid == "" && WiFiAutoAPFirsttime ) { startAP = true; + } else if (currentWiFi->ssid == "" ) { + startAP = false; } else { uint8_t wifiCounter = 0; WiFi.mode(WIFI_STA); @@ -114,17 +118,21 @@ namespace WIFI_Utils { Serial.print(" / MAC Address: "); Serial.println(WiFi.macAddress()); displayShow("", " Connected!!", "" , " loading ...", 1000); + WiFiConnected = true; } else if (WiFi.status() != WL_CONNECTED) { - startAP = true; - - Serial.println("\nNot connected to WiFi! Starting Auto AP"); + + Serial.println("\nNot connected to WiFi!"); displayShow("", " WiFi Not Connected!", "" , " loading ...", 1000); + WiFi.disconnect(); + WiFi.mode(WIFI_MODE_NULL); + WiFiConnected = false; + startAP = true; } - WiFiConnected = !startAP; - if (startAP) { + + if (startAP && WiFiAutoAPFirsttime && !backUpDigiMode) { Serial.println("\nNot connected to WiFi! Starting Auto AP"); displayShow("", " Starting Auto AP", " Please connect to it " , " loading ...", 1000); - + WiFiConnected = false; startAutoAP(); } } @@ -141,7 +149,7 @@ namespace WIFI_Utils { WiFiAutoAPStarted = false; WiFi.softAPdisconnect(true); - + WiFi.mode(WIFI_MODE_NULL); Serial.println("Auto AP stopped (timeout)"); } }