mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	feat: wifi.configure now emits error after reconnecting to old AP (#8653)
				
					
				
			This commit is contained in:
		| @@ -483,14 +483,16 @@ template<typename... Ts> class WiFiConfigureAction : public Action<Ts...>, publi | |||||||
|     // Enable WiFi |     // Enable WiFi | ||||||
|     global_wifi_component->enable(); |     global_wifi_component->enable(); | ||||||
|     // Set timeout for the connection |     // Set timeout for the connection | ||||||
|     this->set_timeout("wifi-connect-timeout", this->connection_timeout_.value(x...), [this]() { |     this->set_timeout("wifi-connect-timeout", this->connection_timeout_.value(x...), [this, x...]() { | ||||||
|       this->connecting_ = false; |  | ||||||
|       // If the timeout is reached, stop connecting and revert to the old AP |       // If the timeout is reached, stop connecting and revert to the old AP | ||||||
|       global_wifi_component->disable(); |       global_wifi_component->disable(); | ||||||
|       global_wifi_component->save_wifi_sta(old_sta_.get_ssid(), old_sta_.get_password()); |       global_wifi_component->save_wifi_sta(old_sta_.get_ssid(), old_sta_.get_password()); | ||||||
|       global_wifi_component->enable(); |       global_wifi_component->enable(); | ||||||
|       // Callback to notify the user that the connection failed |       // Start a timeout for the fallback if the connection to the old AP fails | ||||||
|       this->error_trigger_->trigger(); |       this->set_timeout("wifi-fallback-timeout", this->connection_timeout_.value(x...), [this]() { | ||||||
|  |         this->connecting_ = false; | ||||||
|  |         this->error_trigger_->trigger(); | ||||||
|  |       }); | ||||||
|     }); |     }); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -503,6 +505,7 @@ template<typename... Ts> class WiFiConfigureAction : public Action<Ts...>, publi | |||||||
|     if (global_wifi_component->is_connected()) { |     if (global_wifi_component->is_connected()) { | ||||||
|       // The WiFi is connected, stop the timeout and reset the connecting flag |       // The WiFi is connected, stop the timeout and reset the connecting flag | ||||||
|       this->cancel_timeout("wifi-connect-timeout"); |       this->cancel_timeout("wifi-connect-timeout"); | ||||||
|  |       this->cancel_timeout("wifi-fallback-timeout"); | ||||||
|       this->connecting_ = false; |       this->connecting_ = false; | ||||||
|       if (global_wifi_component->wifi_ssid() == this->new_sta_.get_ssid()) { |       if (global_wifi_component->wifi_ssid() == this->new_sta_.get_ssid()) { | ||||||
|         // Callback to notify the user that the connection was successful |         // Callback to notify the user that the connection was successful | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user