mirror of
https://github.com/esphome/esphome.git
synced 2025-11-14 13:55:45 +00:00
cleanup
This commit is contained in:
@@ -900,13 +900,41 @@ WiFiRetryPhase WiFiComponent::determine_next_phase_() {
|
|||||||
return WiFiRetryPhase::SCAN_CONNECTING; // Keep retrying
|
return WiFiRetryPhase::SCAN_CONNECTING; // Keep retrying
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Add mesh fallback when platform-specific auth failure detection is implemented
|
// Auth failure + have other same-SSID APs available? Try mesh fallback
|
||||||
// For now, just try with hidden flag after retries exhausted
|
if (wifi_sta_connect_auth_failed() && !this->scan_result_.empty() &&
|
||||||
|
this->scan_result_index_ < this->scan_result_.size()) {
|
||||||
|
// scan_result_ contains multiple SSIDs - search for next AP with same SSID
|
||||||
|
const auto ¤t_ssid = this->scan_result_[this->scan_result_index_].get_ssid();
|
||||||
|
|
||||||
|
// Look for next AP with same SSID (mesh fallback)
|
||||||
|
for (size_t i = this->scan_result_index_ + 1; i < this->scan_result_.size(); i++) {
|
||||||
|
if (this->scan_result_[i].get_ssid() == current_ssid) {
|
||||||
|
return WiFiRetryPhase::SCAN_NEXT_SAME_SSID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// No mesh fallback available, try with hidden flag
|
||||||
return WiFiRetryPhase::SCAN_WITH_HIDDEN;
|
return WiFiRetryPhase::SCAN_WITH_HIDDEN;
|
||||||
|
|
||||||
case WiFiRetryPhase::SCAN_NEXT_SAME_SSID:
|
case WiFiRetryPhase::SCAN_NEXT_SAME_SSID:
|
||||||
// TODO: This phase requires auth failure detection from platform code
|
if (this->num_retried_ < 3) {
|
||||||
// For now, just fall through to hidden
|
return WiFiRetryPhase::SCAN_NEXT_SAME_SSID; // Keep retrying current AP
|
||||||
|
}
|
||||||
|
|
||||||
|
// Can we try another same-SSID AP?
|
||||||
|
if (!this->scan_result_.empty() && this->scan_result_index_ < this->scan_result_.size()) {
|
||||||
|
const auto ¤t_ssid = this->scan_result_[this->scan_result_index_].get_ssid();
|
||||||
|
|
||||||
|
// Search for next AP with same SSID (scan_result_ contains multiple SSIDs)
|
||||||
|
for (size_t i = this->scan_result_index_ + 1; i < this->scan_result_.size(); i++) {
|
||||||
|
if (this->scan_result_[i].get_ssid() == current_ssid) {
|
||||||
|
return WiFiRetryPhase::SCAN_NEXT_SAME_SSID; // Try next BSSID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// No more same-SSID APs, try with hidden flag
|
||||||
return WiFiRetryPhase::SCAN_WITH_HIDDEN;
|
return WiFiRetryPhase::SCAN_WITH_HIDDEN;
|
||||||
|
|
||||||
case WiFiRetryPhase::SCAN_WITH_HIDDEN:
|
case WiFiRetryPhase::SCAN_WITH_HIDDEN:
|
||||||
@@ -973,6 +1001,7 @@ void WiFiComponent::transition_to_phase_(WiFiRetryPhase new_phase) {
|
|||||||
if (this->scan_result_[i].get_ssid() == current_ssid) {
|
if (this->scan_result_[i].get_ssid() == current_ssid) {
|
||||||
this->scan_result_index_ = i;
|
this->scan_result_index_ = i;
|
||||||
this->num_retried_ = 0;
|
this->num_retried_ = 0;
|
||||||
|
wifi_sta_clear_auth_failed(); // Clear auth failure flag when moving to next AP
|
||||||
ESP_LOGI(TAG, "Trying next AP with same SSID: " LOG_SECRET("'%s'"), current_ssid.c_str());
|
ESP_LOGI(TAG, "Trying next AP with same SSID: " LOG_SECRET("'%s'"), current_ssid.c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,11 @@ struct SavedWifiFastConnectSettings {
|
|||||||
int8_t ap_index;
|
int8_t ap_index;
|
||||||
} PACKED; // NOLINT
|
} PACKED; // NOLINT
|
||||||
|
|
||||||
|
// Platform-specific auth failure tracking functions
|
||||||
|
// Implemented in wifi_component_esp8266.cpp, wifi_component_esp_idf.cpp, wifi_component_libretiny.cpp
|
||||||
|
bool wifi_sta_connect_auth_failed();
|
||||||
|
void wifi_sta_clear_auth_failed();
|
||||||
|
|
||||||
enum WiFiComponentState : uint8_t {
|
enum WiFiComponentState : uint8_t {
|
||||||
/** Nothing has been initialized yet. Internal AP, if configured, is disabled at this point. */
|
/** Nothing has been initialized yet. Internal AP, if configured, is disabled at this point. */
|
||||||
WIFI_COMPONENT_STATE_OFF = 0,
|
WIFI_COMPONENT_STATE_OFF = 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user