mirror of
https://github.com/esphome/esphome.git
synced 2026-02-08 00:31:58 +00:00
[captive_portal] Avoid defer overhead on ESP8266 when saving WiFi credentials (#12981)
This commit is contained in:
@@ -54,8 +54,13 @@ void CaptivePortal::handle_wifisave(AsyncWebServerRequest *request) {
|
||||
" SSID='%s'\n"
|
||||
" Password=" LOG_SECRET("'%s'"),
|
||||
ssid.c_str(), psk.c_str());
|
||||
#ifdef USE_ESP8266
|
||||
// ESP8266 is single-threaded, call directly
|
||||
wifi::global_wifi_component->save_wifi_sta(ssid, psk);
|
||||
#else
|
||||
// Defer save to main loop thread to avoid NVS operations from HTTP thread
|
||||
this->defer([ssid, psk]() { wifi::global_wifi_component->save_wifi_sta(ssid, psk); });
|
||||
#endif
|
||||
request->redirect(ESPHOME_F("/?save"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user