fix: use board's file group for WiFi auto-detection instead of legacy global files

startBoard() was reading useEditorStore.getState().files (the legacy global
array with the default Arduino sketch) instead of the board's specific file
group. This caused hasWifi to always be false for ESP32 boards, so QEMU
never received the -nic flag and WiFi never connected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
David Montero 2026-04-05 21:36:04 +02:00
parent 1298be72b2
commit 7c755ca3d1
1 changed files with 6 additions and 3 deletions

View File

@ -659,9 +659,12 @@ export const useSimulatorStore = create<SimulatorState>((set, get) => {
} }
esp32Bridge.setSensors(sensors); esp32Bridge.setSensors(sensors);
// Auto-detect WiFi usage in sketch files // Auto-detect WiFi usage in this board's sketch files.
const editorFiles = useEditorStore.getState().files; // Use the board's file group (not the legacy global files array).
const hasWifi = editorFiles.some(f => const editorState = useEditorStore.getState();
const boardFiles = editorState.fileGroups[board.activeFileGroupId]
?? editorState.files;
const hasWifi = boardFiles.some(f =>
f.content.includes('#include <WiFi.h>') || f.content.includes('#include <WiFi.h>') ||
f.content.includes('#include <esp_wifi.h>') || f.content.includes('#include <esp_wifi.h>') ||
f.content.includes('#include "WiFi.h"') || f.content.includes('#include "WiFi.h"') ||