From 6d12c3a6fbb44633aabd43b1b332bb90d4f5eeaa Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Jan 2026 13:10:56 +0000 Subject: [PATCH] Fix WiFi file transfer crash by disabling WiFi sleep early The previous commit added an initialization delay, but the device was still crashing with a store access fault during web server operation. The root cause was WiFi sleep mode causing instability in the ESP32 WiFi/TCP stack. Root cause analysis: - WiFi.setSleep(false) was only called when web server started - By that time, WiFi operations had already occurred with sleep mode enabled - WiFi sleep mode can cause memory corruption and crashes in the WiFi stack - The crashes manifested as "Store access fault" errors during web server operation Why hotspot-first workaround worked: - Hotspot mode initialized WiFi and called setSleep(false) via web server - This properly configured the WiFi hardware - When switching to STA mode later, WiFi stack remained stable - Direct STA mode start didn't have this initialization, causing crashes Fix: - Added WiFi.setSleep(false) immediately after WiFi.mode() in both STA and AP paths - This disables sleep mode before any WiFi operations occur - Prevents WiFi stack instability and memory corruption - Matches the critical importance noted in CrossPointWebServer.cpp:54-55 Files changed: - CrossPointWebServerActivity.cpp:142 - STA mode path - CrossPointWebServerActivity.cpp:191 - AP mode path (for consistency) --- src/activities/network/CrossPointWebServerActivity.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/activities/network/CrossPointWebServerActivity.cpp b/src/activities/network/CrossPointWebServerActivity.cpp index 8110f73..7c49286 100644 --- a/src/activities/network/CrossPointWebServerActivity.cpp +++ b/src/activities/network/CrossPointWebServerActivity.cpp @@ -139,6 +139,7 @@ void CrossPointWebServerActivity::onNetworkModeSelected(const NetworkMode mode) Serial.printf("[%lu] [WEBACT] Turning on WiFi (STA mode)...\n", millis()); WiFi.mode(WIFI_STA); delay(100); // Allow WiFi hardware to initialize before proceeding + WiFi.setSleep(false); // Disable WiFi sleep immediately to prevent crashes state = WebServerActivityState::WIFI_SELECTION; Serial.printf("[%lu] [WEBACT] Launching WifiSelectionActivity...\n", millis()); @@ -187,6 +188,7 @@ void CrossPointWebServerActivity::startAccessPoint() { // Configure and start the AP WiFi.mode(WIFI_AP); delay(100); + WiFi.setSleep(false); // Disable WiFi sleep immediately to prevent crashes // Start soft AP bool apStarted;