From f174661e81350cbba5e2845f3668e4e9de95ce7f Mon Sep 17 00:00:00 2001 From: FrogAi <91348155+FrogAi@users.noreply.github.com> Date: Wed, 27 Mar 2024 03:10:35 -0700 Subject: [PATCH] Retain tethering status between reboots --- common/params.cc | 1 + selfdrive/ui/qt/network/networking.cc | 6 ++++++ selfdrive/ui/ui.cc | 1 + selfdrive/ui/ui.h | 3 +++ 4 files changed, 11 insertions(+) diff --git a/common/params.cc b/common/params.cc index 213bbd96e..eeb1b1d48 100644 --- a/common/params.cc +++ b/common/params.cc @@ -372,6 +372,7 @@ std::unordered_map keys = { {"StandardJerk", PERSISTENT}, {"StockTune", PERSISTENT}, {"StoppingDistance", PERSISTENT}, + {"TetheringEnabled", PERSISTENT}, {"ToyotaDoors", PERSISTENT}, {"UnlimitedLength", PERSISTENT}, {"UnlockDoors", PERSISTENT}, diff --git a/selfdrive/ui/qt/network/networking.cc b/selfdrive/ui/qt/network/networking.cc index d7cdddff4..3f1a777dc 100644 --- a/selfdrive/ui/qt/network/networking.cc +++ b/selfdrive/ui/qt/network/networking.cc @@ -130,6 +130,10 @@ AdvancedNetworking::AdvancedNetworking(QWidget* parent, WifiManager* wifi): QWid tetheringToggle = new ToggleControl(tr("Enable Tethering"), "", "", wifi->isTetheringEnabled()); list->addItem(tetheringToggle); QObject::connect(tetheringToggle, &ToggleControl::toggleFlipped, this, &AdvancedNetworking::toggleTethering); + if (params.getBool("TetheringEnabled")) { + tetheringToggle->refresh(); + uiState()->scene.tethering_enabled = true; + } // Change tethering password ButtonControl *editPasswordButton = new ButtonControl(tr("Tethering Password"), tr("EDIT")); @@ -224,6 +228,8 @@ void AdvancedNetworking::refresh() { void AdvancedNetworking::toggleTethering(bool enabled) { wifi->setTetheringEnabled(enabled); tetheringToggle->setEnabled(false); + params.putBool("TetheringEnabled", enabled); + uiState()->scene.tethering_enabled = enabled; } // WifiUI functions diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index f9ccb7da1..4b749d9c9 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -389,6 +389,7 @@ void UIState::updateStatus() { started_prev = scene.started; scene.world_objects_visible = false; emit offroadTransition(!scene.started); + wifi->setTetheringEnabled(scene.started && scene.tethering_enabled); } } diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index 930d3e3ca..88bfbc92e 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -15,6 +15,7 @@ #include "common/mat.h" #include "common/params.h" #include "common/timing.h" +#include "selfdrive/ui/qt/network/wifi_manager.h" #include "system/hardware/hw.h" const int UI_BORDER_SIZE = 30; @@ -218,6 +219,7 @@ typedef struct UIScene { bool show_jerk; bool show_tuning; bool standstill; + bool tethering_enabled; bool turn_signal_left; bool turn_signal_right; bool unlimited_road_ui_length; @@ -287,6 +289,7 @@ public: QTransform car_space_transform; // FrogPilot variables + WifiManager *wifi = nullptr; signals: void uiUpdate(const UIState &s);