ESPHome 2026.9.0-dev
Loading...
Searching...
No Matches
scan_list.h
Go to the documentation of this file.
1#pragma once
2#include <cstdint>
3
4namespace esphome::wifi {
5
6// A scan lists every BSSID, so one SSID can appear several times. Returns true for
7// the strongest entry per SSID (earliest on ties), never for hidden entries. scan
8// must be an element of results. with_auth is written only when returning true and
9// is set if any entry with that SSID needs a key. Templated for host tests.
10template<typename Results, typename Entry>
11bool should_show_scan_entry(const Results &results, const Entry &scan, bool &with_auth) {
12 if (scan.get_is_hidden())
13 return false;
14 const int8_t rssi = scan.get_rssi();
15 bool any_auth = false;
16 for (const auto &other : results) {
17 if (other.get_is_hidden() || !other.ssid_equals(scan))
18 continue;
19 // Same array, so address order is index order. scan fails both checks against itself.
20 if (other.get_rssi() > rssi || (other.get_rssi() == rssi && &other < &scan))
21 return false;
22 any_auth |= other.get_with_auth();
23 }
24 with_auth = any_auth;
25 return true;
26}
27
28} // namespace esphome::wifi
bool should_show_scan_entry(const Results &results, const Entry &scan, bool &with_auth)
Definition scan_list.h:11