mirror of
https://github.com/esphome/esphome.git
synced 2025-11-19 08:15:49 +00:00
preen
This commit is contained in:
@@ -915,26 +915,22 @@ void WiFiComponent::save_fast_connect_settings_() {
|
|||||||
bssid_t bssid = wifi_bssid();
|
bssid_t bssid = wifi_bssid();
|
||||||
uint8_t channel = get_wifi_channel();
|
uint8_t channel = get_wifi_channel();
|
||||||
|
|
||||||
// Check if we need to save (compare with current scan result if available)
|
// Skip save if settings haven't changed (compare with current scan result if available)
|
||||||
bool should_save = true;
|
|
||||||
if (this->selected_scan_index_ >= 0 && this->selected_scan_index_ < this->scan_result_.size()) {
|
if (this->selected_scan_index_ >= 0 && this->selected_scan_index_ < this->scan_result_.size()) {
|
||||||
const WiFiScanResult &scan = this->scan_result_[this->selected_scan_index_];
|
const WiFiScanResult &scan = this->scan_result_[this->selected_scan_index_];
|
||||||
if (bssid == scan.get_bssid() && channel == scan.get_channel()) {
|
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{};
|
||||||
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;
|
||||||
|
|
||||||
memcpy(fast_connect_save.bssid, bssid.data(), 6);
|
this->fast_connect_pref_.save(&fast_connect_save);
|
||||||
fast_connect_save.channel = channel;
|
|
||||||
fast_connect_save.ap_index = this->selected_ap_index_ >= 0 ? this->selected_ap_index_ : 0;
|
|
||||||
|
|
||||||
this->fast_connect_pref_.save(&fast_connect_save);
|
ESP_LOGD(TAG, "Saved fast_connect settings");
|
||||||
|
|
||||||
ESP_LOGD(TAG, "Saved fast_connect settings");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -426,7 +426,11 @@ 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};
|
||||||
|
// 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};
|
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};
|
int8_t selected_scan_index_{-1};
|
||||||
#if USE_NETWORK_IPV6
|
#if USE_NETWORK_IPV6
|
||||||
uint8_t num_ipv6_addresses_{0};
|
uint8_t num_ipv6_addresses_{0};
|
||||||
|
|||||||
Reference in New Issue
Block a user