mirror of
https://github.com/esphome/esphome.git
synced 2025-11-16 23:05:46 +00:00
Merge branch 'wifi_reconnect_fixes' into integration
This commit is contained in:
@@ -465,6 +465,8 @@ void WiFiComponent::loop() {
|
|||||||
if (!this->is_connected()) {
|
if (!this->is_connected()) {
|
||||||
ESP_LOGW(TAG, "Connection lost; reconnecting");
|
ESP_LOGW(TAG, "Connection lost; reconnecting");
|
||||||
this->state_ = WIFI_COMPONENT_STATE_STA_CONNECTING;
|
this->state_ = WIFI_COMPONENT_STATE_STA_CONNECTING;
|
||||||
|
// Clear error flag before reconnecting so first attempt is not seen as immediate failure
|
||||||
|
this->error_from_callback_ = false;
|
||||||
this->retry_connect();
|
this->retry_connect();
|
||||||
} else {
|
} else {
|
||||||
this->status_clear_warning();
|
this->status_clear_warning();
|
||||||
@@ -1060,6 +1062,10 @@ void WiFiComponent::check_connecting_finished() {
|
|||||||
// Reset to initial phase on successful connection (don't log transition, just reset state)
|
// Reset to initial phase on successful connection (don't log transition, just reset state)
|
||||||
this->retry_phase_ = WiFiRetryPhase::INITIAL_CONNECT;
|
this->retry_phase_ = WiFiRetryPhase::INITIAL_CONNECT;
|
||||||
this->num_retried_ = 0;
|
this->num_retried_ = 0;
|
||||||
|
// Ensure next connection attempt does not inherit error state
|
||||||
|
// so when WiFi disconnects later we start fresh we don't see
|
||||||
|
// the first connection as a failure.
|
||||||
|
this->error_from_callback_ = false;
|
||||||
|
|
||||||
this->print_connect_params_();
|
this->print_connect_params_();
|
||||||
|
|
||||||
@@ -1146,6 +1152,11 @@ WiFiRetryPhase WiFiComponent::determine_next_phase_() {
|
|||||||
return WiFiRetryPhase::FAST_CONNECT_CYCLING_APS; // Move to next AP
|
return WiFiRetryPhase::FAST_CONNECT_CYCLING_APS; // Move to next AP
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
// Check if we should try explicit hidden networks before scanning
|
||||||
|
// This handles reconnection after connection loss where first network is hidden
|
||||||
|
if (!this->sta_.empty() && this->sta_[0].get_hidden()) {
|
||||||
|
return WiFiRetryPhase::EXPLICIT_HIDDEN;
|
||||||
|
}
|
||||||
// No more APs to try, fall back to scan
|
// No more APs to try, fall back to scan
|
||||||
return WiFiRetryPhase::SCAN_CONNECTING;
|
return WiFiRetryPhase::SCAN_CONNECTING;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user