fix(esp32): auto-enable WiFi NIC for MicroPython sketches using network module

The hasWifi auto-detection in useSimulatorStore.startBoard only matched
Arduino C++ patterns (#include <WiFi.h>, WiFi.begin). MicroPython
sketches that call `import network` or `network.WLAN(STA_IF)` were
not detected, so wifi_enabled stayed false and the backend never
attached the esp32_wifi NIC model to QEMU.

Symptom: any MicroPython ESP32 example that touches the network
module hangs in network.WLAN(STA_IF) (the constructor that triggers
esp_wifi_init internally) and the FreeRTOS task watchdog trips with
TG1WDT_SYS_RESET ~26 seconds after boot. The chip then reboot-loops.

Mirror the Pico W detector right below this one — it already handles
both Arduino and MicroPython patterns. Now ESP32 does too.

Affects 31 examples in examples-100-days.ts that use network.WLAN.
This commit is contained in:
David Montero 2026-05-23 22:54:10 +02:00
parent c147e7a4aa
commit cf28b3b5ea
1 changed files with 7 additions and 1 deletions

View File

@ -1443,7 +1443,13 @@ export const useSimulatorStore = create<SimulatorState>((set, get) => {
f.content.includes('#include <WiFi.h>') ||
f.content.includes('#include <esp_wifi.h>') ||
f.content.includes('#include "WiFi.h"') ||
f.content.includes('WiFi.begin('),
f.content.includes('WiFi.begin(') ||
// MicroPython patterns — without these the WiFi NIC is never
// passed to QEMU, and `network.WLAN(STA_IF)` hangs forever
// trying to init a peripheral that doesn't exist, eventually
// tripping the FreeRTOS task watchdog (TG1WDT_SYS_RESET).
/import\s+network\b/.test(f.content) ||
/network\.WLAN/.test(f.content),
);
}
esp32Bridge.wifiEnabled = hasWifi;