mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 13:34:54 +01:00
Improv: support connecting to hidden networks (#6322)
This commit is contained in:
parent
626221c5a8
commit
357ac3b85f
3 changed files with 15 additions and 8 deletions
|
@ -293,7 +293,7 @@ void ESP32ImprovComponent::process_incoming_data_() {
|
|||
this->connecting_sta_ = sta;
|
||||
|
||||
wifi::global_wifi_component->set_sta(sta);
|
||||
wifi::global_wifi_component->start_scanning();
|
||||
wifi::global_wifi_component->start_connecting(sta, false);
|
||||
this->set_state_(improv::STATE_PROVISIONING);
|
||||
ESP_LOGD(TAG, "Received Improv wifi settings ssid=%s, password=" LOG_SECRET("%s"), command.ssid.c_str(),
|
||||
command.password.c_str());
|
||||
|
|
|
@ -196,7 +196,7 @@ bool ImprovSerialComponent::parse_improv_payload_(improv::ImprovCommand &command
|
|||
this->connecting_sta_ = sta;
|
||||
|
||||
wifi::global_wifi_component->set_sta(sta);
|
||||
wifi::global_wifi_component->start_scanning();
|
||||
wifi::global_wifi_component->start_connecting(sta, false);
|
||||
this->set_state_(improv::STATE_PROVISIONING);
|
||||
ESP_LOGD(TAG, "Received Improv wifi settings ssid=%s, password=" LOG_SECRET("%s"), command.ssid.c_str(),
|
||||
command.password.c_str());
|
||||
|
|
|
@ -661,12 +661,19 @@ void WiFiComponent::retry_connect() {
|
|||
|
||||
delay(10);
|
||||
if (!this->is_captive_portal_active_() && !this->is_esp32_improv_active_() &&
|
||||
(this->num_retried_ > 5 || this->error_from_callback_)) {
|
||||
// If retry failed for more than 5 times, let's restart STA
|
||||
ESP_LOGW(TAG, "Restarting WiFi adapter...");
|
||||
this->wifi_mode_(false, {});
|
||||
delay(100); // NOLINT
|
||||
this->num_retried_ = 0;
|
||||
(this->num_retried_ > 3 || this->error_from_callback_)) {
|
||||
if (this->num_retried_ > 5) {
|
||||
// If retry failed for more than 5 times, let's restart STA
|
||||
ESP_LOGW(TAG, "Restarting WiFi adapter...");
|
||||
this->wifi_mode_(false, {});
|
||||
delay(100); // NOLINT
|
||||
this->num_retried_ = 0;
|
||||
} else {
|
||||
// Try hidden networks after 3 failed retries
|
||||
ESP_LOGD(TAG, "Retrying with hidden networks...");
|
||||
this->fast_connect_ = true;
|
||||
this->num_retried_++;
|
||||
}
|
||||
} else {
|
||||
this->num_retried_++;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue