From f627a34e47d22d3cc58139a24156ddc2f6fcb9d3 Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Sat, 3 Jun 2023 00:17:13 -0400 Subject: [PATCH] Retain hotspot/tethering state across reboots (#89) * Retain tethering state across reboots * store state * Update CHANGELOGS.md * Add toggle to "SP - General" * Network icon --- CHANGELOGS.md | 1 + selfdrive/manager/manager.py | 3 +++ selfdrive/ui/qt/offroad/networking.cc | 1 + selfdrive/ui/qt/offroad/sunnypilot_settings.cc | 9 +++++++++ 4 files changed, 14 insertions(+) diff --git a/CHANGELOGS.md b/CHANGELOGS.md index 4b5160f2cf..302f9bb582 100644 --- a/CHANGELOGS.md +++ b/CHANGELOGS.md @@ -2,6 +2,7 @@ sunnypilot - 0.9.2.x (2023-02-22) ======================== * Dashcam Viewer (native & screen recordings) via Browser support thanks to actuallylemoncurd, AlexandreSato, ntegan1, and royjr! * Honda Clarity 2018-22 support thanks to mcallbosco, vanillagorillaa and wirelessnet2! +* Retain hotspot/tethering state across reboots thanks to rogerioaguas! sunnypilot - Version Latest (2023-02-22) ======================== diff --git a/selfdrive/manager/manager.py b/selfdrive/manager/manager.py index 219ef50875..99eaf38d5a 100755 --- a/selfdrive/manager/manager.py +++ b/selfdrive/manager/manager.py @@ -167,6 +167,9 @@ def manager_init() -> None: if os.path.isfile(f'{CRASHES_DIR}/error.txt'): os.remove(f'{CRASHES_DIR}/error.txt') + if params.get_bool("HotspotOnBoot"): + os.system('nmcli con up Hotspot') + def manager_prepare() -> None: for p in managed_processes.values(): diff --git a/selfdrive/ui/qt/offroad/networking.cc b/selfdrive/ui/qt/offroad/networking.cc index d69d67edeb..3f2d9fae8a 100644 --- a/selfdrive/ui/qt/offroad/networking.cc +++ b/selfdrive/ui/qt/offroad/networking.cc @@ -204,6 +204,7 @@ void AdvancedNetworking::refresh() { } void AdvancedNetworking::toggleTethering(bool enabled) { + params.putBool("HotspotOnBoot", enabled); wifi->setTetheringEnabled(enabled); tetheringToggle->setEnabled(false); } diff --git a/selfdrive/ui/qt/offroad/sunnypilot_settings.cc b/selfdrive/ui/qt/offroad/sunnypilot_settings.cc index 41e99010c4..3f2e52a156 100644 --- a/selfdrive/ui/qt/offroad/sunnypilot_settings.cc +++ b/selfdrive/ui/qt/offroad/sunnypilot_settings.cc @@ -52,6 +52,15 @@ SPGeneralPanel::SPGeneralPanel(QWidget *parent) : QWidget(parent) { "../assets/offroad/icon_road.png" )); + // General: Retain hotspot/tethering state + main_layout->addWidget(horizontal_line()); + main_layout->addWidget(new ParamControl( + "HotspotOnBoot", + tr("Retain hotspot/tethering state"), + tr("Enabling this toggle will retain the hotspot/tethering toggle state across reboots."), + "../assets/offroad/icon_network.png" + )); + // General: Max Time Offroad (Shutdown timer) main_layout->addWidget(horizontal_line()); main_layout->addWidget(new MaxTimeOffroad());