mirror of
https://github.com/esphome/esphome.git
synced 2025-11-16 23:05:46 +00:00
dry
This commit is contained in:
@@ -348,15 +348,12 @@ void WiFiComponent::clear_sta() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
WiFiAP WiFiComponent::build_wifi_ap_from_selected_() const {
|
WiFiAP WiFiComponent::build_wifi_ap_from_selected_() const {
|
||||||
const WiFiAP *config = this->get_selected_sta_();
|
WiFiAP params = this->get_sta();
|
||||||
if (!config) {
|
if (params.get_ssid().empty()) {
|
||||||
ESP_LOGE(TAG, "No config selected");
|
ESP_LOGE(TAG, "No config selected");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start with a copy of the entire config
|
|
||||||
WiFiAP params = *config;
|
|
||||||
|
|
||||||
// SYNCHRONIZATION: selected_sta_index_ and scan_result_[0] are kept in sync:
|
// SYNCHRONIZATION: selected_sta_index_ and scan_result_[0] are kept in sync:
|
||||||
// - wifi_scan_done() sorts all scan results by priority/RSSI (best first)
|
// - wifi_scan_done() sorts all scan results by priority/RSSI (best first)
|
||||||
// - It then finds which sta_[i] config matches scan_result_[0]
|
// - It then finds which sta_[i] config matches scan_result_[0]
|
||||||
@@ -369,7 +366,7 @@ WiFiAP WiFiComponent::build_wifi_ap_from_selected_() const {
|
|||||||
params.set_ssid(scan.get_ssid());
|
params.set_ssid(scan.get_ssid());
|
||||||
params.set_bssid(scan.get_bssid());
|
params.set_bssid(scan.get_bssid());
|
||||||
params.set_channel(scan.get_channel());
|
params.set_channel(scan.get_channel());
|
||||||
} else if (config->get_hidden()) {
|
} else if (params.get_hidden()) {
|
||||||
// Hidden network - clear BSSID and channel even if set in config
|
// Hidden network - clear BSSID and channel even if set in config
|
||||||
// There might be multiple hidden networks with same SSID but we can't know which is correct
|
// There might be multiple hidden networks with same SSID but we can't know which is correct
|
||||||
// Rely on probe-req with just SSID. Empty channel triggers ALL_CHANNEL_SCAN.
|
// Rely on probe-req with just SSID. Empty channel triggers ALL_CHANNEL_SCAN.
|
||||||
|
|||||||
Reference in New Issue
Block a user