mirror of
https://github.com/esphome/esphome.git
synced 2025-11-19 00:05:43 +00:00
no delay
This commit is contained in:
@@ -51,7 +51,11 @@ void CaptivePortal::handle_wifisave(AsyncWebServerRequest *request) {
|
|||||||
ESP_LOGI(TAG, " SSID='%s'", ssid.c_str());
|
ESP_LOGI(TAG, " SSID='%s'", ssid.c_str());
|
||||||
ESP_LOGI(TAG, " Password=" LOG_SECRET("'%s'"), psk.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
|
// 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); });
|
this->defer([ssid, psk]() {
|
||||||
|
wifi::global_wifi_component->save_wifi_sta(ssid, psk);
|
||||||
|
// Trigger immediate retry to attempt connection with new credentials
|
||||||
|
wifi::global_wifi_component->retry_connect();
|
||||||
|
});
|
||||||
request->redirect(ESPHOME_F("/?save"));
|
request->redirect(ESPHOME_F("/?save"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -381,6 +381,8 @@ void ESP32ImprovComponent::check_wifi_connection_() {
|
|||||||
|
|
||||||
if (this->state_ == improv::STATE_PROVISIONING) {
|
if (this->state_ == improv::STATE_PROVISIONING) {
|
||||||
wifi::global_wifi_component->save_wifi_sta(this->connecting_sta_.get_ssid(), this->connecting_sta_.get_password());
|
wifi::global_wifi_component->save_wifi_sta(this->connecting_sta_.get_ssid(), this->connecting_sta_.get_password());
|
||||||
|
// Trigger immediate retry to attempt connection with new credentials
|
||||||
|
wifi::global_wifi_component->retry_connect();
|
||||||
this->connecting_sta_ = {};
|
this->connecting_sta_ = {};
|
||||||
this->cancel_timeout("wifi-connect-timeout");
|
this->cancel_timeout("wifi-connect-timeout");
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ void ImprovSerialComponent::loop() {
|
|||||||
if (wifi::global_wifi_component->is_connected()) {
|
if (wifi::global_wifi_component->is_connected()) {
|
||||||
wifi::global_wifi_component->save_wifi_sta(this->connecting_sta_.get_ssid(),
|
wifi::global_wifi_component->save_wifi_sta(this->connecting_sta_.get_ssid(),
|
||||||
this->connecting_sta_.get_password());
|
this->connecting_sta_.get_password());
|
||||||
|
// Trigger immediate retry to attempt connection with new credentials
|
||||||
|
wifi::global_wifi_component->retry_connect();
|
||||||
this->connecting_sta_ = {};
|
this->connecting_sta_ = {};
|
||||||
this->cancel_timeout("wifi-connect-timeout");
|
this->cancel_timeout("wifi-connect-timeout");
|
||||||
this->set_state_(improv::STATE_PROVISIONED);
|
this->set_state_(improv::STATE_PROVISIONED);
|
||||||
|
|||||||
@@ -291,6 +291,7 @@ class WiFiComponent : public Component {
|
|||||||
void set_passive_scan(bool passive);
|
void set_passive_scan(bool passive);
|
||||||
|
|
||||||
void save_wifi_sta(const std::string &ssid, const std::string &password);
|
void save_wifi_sta(const std::string &ssid, const std::string &password);
|
||||||
|
|
||||||
// ========== INTERNAL METHODS ==========
|
// ========== INTERNAL METHODS ==========
|
||||||
// (In most use cases you won't need these)
|
// (In most use cases you won't need these)
|
||||||
/// Setup WiFi interface.
|
/// Setup WiFi interface.
|
||||||
|
|||||||
Reference in New Issue
Block a user