mirror of
https://github.com/esphome/esphome.git
synced 2026-09-20 03:28:41 +00:00
Simplify captive_portal lambda capture
Capture auto type directly and use c_str() overload of save_wifi_sta. Works on both std::string and Arduino String.
This commit is contained in:
@@ -59,9 +59,7 @@ void CaptivePortal::handle_wifisave(AsyncWebServerRequest *request) {
|
||||
wifi::global_wifi_component->save_wifi_sta(ssid.c_str(), psk.c_str());
|
||||
#else
|
||||
// Defer save to main loop thread to avoid NVS operations from HTTP thread
|
||||
this->defer([ssid = std::string(ssid.c_str(), ssid.length()), psk = std::string(psk.c_str(), psk.length())]() {
|
||||
wifi::global_wifi_component->save_wifi_sta(ssid, psk);
|
||||
});
|
||||
this->defer([ssid, psk]() { wifi::global_wifi_component->save_wifi_sta(ssid.c_str(), psk.c_str()); });
|
||||
#endif
|
||||
request->redirect(ESPHOME_F("/?save"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user