mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-07 08:07:40 +03:00
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)
This commit is contained in:
parent
0a44e58d4e
commit
6d12c3a6fb
@ -139,6 +139,7 @@ void CrossPointWebServerActivity::onNetworkModeSelected(const NetworkMode mode)
|
|||||||
Serial.printf("[%lu] [WEBACT] Turning on WiFi (STA mode)...\n", millis());
|
Serial.printf("[%lu] [WEBACT] Turning on WiFi (STA mode)...\n", millis());
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
delay(100); // Allow WiFi hardware to initialize before proceeding
|
delay(100); // Allow WiFi hardware to initialize before proceeding
|
||||||
|
WiFi.setSleep(false); // Disable WiFi sleep immediately to prevent crashes
|
||||||
|
|
||||||
state = WebServerActivityState::WIFI_SELECTION;
|
state = WebServerActivityState::WIFI_SELECTION;
|
||||||
Serial.printf("[%lu] [WEBACT] Launching WifiSelectionActivity...\n", millis());
|
Serial.printf("[%lu] [WEBACT] Launching WifiSelectionActivity...\n", millis());
|
||||||
@ -187,6 +188,7 @@ void CrossPointWebServerActivity::startAccessPoint() {
|
|||||||
// Configure and start the AP
|
// Configure and start the AP
|
||||||
WiFi.mode(WIFI_AP);
|
WiFi.mode(WIFI_AP);
|
||||||
delay(100);
|
delay(100);
|
||||||
|
WiFi.setSleep(false); // Disable WiFi sleep immediately to prevent crashes
|
||||||
|
|
||||||
// Start soft AP
|
// Start soft AP
|
||||||
bool apStarted;
|
bool apStarted;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user