WiFi loop protection

This commit is contained in:
Ricardo Guzman committed 2026-09-23 12:39:07 -03:00
1 parent c80eb9bd84
commit e52d4566ba
5 files changed
+16 -2

No files matched your search

+3
View File
@@ -96,4 +96,7 @@ public:
bool isModemConnected() const;
bool isWifiAPActive() const;
// Check if any network interface was started (lwip TCP/IP stack is initialized)
bool hasActiveInterface() const;
};
+4
View File
@@ -339,6 +339,10 @@ bool NetworkManager::isWifiAPActive() const {
return _wifiAPmode;
}
bool NetworkManager::hasActiveInterface() const {
return _wifiSTAmode || _wifiAPmode || _ethernetMode;
}
// Check if Ethernet is connected
bool NetworkManager::isEthernetConnected() const {
return _ethernetMode && _ethernetConnected && ETH.linkUp();
+3 -1
View File
@@ -18,6 +18,7 @@
#include <WiFi.h>
#include "ESPmDNS.h"
#include "network_manager.h"
#include "configuration.h"
#include "station_utils.h"
#include "kiss_protocol.h"
@@ -28,6 +29,7 @@
extern Configuration Config;
extern NetworkManager *networkManager;
extern WiFiClient aprsIsClient;
extern bool passcodeValid;
@@ -47,7 +49,7 @@ String inputSerialBuffer = "";
namespace TNC_Utils {
void setup() {
if (Config.tnc.enableServer && Config.digi.ecoMode == 0) {
if (Config.tnc.enableServer && Config.digi.ecoMode == 0 && networkManager->hasActiveInterface()) { // no WiFi STA/AP or Ethernet started = no TCP/IP stack
tncServer.stop();
tncServer.begin();
String host = "igate-" + Config.callsign;
+3 -1
View File
@@ -17,6 +17,7 @@
*/
#include <ArduinoJson.h>
#include "network_manager.h"
#include "configuration.h"
#include "ota_utils.h"
#include "web_utils.h"
@@ -26,6 +27,7 @@
extern Configuration Config;
extern NetworkManager *networkManager;
extern uint32_t lastBeaconTx;
extern std::vector<ReceivedPacket> receivedPackets;
@@ -435,7 +437,7 @@ namespace WEB_Utils {
}
void setup() {
if (Config.digi.ecoMode == 0) {
if (Config.digi.ecoMode == 0 && networkManager->hasActiveInterface()) { // no WiFi STA/AP or Ethernet started = no TCP/IP stack
server.on("/", HTTP_GET, handleHome);
server.on("/status", HTTP_GET, handleStatus);
server.on("/received-packets.json", HTTP_GET, handleReceivedPackets);
+3
View File
@@ -99,6 +99,9 @@ namespace WIFI_Utils {
if (Config.wifiAutoAP.enabled) {
Serial.println("Starting AP fallback...");
startAutoAP();
} else {
Serial.println("AutoAP disabled: no network, WebUI/TNC server not started (reconfigure over USB)");
displayShow("", " No WiFi / No AP", " WebUI disabled", " loading ...", 2000);
}
return;
}