From b8b1e17a21390d9a80b1b0643c0001129292576c Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Fri, 18 Aug 2023 05:43:40 +0800 Subject: [PATCH] ui/networking: do not skip the connected network (#29396) * do not skip connected network * simplify * revert * revert * no implicit * ifwt * fix missing ssid * makes more sense to only update security_type once (first vs. last) * better comment --------- Co-authored-by: Shane Smiskol --- selfdrive/ui/qt/offroad/wifiManager.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/selfdrive/ui/qt/offroad/wifiManager.cc b/selfdrive/ui/qt/offroad/wifiManager.cc index e23313970..391cc9fb5 100644 --- a/selfdrive/ui/qt/offroad/wifiManager.cc +++ b/selfdrive/ui/qt/offroad/wifiManager.cc @@ -99,15 +99,22 @@ void WifiManager::refreshFinished(QDBusPendingCallWatcher *watcher) { auto properties = replay.value(); const QByteArray ssid = properties["Ssid"].toByteArray(); - uint32_t strength = properties["Strength"].toUInt(); - if (ssid.isEmpty() || (seenNetworks.contains(ssid) && strength <= seenNetworks[ssid].strength)) continue; + if (ssid.isEmpty()) continue; + + // May be multiple access points for each SSID. + // Use first for ssid and security type, then update connected status and strength using all + if (!seenNetworks.contains(ssid)) { + seenNetworks[ssid] = {ssid, 0U, ConnectedType::DISCONNECTED, getSecurityType(properties)}; + } - SecurityType security = getSecurityType(properties); - ConnectedType ctype = ConnectedType::DISCONNECTED; if (path.path() == activeAp) { - ctype = (ssid == connecting_to_network) ? ConnectedType::CONNECTING : ConnectedType::CONNECTED; + seenNetworks[ssid].connected = (ssid == connecting_to_network) ? ConnectedType::CONNECTING : ConnectedType::CONNECTED; + } + + uint32_t strength = properties["Strength"].toUInt(); + if (seenNetworks[ssid].strength < strength) { + seenNetworks[ssid].strength = strength; } - seenNetworks[ssid] = {ssid, strength, ctype, security}; } emit refreshSignal();