1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-19 00:05:43 +00:00
This commit is contained in:
J. Nick Koston
2025-11-06 11:17:17 -06:00
parent 378e591e70
commit 13ee597ce0
2 changed files with 12 additions and 12 deletions

View File

@@ -915,18 +915,15 @@ void WiFiComponent::save_fast_connect_settings_() {
bssid_t bssid = wifi_bssid();
uint8_t channel = get_wifi_channel();
// Check if we need to save (compare with current scan result if available)
bool should_save = true;
// Skip save if settings haven't changed (compare with current scan result if available)
if (this->selected_scan_index_ >= 0 && this->selected_scan_index_ < this->scan_result_.size()) {
const WiFiScanResult &scan = this->scan_result_[this->selected_scan_index_];
if (bssid == scan.get_bssid() && channel == scan.get_channel()) {
should_save = false;
return; // No change, nothing to save
}
}
if (should_save) {
SavedWifiFastConnectSettings fast_connect_save{};
memcpy(fast_connect_save.bssid, bssid.data(), 6);
fast_connect_save.channel = channel;
fast_connect_save.ap_index = this->selected_ap_index_ >= 0 ? this->selected_ap_index_ : 0;
@@ -934,7 +931,6 @@ void WiFiComponent::save_fast_connect_settings_() {
this->fast_connect_pref_.save(&fast_connect_save);
ESP_LOGD(TAG, "Saved fast_connect settings");
}
}
#endif

View File

@@ -426,7 +426,11 @@ class WiFiComponent : public Component {
WiFiComponentState state_{WIFI_COMPONENT_STATE_OFF};
WiFiPowerSaveMode power_save_{WIFI_POWER_SAVE_NONE};
uint8_t num_retried_{0};
// Index into sta_ array for the currently selected AP configuration (-1 = none selected)
// Used to access password, manual_ip, priority, EAP settings, and hidden flag
int8_t selected_ap_index_{-1};
// Index into scan_result_ array for the currently selected scan result (-1 = no scan data)
// Used to access scanned SSID, BSSID, and channel. Also used for fast connect (synthetic scan result)
int8_t selected_scan_index_{-1};
#if USE_NETWORK_IPV6
uint8_t num_ipv6_addresses_{0};