diff --git a/selfdrive/thermald/thermald.py b/selfdrive/thermald/thermald.py index 928a338092..bcd3f18883 100755 --- a/selfdrive/thermald/thermald.py +++ b/selfdrive/thermald/thermald.py @@ -165,7 +165,6 @@ def thermald_thread(): handle_fan = None is_uno = False ui_running_prev = False - last_gsm_roaming = None params = Params() power_monitor = PowerMonitoring() @@ -258,17 +257,6 @@ def thermald_thread(): except Exception: cloudlog.exception("Error getting network status") - if TICI: - try: - gsm_roaming = params.get_bool("GsmRoaming") - if gsm_roaming != last_gsm_roaming: - last_gsm_roaming = gsm_roaming - home_only = "no" if gsm_roaming else "yes" - os.system(f"nmcli connection modify --temporary lte gsm.home-only {home_only}") - - except Exception: - cloudlog.exception("Error setting roaming") - msg.deviceState.freeSpacePercent = get_available_percent(default=100.0) msg.deviceState.memoryUsagePercent = int(round(psutil.virtual_memory().percent)) msg.deviceState.cpuUsagePercent = int(round(psutil.cpu_percent())) diff --git a/selfdrive/ui/qt/offroad/networking.cc b/selfdrive/ui/qt/offroad/networking.cc index 75304d7ae2..4fc031f5f7 100644 --- a/selfdrive/ui/qt/offroad/networking.cc +++ b/selfdrive/ui/qt/offroad/networking.cc @@ -67,6 +67,14 @@ Networking::Networking(QWidget* parent, bool show_advanced) : QFrame(parent) { } )"); main_layout->setCurrentWidget(wifiScreen); + + QTimer* timer = new QTimer(this); + QObject::connect(timer, &QTimer::timeout, this, [=]() { + bool roaming = params.getBool("GsmRoaming"); + qDebug() << "Setting roaming:" << roaming; + wifi->setRoaming(roaming); + }); + timer->start(5000); } void Networking::refresh() { diff --git a/selfdrive/ui/qt/offroad/networking.h b/selfdrive/ui/qt/offroad/networking.h index 02fd2d372f..b6d1768473 100644 --- a/selfdrive/ui/qt/offroad/networking.h +++ b/selfdrive/ui/qt/offroad/networking.h @@ -61,6 +61,8 @@ private: WifiUI* wifiWidget; WifiManager* wifi = nullptr; + Params params; + protected: void showEvent(QShowEvent* event) override; diff --git a/selfdrive/ui/qt/offroad/wifiManager.cc b/selfdrive/ui/qt/offroad/wifiManager.cc index ec0bc1f654..3d2e040a6b 100644 --- a/selfdrive/ui/qt/offroad/wifiManager.cc +++ b/selfdrive/ui/qt/offroad/wifiManager.cc @@ -418,6 +418,24 @@ NetworkType WifiManager::currentNetworkType() { return NetworkType::NONE; } +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); + 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"; + } +} + // Functions for tethering void WifiManager::addTetheringConnection() { Connection connection; diff --git a/selfdrive/ui/qt/offroad/wifiManager.h b/selfdrive/ui/qt/offroad/wifiManager.h index e0ee86f109..71c36036f7 100644 --- a/selfdrive/ui/qt/offroad/wifiManager.h +++ b/selfdrive/ui/qt/offroad/wifiManager.h @@ -49,6 +49,7 @@ public: bool isKnownConnection(const QString &ssid); void activateWifiConnection(const QString &ssid); NetworkType currentNetworkType(); + void setRoaming(bool roaming); void connect(const Network &ssid); void connect(const Network &ssid, const QString &password);