From 3b8c65f133faf86f4e46e67c7ad1f2e92f0dcd24 Mon Sep 17 00:00:00 2001 From: ShaneSmiskol Date: Tue, 27 Jul 2021 15:50:46 -0700 Subject: [PATCH] should be working --- selfdrive/ui/qt/offroad/wifiManager.cc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/selfdrive/ui/qt/offroad/wifiManager.cc b/selfdrive/ui/qt/offroad/wifiManager.cc index 3d2e040a6b..bbff1f310d 100644 --- a/selfdrive/ui/qt/offroad/wifiManager.cc +++ b/selfdrive/ui/qt/offroad/wifiManager.cc @@ -368,7 +368,11 @@ QString WifiManager::getConnectionSsid(const QDBusObjectPath &path) { QDBusInterface nm(NM_DBUS_SERVICE, path.path(), NM_DBUS_INTERFACE_SETTINGS_CONNECTION, bus); nm.setTimeout(DBUS_TIMEOUT); const QDBusReply result = nm.call("GetSettings"); - return result.value().value("802-11-wireless").value("ssid").toString(); + const QString &ssid = result.value().value("802-11-wireless").value("ssid").toString(); + if (!ssid.isEmpty()) { + return ssid; + } + return result.value().value("connection").value("id").toString(); } void WifiManager::initConnections() { @@ -421,18 +425,15 @@ NetworkType WifiManager::currentNetworkType() { void WifiManager::setRoaming(bool roaming) { const QDBusObjectPath &path = getConnectionPath("lte"); if (!path.path().isEmpty()) { - ElapsedTimer timer; - timer.start(); - QDBusInterface nm(NM_DBUS_INTERFACE, path.path(), NM_DBUS_INTERFACE_SETTINGS_CONNECTION, bus); + QDBusInterface nm(NM_DBUS_SERVICE, path.path(), NM_DBUS_INTERFACE_SETTINGS_CONNECTION, bus); nm.setTimeout(DBUS_TIMEOUT); Connection settings = QDBusReply(nm.call("GetSettings")).value(); - qDebug() << "Getting settings took:" << timer.nsecsElapsed() / 1e6 << "ms"; - qDebug() << "home only:" << settings["gsm"]["home-only"]; - timer.start(); - settings["gsm"]["home-only"] = roaming ? "no" : "yes"; - nm.call("Update", QVariant::fromValue(settings)); - qDebug() << "Saving settings took:" << timer.nsecsElapsed() / 1e6 << "ms"; + bool prevRoaming = !settings.value("gsm").value("home-only").toBool(); + if (!settings.value("gsm").contains("home-only") || prevRoaming != roaming) { + settings["gsm"]["home-only"] = roaming ? "no" : "yes"; + nm.call("Update", QVariant::fromValue(settings)); + } } }