1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-18 15:55:46 +00:00
This commit is contained in:
J. Nick Koston
2025-11-06 13:51:47 -06:00
parent 047773e62f
commit 703b1cf314
2 changed files with 9 additions and 2 deletions

View File

@@ -821,7 +821,7 @@ void WiFiComponent::retry_connect() {
if (this->trying_loaded_ap_) { if (this->trying_loaded_ap_) {
this->trying_loaded_ap_ = false; this->trying_loaded_ap_ = false;
this->selected_sta_index_ = 0; // Retry from the first configured AP this->selected_sta_index_ = 0; // Retry from the first configured AP
this->num_retried_ = 0; this->reset_for_next_ap_attempt_();
} else if (this->selected_sta_index_ >= static_cast<int8_t>(this->sta_.size()) - 1) { } else if (this->selected_sta_index_ >= static_cast<int8_t>(this->sta_.size()) - 1) {
// Exhausted all configured APs, fall back to full scan // Exhausted all configured APs, fall back to full scan
ESP_LOGW(TAG, "No more APs to try, starting scan"); ESP_LOGW(TAG, "No more APs to try, starting scan");
@@ -831,7 +831,7 @@ void WiFiComponent::retry_connect() {
} else { } else {
// Try next AP // Try next AP
this->selected_sta_index_++; this->selected_sta_index_++;
this->num_retried_ = 0; this->reset_for_next_ap_attempt_();
} }
#else #else
if (this->num_retried_ > 5) { if (this->num_retried_ > 5) {

View File

@@ -385,6 +385,13 @@ class WiFiComponent : public Component {
this->start_connecting(connection_params, two); this->start_connecting(connection_params, two);
} }
// Reset state for next fast connect AP attempt
// Clears old scan data so the new AP is tried with config only (SSID without specific BSSID/channel)
void reset_for_next_ap_attempt_() {
this->num_retried_ = 0;
this->scan_result_.clear();
}
void wifi_loop_(); void wifi_loop_();
bool wifi_mode_(optional<bool> sta, optional<bool> ap); bool wifi_mode_(optional<bool> sta, optional<bool> ap);
bool wifi_sta_pre_setup_(); bool wifi_sta_pre_setup_();