From b45633ab48bcfc09adb94663c5ce000075515043 Mon Sep 17 00:00:00 2001 From: SQ2CPA Date: Sun, 25 Feb 2024 18:02:50 +0100 Subject: [PATCH] fix: digi mode with auto ap --- src/LoRa_APRS_iGate.cpp | 8 ++++---- src/wifi_utils.cpp | 20 ++++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 0a2ff0d..1f775e3 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -82,11 +82,11 @@ void loop() { WIFI_Utils::checkIfAutoAPShouldPowerOff(); - if (!WiFiConnected) { - thirdLine = Utils::getLocalIP(); - } - if (stationMode==1 || stationMode==2 ) { // iGate (1 Only Rx / 2 Rx+Tx) + if (!WiFiConnected) { + thirdLine = Utils::getLocalIP(); + } + WIFI_Utils::checkWiFi(); if (!espClient.connected()) { APRS_IS_Utils::connect(); diff --git a/src/wifi_utils.cpp b/src/wifi_utils.cpp index 4cd15e9..bb8e9d9 100644 --- a/src/wifi_utils.cpp +++ b/src/wifi_utils.cpp @@ -27,6 +27,16 @@ namespace WIFI_Utils { } } + void startAutoAP() { + WiFi.mode(WIFI_MODE_NULL); + + WiFi.mode(WIFI_AP); + WiFi.softAP(Config.callsign + " AP", "1234567890"); + + WiFiAutoAPTime = millis(); + WiFiAutoAPStarted = true; + } + void startWiFi() { bool startAP = false; if (currentWiFi->ssid == "") { @@ -88,13 +98,7 @@ namespace WIFI_Utils { Serial.println("\nNot connected to WiFi! Starting Auto AP"); show_display("", "", " Starting Auto AP", " Please connect to it " , " loading ...", 1000); - WiFi.mode(WIFI_MODE_NULL); - - WiFi.mode(WIFI_AP); - WiFi.softAP(Config.callsign + " AP", "1234567890"); - - WiFiAutoAPTime = millis(); - WiFiAutoAPStarted = true; + startAutoAP(); } } @@ -132,7 +136,7 @@ namespace WIFI_Utils { } else { Serial.println("stationMode ---> DigiRepeater (Rx freq != Tx freq)"); } - WiFi.mode(WIFI_OFF); + startAutoAP(); btStop(); } else if (stationMode==5) { Serial.println("stationMode ---> iGate when Wifi/APRS available (DigiRepeater when not)");