mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 00:18:11 +01:00
wifi: fix reconnect issue due to enablement of fast connect (#6598)
This commit is contained in:
parent
16e0b78c64
commit
927caf062b
2 changed files with 7 additions and 2 deletions
|
@ -128,7 +128,7 @@ void WiFiComponent::loop() {
|
||||||
case WIFI_COMPONENT_STATE_COOLDOWN: {
|
case WIFI_COMPONENT_STATE_COOLDOWN: {
|
||||||
this->status_set_warning();
|
this->status_set_warning();
|
||||||
if (millis() - this->action_started_ > 5000) {
|
if (millis() - this->action_started_ > 5000) {
|
||||||
if (this->fast_connect_) {
|
if (this->fast_connect_ || this->retry_hidden_) {
|
||||||
this->start_connecting(this->sta_[0], false);
|
this->start_connecting(this->sta_[0], false);
|
||||||
} else {
|
} else {
|
||||||
this->start_scanning();
|
this->start_scanning();
|
||||||
|
@ -591,6 +591,9 @@ void WiFiComponent::check_connecting_finished() {
|
||||||
return;
|
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!");
|
ESP_LOGI(TAG, "WiFi Connected!");
|
||||||
this->print_connect_params_();
|
this->print_connect_params_();
|
||||||
|
|
||||||
|
@ -668,10 +671,11 @@ void WiFiComponent::retry_connect() {
|
||||||
this->wifi_mode_(false, {});
|
this->wifi_mode_(false, {});
|
||||||
delay(100); // NOLINT
|
delay(100); // NOLINT
|
||||||
this->num_retried_ = 0;
|
this->num_retried_ = 0;
|
||||||
|
this->retry_hidden_ = false;
|
||||||
} else {
|
} else {
|
||||||
// Try hidden networks after 3 failed retries
|
// Try hidden networks after 3 failed retries
|
||||||
ESP_LOGD(TAG, "Retrying with hidden networks...");
|
ESP_LOGD(TAG, "Retrying with hidden networks...");
|
||||||
this->fast_connect_ = true;
|
this->retry_hidden_ = true;
|
||||||
this->num_retried_++;
|
this->num_retried_++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -371,6 +371,7 @@ class WiFiComponent : public Component {
|
||||||
std::vector<WiFiSTAPriority> sta_priorities_;
|
std::vector<WiFiSTAPriority> sta_priorities_;
|
||||||
WiFiAP selected_ap_;
|
WiFiAP selected_ap_;
|
||||||
bool fast_connect_{false};
|
bool fast_connect_{false};
|
||||||
|
bool retry_hidden_{false};
|
||||||
|
|
||||||
bool has_ap_{false};
|
bool has_ap_{false};
|
||||||
WiFiAP ap_;
|
WiFiAP ap_;
|
||||||
|
|
Loading…
Reference in a new issue