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-11 08:52:12 -06:00
parent 262f28aec5
commit bee174150b
2 changed files with 11 additions and 10 deletions

View File

@@ -1062,8 +1062,8 @@ void WiFiComponent::check_connecting_finished() {
this->state_ = WIFI_COMPONENT_STATE_STA_CONNECTED; this->state_ = WIFI_COMPONENT_STATE_STA_CONNECTED;
this->num_retried_ = 0; this->num_retried_ = 0;
// Clear priority tracking if all priorities are identical // Clear priority tracking if all priorities are at minimum
this->clear_priorities_if_all_same_(); this->clear_priorities_if_all_min_();
#ifdef USE_WIFI_FAST_CONNECT #ifdef USE_WIFI_FAST_CONNECT
this->save_fast_connect_settings_(); this->save_fast_connect_settings_();
@@ -1293,9 +1293,10 @@ bool WiFiComponent::transition_to_phase_(WiFiRetryPhase new_phase) {
return false; // Did not start scan, can proceed with connection return false; // Did not start scan, can proceed with connection
} }
/// Clear BSSID priority tracking if all priorities are identical (can't differentiate, saves memory) /// Clear BSSID priority tracking if all priorities are at minimum (saves memory)
/// Called when starting a fresh connection attempt or after successful connection /// At minimum priority, all BSSIDs are equally bad, so priority tracking is useless
void WiFiComponent::clear_priorities_if_all_same_() { /// Called after successful connection or after failed connection attempts
void WiFiComponent::clear_priorities_if_all_min_() {
if (this->sta_priorities_.empty()) { if (this->sta_priorities_.empty()) {
return; return;
} }
@@ -1366,9 +1367,9 @@ void WiFiComponent::log_and_adjust_priority_for_failed_connect_() {
ESP_LOGD(TAG, "Failed " LOG_SECRET("'%s'") " " LOG_SECRET("(%s)") ", priority %d → %d", ssid.c_str(), ESP_LOGD(TAG, "Failed " LOG_SECRET("'%s'") " " LOG_SECRET("(%s)") ", priority %d → %d", ssid.c_str(),
format_mac_address_pretty(failed_bssid.value().data()).c_str(), old_priority, new_priority); format_mac_address_pretty(failed_bssid.value().data()).c_str(), old_priority, new_priority);
// After adjusting priority, check if all priorities are now identical // After adjusting priority, check if all priorities are now at minimum
// If so, clear the vector to save memory // If so, clear the vector to save memory and reset for fresh start
this->clear_priorities_if_all_same_(); this->clear_priorities_if_all_min_();
} }
/// Handle target advancement or retry counter increment when staying in the same phase /// Handle target advancement or retry counter increment when staying in the same phase

View File

@@ -383,8 +383,8 @@ class WiFiComponent : public Component {
int8_t find_next_hidden_sta_(int8_t start_index, bool include_explicit_hidden = true); int8_t find_next_hidden_sta_(int8_t start_index, bool include_explicit_hidden = true);
/// Log failed connection and decrease BSSID priority to avoid repeated attempts /// Log failed connection and decrease BSSID priority to avoid repeated attempts
void log_and_adjust_priority_for_failed_connect_(); void log_and_adjust_priority_for_failed_connect_();
/// Clear BSSID priority tracking if all priorities are identical (saves memory) /// Clear BSSID priority tracking if all priorities are at minimum (saves memory)
void clear_priorities_if_all_same_(); void clear_priorities_if_all_min_();
/// Advance to next target (AP/SSID) within current phase, or increment retry counter /// Advance to next target (AP/SSID) within current phase, or increment retry counter
/// Called when staying in the same phase after a failed connection attempt /// Called when staying in the same phase after a failed connection attempt
void advance_to_next_target_or_increment_retry_(); void advance_to_next_target_or_increment_retry_();