From 0a44e58d4ea3dce7f64f22c17f74586b0a16560d Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Jan 2026 13:03:09 +0000 Subject: [PATCH] Fix WiFi file transfer crash by adding initialization delay Fixed a critical bug where WiFi file transfer would crash and lock the device when accessed directly. The issue was caused by missing initialization time after WiFi.mode(WIFI_STA) call. Root cause: - Hotspot mode includes delay(100) after WiFi.mode(WIFI_AP) to allow hardware initialization - Join Network mode was missing this delay after WiFi.mode(WIFI_STA) - Without the delay, ESP32 WiFi hardware wasn't properly initialized - This caused crashes when starting the web server in STA mode Fix: - Added delay(100) after WiFi.mode(WIFI_STA) in onNetworkModeSelected() - Matches the proven initialization pattern used in hotspot mode - Comment added to explain the purpose of the delay This explains why going to hotspot first and exiting worked - hotspot mode properly initialized the WiFi hardware, which remained stable for subsequent file transfer operations. --- src/activities/network/CrossPointWebServerActivity.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/activities/network/CrossPointWebServerActivity.cpp b/src/activities/network/CrossPointWebServerActivity.cpp index dde05614..8110f73a 100644 --- a/src/activities/network/CrossPointWebServerActivity.cpp +++ b/src/activities/network/CrossPointWebServerActivity.cpp @@ -138,6 +138,7 @@ void CrossPointWebServerActivity::onNetworkModeSelected(const NetworkMode mode) // STA mode - launch WiFi selection Serial.printf("[%lu] [WEBACT] Turning on WiFi (STA mode)...\n", millis()); WiFi.mode(WIFI_STA); + delay(100); // Allow WiFi hardware to initialize before proceeding state = WebServerActivityState::WIFI_SELECTION; Serial.printf("[%lu] [WEBACT] Launching WifiSelectionActivity...\n", millis());