mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 11:47:30 +01:00
Improv: support connecting to hidden networks (#6322)
This commit is contained in:
parent
626221c5a8
commit
357ac3b85f
@ -293,7 +293,7 @@ void ESP32ImprovComponent::process_incoming_data_() {
|
|||||||
this->connecting_sta_ = sta;
|
this->connecting_sta_ = sta;
|
||||||
|
|
||||||
wifi::global_wifi_component->set_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);
|
this->set_state_(improv::STATE_PROVISIONING);
|
||||||
ESP_LOGD(TAG, "Received Improv wifi settings ssid=%s, password=" LOG_SECRET("%s"), command.ssid.c_str(),
|
ESP_LOGD(TAG, "Received Improv wifi settings ssid=%s, password=" LOG_SECRET("%s"), command.ssid.c_str(),
|
||||||
command.password.c_str());
|
command.password.c_str());
|
||||||
|
@ -196,7 +196,7 @@ bool ImprovSerialComponent::parse_improv_payload_(improv::ImprovCommand &command
|
|||||||
this->connecting_sta_ = sta;
|
this->connecting_sta_ = sta;
|
||||||
|
|
||||||
wifi::global_wifi_component->set_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);
|
this->set_state_(improv::STATE_PROVISIONING);
|
||||||
ESP_LOGD(TAG, "Received Improv wifi settings ssid=%s, password=" LOG_SECRET("%s"), command.ssid.c_str(),
|
ESP_LOGD(TAG, "Received Improv wifi settings ssid=%s, password=" LOG_SECRET("%s"), command.ssid.c_str(),
|
||||||
command.password.c_str());
|
command.password.c_str());
|
||||||
|
@ -661,12 +661,19 @@ void WiFiComponent::retry_connect() {
|
|||||||
|
|
||||||
delay(10);
|
delay(10);
|
||||||
if (!this->is_captive_portal_active_() && !this->is_esp32_improv_active_() &&
|
if (!this->is_captive_portal_active_() && !this->is_esp32_improv_active_() &&
|
||||||
(this->num_retried_ > 5 || this->error_from_callback_)) {
|
(this->num_retried_ > 3 || this->error_from_callback_)) {
|
||||||
// If retry failed for more than 5 times, let's restart STA
|
if (this->num_retried_ > 5) {
|
||||||
ESP_LOGW(TAG, "Restarting WiFi adapter...");
|
// If retry failed for more than 5 times, let's restart STA
|
||||||
this->wifi_mode_(false, {});
|
ESP_LOGW(TAG, "Restarting WiFi adapter...");
|
||||||
delay(100); // NOLINT
|
this->wifi_mode_(false, {});
|
||||||
this->num_retried_ = 0;
|
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 {
|
} else {
|
||||||
this->num_retried_++;
|
this->num_retried_++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user