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-09 20:56:42 -06:00
parent cc12aa101a
commit adbb86cec0

View File

@@ -357,10 +357,11 @@ void WiFiComponent::start() {
WiFiAP params; WiFiAP params;
bool loaded_fast_connect = this->load_fast_connect_settings_(params); bool loaded_fast_connect = this->load_fast_connect_settings_(params);
// Skip fast_connect if no saved data AND (first network is hidden OR only one AP configured) // Skip fast_connect if no saved data AND (no configured networks OR first is hidden OR only one AP)
// Logic: Try fast_connect if we have saved settings (might be for a working non-hidden network) // Try fast_connect if:
// OR if we have multiple APs to cycle through // 1. Have saved settings (from previous connection or Improv) - always try these first
if (!loaded_fast_connect && ((!this->sta_.empty() && this->sta_[0].get_hidden()) || this->sta_.size() <= 1)) { // 2. Have multiple configured APs to cycle through
if (!loaded_fast_connect && (this->sta_.empty() || this->sta_[0].get_hidden() || this->sta_.size() <= 1)) {
this->start_initial_connection_(); this->start_initial_connection_();
} else { } else {
// FAST CONNECT ENABLED: Either have saved data OR multiple configured APs to try // FAST CONNECT ENABLED: Either have saved data OR multiple configured APs to try
@@ -600,7 +601,12 @@ void WiFiComponent::set_sta(const WiFiAP &ap) {
WiFiAP WiFiComponent::build_params_for_current_phase_() { WiFiAP WiFiComponent::build_params_for_current_phase_() {
const WiFiAP *config = this->get_selected_sta_(); const WiFiAP *config = this->get_selected_sta_();
assert(config != nullptr); if (config == nullptr) {
ESP_LOGE(TAG, "No valid network config (selected_sta_index_=%d, sta_.size()=%zu)",
static_cast<int>(this->selected_sta_index_), this->sta_.size());
// Return empty params - caller should handle this gracefully
return WiFiAP();
}
WiFiAP params = *config; WiFiAP params = *config;