mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	wifi: fix reconnect issue due to enablement of fast connect (#6598)
This commit is contained in:
		| @@ -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_; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user