From dac1e1a69c18a155f60b211412a3dce000c7a8a5 Mon Sep 17 00:00:00 2001 From: proddy Date: Thu, 6 Aug 2026 12:10:39 +0200 Subject: [PATCH] prevent STA warning on boot --- src/core/network.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/network.cpp b/src/core/network.cpp index 3eee3ae14..467171626 100644 --- a/src/core/network.cpp +++ b/src/core/network.cpp @@ -82,7 +82,13 @@ void Network::begin() { WiFi.persistent(false); WiFi.setAutoReconnect(false); WiFi.mode(WIFI_STA); - WiFi.disconnect(true, true); // wipe old settings in NVS. Will give a warning on boot but can be ignored. + + if (WiFi.STA.started()) { + WiFi.disconnect(true, true); // wipe old settings; only when STA is up + } else { + WiFi.disconnect(true, false); // disconnect/off without erase, so no warning is shown + } + WiFi.setScanMethod(WIFI_ALL_CHANNEL_SCAN); WiFi.setHostname(hostname_.c_str()); // updates shared default_hostname buffer WiFi.enableSTA(true); // creates the STA netif