mirror of
https://github.com/esphome/esphome.git
synced 2025-11-19 08:15:49 +00:00
preen
This commit is contained in:
@@ -112,7 +112,6 @@ void WiFiComponent::start() {
|
|||||||
this->trying_loaded_ap_ = this->load_fast_connect_settings_();
|
this->trying_loaded_ap_ = this->load_fast_connect_settings_();
|
||||||
if (!this->trying_loaded_ap_) {
|
if (!this->trying_loaded_ap_) {
|
||||||
// Fast connect failed - start from first configured AP without scan result
|
// Fast connect failed - start from first configured AP without scan result
|
||||||
this->ap_index_ = 0;
|
|
||||||
this->selected_ap_index_ = 0;
|
this->selected_ap_index_ = 0;
|
||||||
this->selected_scan_index_ = -1;
|
this->selected_scan_index_ = -1;
|
||||||
}
|
}
|
||||||
@@ -820,17 +819,16 @@ void WiFiComponent::retry_connect() {
|
|||||||
#ifdef USE_WIFI_FAST_CONNECT
|
#ifdef USE_WIFI_FAST_CONNECT
|
||||||
if (this->trying_loaded_ap_) {
|
if (this->trying_loaded_ap_) {
|
||||||
this->trying_loaded_ap_ = false;
|
this->trying_loaded_ap_ = false;
|
||||||
this->ap_index_ = 0; // Retry from the first configured AP
|
this->selected_ap_index_ = 0; // Retry from the first configured AP
|
||||||
} else if (this->ap_index_ >= this->sta_.size() - 1) {
|
} else if (this->selected_ap_index_ >= static_cast<int8_t>(this->sta_.size()) - 1) {
|
||||||
ESP_LOGW(TAG, "No more APs to try");
|
ESP_LOGW(TAG, "No more APs to try");
|
||||||
this->ap_index_ = 0;
|
this->selected_ap_index_ = 0;
|
||||||
this->restart_adapter();
|
this->restart_adapter();
|
||||||
} else {
|
} else {
|
||||||
// Try next AP
|
// Try next AP
|
||||||
this->ap_index_++;
|
this->selected_ap_index_++;
|
||||||
}
|
}
|
||||||
this->num_retried_ = 0;
|
this->num_retried_ = 0;
|
||||||
this->selected_ap_index_ = this->ap_index_;
|
|
||||||
this->selected_scan_index_ = -1;
|
this->selected_scan_index_ = -1;
|
||||||
#else
|
#else
|
||||||
if (this->num_retried_ > 5) {
|
if (this->num_retried_ > 5) {
|
||||||
@@ -903,8 +901,7 @@ bool WiFiComponent::load_fast_connect_settings_() {
|
|||||||
this->scan_result_.push_back(fast_connect_scan);
|
this->scan_result_.push_back(fast_connect_scan);
|
||||||
|
|
||||||
// Set indices to use the loaded AP config and temporary scan result
|
// Set indices to use the loaded AP config and temporary scan result
|
||||||
this->ap_index_ = fast_connect_save.ap_index;
|
this->selected_ap_index_ = fast_connect_save.ap_index;
|
||||||
this->selected_ap_index_ = this->ap_index_;
|
|
||||||
this->selected_scan_index_ = 0;
|
this->selected_scan_index_ = 0;
|
||||||
|
|
||||||
ESP_LOGD(TAG, "Loaded fast_connect settings");
|
ESP_LOGD(TAG, "Loaded fast_connect settings");
|
||||||
@@ -932,7 +929,7 @@ void WiFiComponent::save_fast_connect_settings_() {
|
|||||||
|
|
||||||
memcpy(fast_connect_save.bssid, bssid.data(), 6);
|
memcpy(fast_connect_save.bssid, bssid.data(), 6);
|
||||||
fast_connect_save.channel = channel;
|
fast_connect_save.channel = channel;
|
||||||
fast_connect_save.ap_index = this->ap_index_;
|
fast_connect_save.ap_index = this->selected_ap_index_ >= 0 ? this->selected_ap_index_ : 0;
|
||||||
|
|
||||||
this->fast_connect_pref_.save(&fast_connect_save);
|
this->fast_connect_pref_.save(&fast_connect_save);
|
||||||
|
|
||||||
|
|||||||
@@ -426,9 +426,6 @@ class WiFiComponent : public Component {
|
|||||||
WiFiComponentState state_{WIFI_COMPONENT_STATE_OFF};
|
WiFiComponentState state_{WIFI_COMPONENT_STATE_OFF};
|
||||||
WiFiPowerSaveMode power_save_{WIFI_POWER_SAVE_NONE};
|
WiFiPowerSaveMode power_save_{WIFI_POWER_SAVE_NONE};
|
||||||
uint8_t num_retried_{0};
|
uint8_t num_retried_{0};
|
||||||
#ifdef USE_WIFI_FAST_CONNECT
|
|
||||||
uint8_t ap_index_{0};
|
|
||||||
#endif
|
|
||||||
int8_t selected_ap_index_{-1};
|
int8_t selected_ap_index_{-1};
|
||||||
int8_t selected_scan_index_{-1};
|
int8_t selected_scan_index_{-1};
|
||||||
#if USE_NETWORK_IPV6
|
#if USE_NETWORK_IPV6
|
||||||
|
|||||||
Reference in New Issue
Block a user