move to wifiManager

pull/21750/head
ShaneSmiskol 4 years ago
parent 996654942e
commit 8985ab1fa3
  1. 12
      selfdrive/thermald/thermald.py
  2. 8
      selfdrive/ui/qt/offroad/networking.cc
  3. 2
      selfdrive/ui/qt/offroad/networking.h
  4. 18
      selfdrive/ui/qt/offroad/wifiManager.cc
  5. 1
      selfdrive/ui/qt/offroad/wifiManager.h

@ -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()))

@ -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() {

@ -61,6 +61,8 @@ private:
WifiUI* wifiWidget;
WifiManager* wifi = nullptr;
Params params;
protected:
void showEvent(QShowEvent* event) override;

@ -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<Connection>(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;

@ -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);

Loading…
Cancel
Save