From 81fbf42cd10a72780eb1098f317eb6235629a451 Mon Sep 17 00:00:00 2001 From: James <91348155+FrogAi@users.noreply.github.com> Date: Mon, 1 Dec 2025 12:00:00 -0700 Subject: [PATCH] Retain network tethering --- frogpilot/ui/frogpilot_ui.cc | 4 ++++ selfdrive/ui/qt/network/networking.cc | 17 ++++++++++++----- selfdrive/ui/qt/network/networking.h | 5 +++-- selfdrive/ui/ui.cc | 3 +++ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/frogpilot/ui/frogpilot_ui.cc b/frogpilot/ui/frogpilot_ui.cc index dc63586e8..4983416df 100644 --- a/frogpilot/ui/frogpilot_ui.cc +++ b/frogpilot/ui/frogpilot_ui.cc @@ -41,6 +41,10 @@ FrogPilotUIState::FrogPilotUIState(QObject *parent) : QObject(parent) { }); wifi = new WifiManager(this); + + if (params.getInt("TetheringEnabled") == 1) { + wifi->setTetheringEnabled(true); + } } FrogPilotUIState *frogpilotUIState() { diff --git a/selfdrive/ui/qt/network/networking.cc b/selfdrive/ui/qt/network/networking.cc index f19786a46..55895bb26 100644 --- a/selfdrive/ui/qt/network/networking.cc +++ b/selfdrive/ui/qt/network/networking.cc @@ -131,9 +131,16 @@ AdvancedNetworking::AdvancedNetworking(QWidget* parent, WifiManager* wifi): QWid ListWidget *list = new ListWidget(this); // Enable tethering layout - tetheringToggle = new ToggleControl(tr("Enable Tethering"), "", "", wifi->isTetheringEnabled()); + std::vector tetheringSelection{tr("Off"), tr("Always"), tr("Only Onroad"), tr("Until Reboot")}; + tetheringToggle = new ButtonParamControl("TetheringEnabled", tr("Enable Tethering"), + tr("Share your device's internet connection with other devices, either all the time or only while driving."), + "", tetheringSelection); + if (params.getInt("TetheringEnabled") == 3) { + params.remove("TetheringEnabled"); + tetheringToggle->setCheckedButton(0); + } list->addItem(tetheringToggle); - QObject::connect(tetheringToggle, &ToggleControl::toggleFlipped, this, &AdvancedNetworking::toggleTethering); + QObject::connect(tetheringToggle, &MultiButtonControl::buttonClicked, this, &AdvancedNetworking::toggleTethering); // Change tethering password ButtonControl *editPasswordButton = new ButtonControl(tr("Tethering Password"), tr("EDIT")); @@ -252,10 +259,10 @@ void AdvancedNetworking::refresh() { update(); } -void AdvancedNetworking::toggleTethering(bool enabled) { - wifi->setTetheringEnabled(enabled); +void AdvancedNetworking::toggleTethering(int id) { + wifi->setTetheringEnabled(id == 1 || id == 2 && uiState()->scene.started || id == 3); tetheringToggle->setEnabled(false); - if (enabled) { + if (id != 0) { wifiMeteredToggle->setEnabled(false); wifiMeteredToggle->setCheckedButton(0); } diff --git a/selfdrive/ui/qt/network/networking.h b/selfdrive/ui/qt/network/networking.h index 0bdf64e45..e66e431cf 100644 --- a/selfdrive/ui/qt/network/networking.h +++ b/selfdrive/ui/qt/network/networking.h @@ -7,6 +7,7 @@ #include "selfdrive/ui/qt/widgets/input.h" #include "selfdrive/ui/qt/widgets/ssh_keys.h" #include "selfdrive/ui/qt/widgets/toggle.h" +#include "selfdrive/ui/ui.h" class WifiItem : public QWidget { Q_OBJECT @@ -61,7 +62,7 @@ public: private: LabelControl* ipLabel; - ToggleControl* tetheringToggle; + ButtonParamControl* tetheringToggle; ToggleControl* roamingToggle; ButtonControl* editApnButton; ButtonControl* hiddenNetworkButton; @@ -75,7 +76,7 @@ signals: void requestWifiScreen(); public slots: - void toggleTethering(bool enabled); + void toggleTethering(int id); void refresh(); }; diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 2d3b9b4b5..f98d7fc83 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -123,6 +123,9 @@ void UIState::updateStatus(FrogPilotUIState *fs) { emit offroadTransition(!scene.started); // FrogPilot variables + if (frogpilot_toggles.value("tethering_config").toInt() == 2) { + fs->wifi->setTetheringEnabled(scene.started); + } } }