mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-10-31 02:51:58 +01:00
WiFi loop protection
This commit is contained in:
1 parent
c80eb9bd84
commit
e52d4566ba
5 files changed
+16
-2
No files matched your search
@@ -96,4 +96,7 @@ public:
|
|||||||
bool isModemConnected() const;
|
bool isModemConnected() const;
|
||||||
|
|
||||||
bool isWifiAPActive() const;
|
bool isWifiAPActive() const;
|
||||||
|
|
||||||
|
// Check if any network interface was started (lwip TCP/IP stack is initialized)
|
||||||
|
bool hasActiveInterface() const;
|
||||||
};
|
};
|
||||||
@@ -339,6 +339,10 @@ bool NetworkManager::isWifiAPActive() const {
|
|||||||
return _wifiAPmode;
|
return _wifiAPmode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NetworkManager::hasActiveInterface() const {
|
||||||
|
return _wifiSTAmode || _wifiAPmode || _ethernetMode;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if Ethernet is connected
|
// Check if Ethernet is connected
|
||||||
bool NetworkManager::isEthernetConnected() const {
|
bool NetworkManager::isEthernetConnected() const {
|
||||||
return _ethernetMode && _ethernetConnected && ETH.linkUp();
|
return _ethernetMode && _ethernetConnected && ETH.linkUp();
|
||||||
|
|||||||
+3
-1
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include "ESPmDNS.h"
|
#include "ESPmDNS.h"
|
||||||
|
#include "network_manager.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "station_utils.h"
|
#include "station_utils.h"
|
||||||
#include "kiss_protocol.h"
|
#include "kiss_protocol.h"
|
||||||
@@ -28,6 +29,7 @@
|
|||||||
|
|
||||||
|
|
||||||
extern Configuration Config;
|
extern Configuration Config;
|
||||||
|
extern NetworkManager *networkManager;
|
||||||
extern WiFiClient aprsIsClient;
|
extern WiFiClient aprsIsClient;
|
||||||
extern bool passcodeValid;
|
extern bool passcodeValid;
|
||||||
|
|
||||||
@@ -47,7 +49,7 @@ String inputSerialBuffer = "";
|
|||||||
namespace TNC_Utils {
|
namespace TNC_Utils {
|
||||||
|
|
||||||
void setup() {
|
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.stop();
|
||||||
tncServer.begin();
|
tncServer.begin();
|
||||||
String host = "igate-" + Config.callsign;
|
String host = "igate-" + Config.callsign;
|
||||||
|
|||||||
+3
-1
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
#include "network_manager.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "ota_utils.h"
|
#include "ota_utils.h"
|
||||||
#include "web_utils.h"
|
#include "web_utils.h"
|
||||||
@@ -26,6 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
extern Configuration Config;
|
extern Configuration Config;
|
||||||
|
extern NetworkManager *networkManager;
|
||||||
extern uint32_t lastBeaconTx;
|
extern uint32_t lastBeaconTx;
|
||||||
extern std::vector<ReceivedPacket> receivedPackets;
|
extern std::vector<ReceivedPacket> receivedPackets;
|
||||||
|
|
||||||
@@ -435,7 +437,7 @@ namespace WEB_Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setup() {
|
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("/", HTTP_GET, handleHome);
|
||||||
server.on("/status", HTTP_GET, handleStatus);
|
server.on("/status", HTTP_GET, handleStatus);
|
||||||
server.on("/received-packets.json", HTTP_GET, handleReceivedPackets);
|
server.on("/received-packets.json", HTTP_GET, handleReceivedPackets);
|
||||||
|
|||||||
@@ -99,6 +99,9 @@ namespace WIFI_Utils {
|
|||||||
if (Config.wifiAutoAP.enabled) {
|
if (Config.wifiAutoAP.enabled) {
|
||||||
Serial.println("Starting AP fallback...");
|
Serial.println("Starting AP fallback...");
|
||||||
startAutoAP();
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user