wifi: fix reconnect issue due to enablement of fast connect (#6598)

This commit is contained in:
Javier Peletier 2024-04-22 22:48:06 +02:00 committed by Jesse Hills
parent 496b7f45db
commit 1a152169e0
No known key found for this signature in database
GPG key ID: BEAAE804EFD8E83A
2 changed files with 7 additions and 2 deletions

View file

@ -128,7 +128,7 @@ void WiFiComponent::loop() {
case WIFI_COMPONENT_STATE_COOLDOWN: {
this->status_set_warning();
if (millis() - this->action_started_ > 5000) {
if (this->fast_connect_) {
if (this->fast_connect_ || this->retry_hidden_) {
this->start_connecting(this->sta_[0], false);
} else {
this->start_scanning();
@ -591,6 +591,9 @@ void WiFiComponent::check_connecting_finished() {
return;
}
// We won't retry hidden networks unless a reconnect fails more than three times again
this->retry_hidden_ = false;
ESP_LOGI(TAG, "WiFi Connected!");
this->print_connect_params_();
@ -668,10 +671,11 @@ void WiFiComponent::retry_connect() {
this->wifi_mode_(false, {});
delay(100); // NOLINT
this->num_retried_ = 0;
this->retry_hidden_ = false;
} else {
// Try hidden networks after 3 failed retries
ESP_LOGD(TAG, "Retrying with hidden networks...");
this->fast_connect_ = true;
this->retry_hidden_ = true;
this->num_retried_++;
}
} else {

View file

@ -371,6 +371,7 @@ class WiFiComponent : public Component {
std::vector<WiFiSTAPriority> sta_priorities_;
WiFiAP selected_ap_;
bool fast_connect_{false};
bool retry_hidden_{false};
bool has_ap_{false};
WiFiAP ap_;