From 8cbc232fd93e707efedb1186394cbf45c0a00211 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Thu, 10 Oct 2024 09:58:00 -0300 Subject: [PATCH] WiFiAP stops after 1min no cliente connected --- README.md | 1 + src/LoRa_APRS_Tracker.cpp | 2 +- src/keyboard_utils.cpp | 2 +- src/station_utils.cpp | 3 +++ src/wifi_utils.cpp | 24 +++++++++++++++++++----- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index cf985f1..90e081f 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ ____________________________________________________ ____________________________________________________ ## Timeline (Versions): +- 2024.10.10 Configuration WiFiAP stops after 1 minute of no-client connected. - 2024.10.09 WEB INSTALLER/FLASHER. - 2024.10.07 Battery Monitor process added (Voltage Sleep to protect Battery). - 2024.09.17 Battery Voltage now as Encoded Telemetry in GPS Beacon. diff --git a/src/LoRa_APRS_Tracker.cpp b/src/LoRa_APRS_Tracker.cpp index 110f1de..182eae8 100644 --- a/src/LoRa_APRS_Tracker.cpp +++ b/src/LoRa_APRS_Tracker.cpp @@ -49,7 +49,7 @@ TinyGPSPlus gps; OneButton userButton = OneButton(BUTTON_PIN, true, true); #endif -String versionDate = "2024.10.07"; +String versionDate = "2024.10.10"; uint8_t myBeaconsIndex = 0; int myBeaconsSize = Config.beacons.size(); diff --git a/src/keyboard_utils.cpp b/src/keyboard_utils.cpp index 869b97f..2e92bad 100644 --- a/src/keyboard_utils.cpp +++ b/src/keyboard_utils.cpp @@ -486,7 +486,7 @@ namespace KEYBOARD_Utils { displayShow("", "", " STARTING WiFi AP", 2000); Config.wifiAP.active = true; Config.writeFile(); - ESP.restart(); + ESP.restart(); } } diff --git a/src/station_utils.cpp b/src/station_utils.cpp index 110f0ce..0184f0b 100644 --- a/src/station_utils.cpp +++ b/src/station_utils.cpp @@ -195,16 +195,19 @@ namespace STATION_Utils { String tempPacket = basePacket; tempPacket += "EQNS.0,0.01,0"; + displayShow("<<< TX >>>", "Telemetry Packet:", "Equation Coefficients",100); LoRa_Utils::sendNewPacket(tempPacket); delay(3000); tempPacket = basePacket; tempPacket += "UNIT.VDC"; + displayShow("<<< TX >>>", "Telemetry Packet:", "Unit/Label",100); LoRa_Utils::sendNewPacket(tempPacket); delay(3000); tempPacket = basePacket; tempPacket += "PARM.V_Batt"; + displayShow("<<< TX >>>", "Telemetry Packet:", "Parameter Name",100); LoRa_Utils::sendNewPacket(tempPacket); delay(3000); sendStartTelemetry = false; diff --git a/src/wifi_utils.cpp b/src/wifi_utils.cpp index e0412b2..29d99c2 100644 --- a/src/wifi_utils.cpp +++ b/src/wifi_utils.cpp @@ -5,10 +5,10 @@ #include "display.h" -extern Configuration Config; -extern logging::Logger logger; +extern Configuration Config; +extern logging::Logger logger; -//uint32_t WiFiAutoAPTime = millis(); +uint32_t noClientsTime = 0; namespace WIFI_Utils { @@ -17,7 +17,6 @@ namespace WIFI_Utils { WiFi.mode(WIFI_MODE_NULL); WiFi.mode(WIFI_AP); WiFi.softAP("LoRaTracker-AP", Config.wifiAP.password); - //WiFiAutoAPTime = millis(); } void checkIfWiFiAP() { @@ -26,7 +25,22 @@ namespace WIFI_Utils { logger.log(logging::LoggerLevel::LOGGER_LEVEL_WARN, "Main", "WebConfiguration Started!"); startAutoAP(); WEB_Utils::setup(); - while (true) {} + while (true) { + if (WiFi.softAPgetStationNum() > 0) { + noClientsTime = 0; + } else { + if (noClientsTime == 0) { + noClientsTime = millis(); + } else if ((millis() - noClientsTime) > 60 * 1000) { + logger.log(logging::LoggerLevel::LOGGER_LEVEL_WARN, "Main", "WebConfiguration Stopped!"); + displayShow("", "", " STOPPING WiFi AP", 2000); + Config.wifiAP.active = false; + Config.writeFile(); + WiFi.softAPdisconnect(true); + ESP.restart(); + } + } + } } else { WiFi.mode(WIFI_OFF); logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, "Main", "WiFi controller stopped");