test for Killed Wifi Active

This commit is contained in:
richonguzman 2024-10-06 23:23:22 -03:00
parent df9060d906
commit 58d8736969
8 changed files with 60 additions and 52 deletions

View File

@ -1475,7 +1475,7 @@
<label <label
for="wifi.autoAP.active" for="wifi.autoAP.active"
class="form-label" class="form-label"
>WiFi AP Active<small> (Caution: Not Active means No WebUI Configuration)</small></label >WiFi Active<small> (Leave it Active for WiFi and WiFiAP normal use. <strong>Caution:</strong> Not Active means No WebUI Configuration, so <strong>ONLY</strong> deactivate it on Remote Digirepeater Mode)</small></label
> >
</div> </div>
</div> </div>

View File

@ -123,7 +123,7 @@ void setup() {
} }
void loop() { void loop() {
WIFI_Utils::checkIfAutoAPShouldPowerOff(); WIFI_Utils::checkAutoAPTimeout();
if (isUpdatingOTA) { if (isUpdatingOTA) {
ElegantOTA.loop(); ElegantOTA.loop();
@ -136,7 +136,7 @@ void loop() {
thirdLine = Utils::getLocalIP(); thirdLine = Utils::getLocalIP();
WIFI_Utils::checkWiFi(); // Always use WiFi, not related to IGate/Digi mode WIFI_Utils::checkWiFi();
#ifdef HAS_A7670 #ifdef HAS_A7670
if (Config.aprs_is.active && !modemLoggedToAPRSIS) A7670_Utils::APRS_IS_connect(); if (Config.aprs_is.active && !modemLoggedToAPRSIS) A7670_Utils::APRS_IS_connect();

View File

@ -71,7 +71,7 @@ namespace APRS_IS_Utils {
if (WiFi.status() == WL_CONNECTED) { if (WiFi.status() == WL_CONNECTED) {
wifiState = "OK"; wifiState = "OK";
} else { } else {
if (backUpDigiMode) { if (backUpDigiMode || !Config.wifiAutoAP.active) {
wifiState = "--"; wifiState = "--";
} else { } else {
wifiState = "AP"; wifiState = "AP";

View File

@ -22,7 +22,7 @@ String inputSerialBuffer = "";
namespace TNC_Utils { namespace TNC_Utils {
void setup() { void setup() {
if (Config.tnc.enableServer) { if (Config.tnc.enableServer && Config.wifiAutoAP.active) {
tncServer.stop(); tncServer.stop();
tncServer.begin(); tncServer.begin();
} }
@ -133,12 +133,14 @@ namespace TNC_Utils {
} }
void loop() { void loop() {
if (Config.tnc.enableServer) { if (Config.wifiAutoAP.active) {
checkNewClients(); if (Config.tnc.enableServer) {
readFromClients(); checkNewClients();
} readFromClients();
if (Config.tnc.enableSerial) { }
readFromSerial(); if (Config.tnc.enableSerial) {
readFromSerial();
}
} }
} }
} }

View File

@ -70,7 +70,9 @@ namespace Utils {
} }
String getLocalIP() { String getLocalIP() {
if (!WiFiConnected) { if (!Config.wifiAutoAP.active) {
return "** WiFi AP Killed **";
} else if (!WiFiConnected) {
return "IP : 192.168.4.1"; return "IP : 192.168.4.1";
} else if (backUpDigiMode) { } else if (backUpDigiMode) {
return "- BACKUP DIGI MODE -"; return "- BACKUP DIGI MODE -";

View File

@ -259,23 +259,25 @@ namespace WEB_Utils {
} }
void setup() { void setup() {
server.on("/", HTTP_GET, handleHome); if (Config.wifiAutoAP.active) {
server.on("/status", HTTP_GET, handleStatus); server.on("/", HTTP_GET, handleHome);
server.on("/received-packets.json", HTTP_GET, handleReceivedPackets); server.on("/status", HTTP_GET, handleStatus);
server.on("/configuration.json", HTTP_GET, handleReadConfiguration); server.on("/received-packets.json", HTTP_GET, handleReceivedPackets);
server.on("/configuration.json", HTTP_POST, handleWriteConfiguration); server.on("/configuration.json", HTTP_GET, handleReadConfiguration);
server.on("/action", HTTP_POST, handleAction); server.on("/configuration.json", HTTP_POST, handleWriteConfiguration);
server.on("/style.css", HTTP_GET, handleStyle); server.on("/action", HTTP_POST, handleAction);
server.on("/script.js", HTTP_GET, handleScript); server.on("/style.css", HTTP_GET, handleStyle);
server.on("/bootstrap.css", HTTP_GET, handleBootstrapStyle); server.on("/script.js", HTTP_GET, handleScript);
server.on("/bootstrap.js", HTTP_GET, handleBootstrapScript); server.on("/bootstrap.css", HTTP_GET, handleBootstrapStyle);
server.on("/favicon.png", HTTP_GET, handleFavicon); server.on("/bootstrap.js", HTTP_GET, handleBootstrapScript);
server.on("/favicon.png", HTTP_GET, handleFavicon);
OTA_Utils::setup(&server); // Include OTA Updater for WebServer OTA_Utils::setup(&server); // Include OTA Updater for WebServer
server.onNotFound(handleNotFound); server.onNotFound(handleNotFound);
server.begin(); server.begin();
}
} }
} }

View File

@ -23,33 +23,35 @@ uint32_t lastBackupDigiTime = millis();
namespace WIFI_Utils { namespace WIFI_Utils {
void checkWiFi() { void checkWiFi() {
if (backUpDigiMode) { if (Config.wifiAutoAP.active) {
uint32_t WiFiCheck = millis() - lastBackupDigiTime; if (backUpDigiMode) {
if (WiFi.status() != WL_CONNECTED && WiFiCheck >= 15 * 60 * 1000) { uint32_t WiFiCheck = millis() - lastBackupDigiTime;
Serial.println("*** Stoping BackUp Digi Mode ***"); if (WiFi.status() != WL_CONNECTED && WiFiCheck >= 15 * 60 * 1000) {
backUpDigiMode = false; Serial.println("*** Stoping BackUp Digi Mode ***");
wifiCounter = 0; backUpDigiMode = false;
} else if (WiFi.status() == WL_CONNECTED) { wifiCounter = 0;
Serial.println("*** WiFi Reconnect Success (Stoping Backup Digi Mode) ***"); } else if (WiFi.status() == WL_CONNECTED) {
backUpDigiMode = false; Serial.println("*** WiFi Reconnect Success (Stoping Backup Digi Mode) ***");
wifiCounter = 0; backUpDigiMode = false;
wifiCounter = 0;
}
} }
}
if (!backUpDigiMode && (WiFi.status() != WL_CONNECTED) && ((millis() - previousWiFiMillis) >= 30 * 1000) && !WiFiAutoAPStarted) { if (!backUpDigiMode && (WiFi.status() != WL_CONNECTED) && ((millis() - previousWiFiMillis) >= 30 * 1000) && !WiFiAutoAPStarted) {
Serial.print(millis()); Serial.print(millis());
Serial.println("Reconnecting to WiFi..."); Serial.println("Reconnecting to WiFi...");
WiFi.disconnect(); WiFi.disconnect();
WIFI_Utils::startWiFi();//WiFi.reconnect(); WIFI_Utils::startWiFi();//WiFi.reconnect();
previousWiFiMillis = millis(); previousWiFiMillis = millis();
if (Config.backupDigiMode) { if (Config.backupDigiMode) {
wifiCounter++; wifiCounter++;
} }
if (wifiCounter >= 2) { if (wifiCounter >= 2) {
Serial.println("*** Starting BackUp Digi Mode ***"); Serial.println("*** Starting BackUp Digi Mode ***");
backUpDigiMode = true; backUpDigiMode = true;
lastBackupDigiTime = millis(); lastBackupDigiTime = millis();
}
} }
} }
} }
@ -131,7 +133,7 @@ namespace WIFI_Utils {
} }
} }
void checkIfAutoAPShouldPowerOff() { void checkAutoAPTimeout() {
if (WiFiAutoAPStarted && Config.wifiAutoAP.timeout > 0) { if (WiFiAutoAPStarted && Config.wifiAutoAP.timeout > 0) {
if (WiFi.softAPgetStationNum() > 0) { if (WiFi.softAPgetStationNum() > 0) {
WiFiAutoAPTime = 0; WiFiAutoAPTime = 0;

View File

@ -9,7 +9,7 @@ namespace WIFI_Utils {
void checkWiFi(); void checkWiFi();
void startAutoAP(); void startAutoAP();
void startWiFi(); void startWiFi();
void checkIfAutoAPShouldPowerOff(); void checkAutoAPTimeout();
void setup(); void setup();
} }