mirror of
https://github.com/esphome/esphome.git
synced 2025-11-19 08:15:49 +00:00
no delay
This commit is contained in:
@@ -51,11 +51,7 @@ void CaptivePortal::handle_wifisave(AsyncWebServerRequest *request) {
|
||||
ESP_LOGI(TAG, " SSID='%s'", ssid.c_str());
|
||||
ESP_LOGI(TAG, " Password=" LOG_SECRET("'%s'"), psk.c_str());
|
||||
// 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);
|
||||
// Trigger connection attempt (exits cooldown if needed)
|
||||
wifi::global_wifi_component->connect_soon();
|
||||
});
|
||||
this->defer([ssid, psk]() { wifi::global_wifi_component->save_wifi_sta(ssid, psk); });
|
||||
request->redirect(ESPHOME_F("/?save"));
|
||||
}
|
||||
|
||||
|
||||
@@ -381,8 +381,6 @@ void ESP32ImprovComponent::check_wifi_connection_() {
|
||||
|
||||
if (this->state_ == improv::STATE_PROVISIONING) {
|
||||
wifi::global_wifi_component->save_wifi_sta(this->connecting_sta_.get_ssid(), this->connecting_sta_.get_password());
|
||||
// Trigger connection attempt (exits cooldown if needed, no-op if already connected)
|
||||
wifi::global_wifi_component->connect_soon();
|
||||
this->connecting_sta_ = {};
|
||||
this->cancel_timeout("wifi-connect-timeout");
|
||||
|
||||
|
||||
@@ -50,8 +50,6 @@ void ImprovSerialComponent::loop() {
|
||||
if (wifi::global_wifi_component->is_connected()) {
|
||||
wifi::global_wifi_component->save_wifi_sta(this->connecting_sta_.get_ssid(),
|
||||
this->connecting_sta_.get_password());
|
||||
// Trigger connection attempt (exits cooldown if needed, no-op if already connected)
|
||||
wifi::global_wifi_component->connect_soon();
|
||||
this->connecting_sta_ = {};
|
||||
this->cancel_timeout("wifi-connect-timeout");
|
||||
this->set_state_(improv::STATE_PROVISIONED);
|
||||
|
||||
@@ -674,6 +674,9 @@ void WiFiComponent::save_wifi_sta(const std::string &ssid, const std::string &pa
|
||||
// Force scan on next attempt even if captive portal is still active
|
||||
// This ensures new credentials are tried with proper BSSID selection after provisioning
|
||||
this->force_scan_after_provision_ = true;
|
||||
|
||||
// Trigger connection attempt (exits cooldown if needed, no-op if already connecting/connected)
|
||||
this->connect_soon();
|
||||
}
|
||||
|
||||
void WiFiComponent::connect_soon() {
|
||||
|
||||
Reference in New Issue
Block a user