From a9a4a7a7122f9220a5b95c2d95279815e6df2412 Mon Sep 17 00:00:00 2001 From: MoreTore Date: Sun, 1 Sep 2024 11:09:41 -0500 Subject: [PATCH] FrogPilot Server Toggle - Use richtext for FrogPilotConfirmationDialog::toggle --- common/params.cc | 3 +++ launch_chffrplus.sh | 1 + .../ui/qt/offroad/control_settings.cc | 26 ++++++++++++++++++- .../ui/qt/offroad/control_settings.h | 2 +- selfdrive/ui/qt/widgets/prime.cc | 3 +++ system/athena/registration.py | 16 ++++++++++++ system/manager/manager.py | 2 ++ 7 files changed, 51 insertions(+), 2 deletions(-) mode change 100644 => 100755 system/athena/registration.py diff --git a/common/params.cc b/common/params.cc index ee3a6f86e8efe04..c0f2d3586d7bd1e 100644 --- a/common/params.cc +++ b/common/params.cc @@ -116,6 +116,7 @@ std::unordered_map keys = { {"DisengageOnAccelerator", PERSISTENT | FROGPILOT_STORAGE}, {"DmModelInitialized", CLEAR_ON_ONROAD_TRANSITION}, {"DongleId", PERSISTENT}, + {"DongleIdPrev", PERSISTENT | FROGPILOT_STORAGE}, {"DoReboot", CLEAR_ON_MANAGER_START}, {"DoShutdown", CLEAR_ON_MANAGER_START}, {"DoUninstall", CLEAR_ON_MANAGER_START}, @@ -331,6 +332,7 @@ std::unordered_map keys = { {"ForceStandstill", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"ForceStops", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, {"FPSCounter", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, + {"FrogId", PERSISTENT | FROGPILOT_STORAGE}, {"FrogPilotDrives", PERSISTENT | FROGPILOT_TRACKING}, {"FrogPilotKilometers", PERSISTENT | FROGPILOT_TRACKING}, {"FrogPilotMinutes", PERSISTENT | FROGPILOT_TRACKING}, @@ -547,6 +549,7 @@ std::unordered_map keys = { {"Updated", PERSISTENT}, {"UpdateTheme", PERSISTENT}, {"UpdateWheelImage", PERSISTENT}, + {"UseFrogServer", PERSISTENT | FROGPILOT_STORAGE}, {"UseSI", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS}, {"UseStockColors", CLEAR_ON_MANAGER_START}, {"UseVienna", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS}, diff --git a/launch_chffrplus.sh b/launch_chffrplus.sh index 9256f463af7e17e..f79b7426a1fd8dc 100755 --- a/launch_chffrplus.sh +++ b/launch_chffrplus.sh @@ -7,6 +7,7 @@ fi source "$BASEDIR/launch_env.sh" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" +PARAMS=/data/params/d function agnos_init { # TODO: move this to agnos diff --git a/selfdrive/frogpilot/ui/qt/offroad/control_settings.cc b/selfdrive/frogpilot/ui/qt/offroad/control_settings.cc index 27d5ddb98eec4ef..3af51d6ca637402 100644 --- a/selfdrive/frogpilot/ui/qt/offroad/control_settings.cc +++ b/selfdrive/frogpilot/ui/qt/offroad/control_settings.cc @@ -47,7 +47,8 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil {"DeviceManagement", tr("Device Management"), tr("Tweak your device's behaviors to your personal preferences."), "../frogpilot/assets/toggle_icons/icon_device.png"}, {"DeviceShutdown", tr("Device Shutdown Timer"), tr("Configure how quickly the device shuts down after going offroad."), ""}, {"NoLogging", tr("Disable Logging"), tr("Turn off all data tracking to enhance privacy or reduce thermal load."), ""}, - {"NoUploads", tr("Disable Uploads"), tr("Turn off all data uploads to comma's servers."), ""}, + {"NoUploads", tr("Disable Uploads"), tr("Turn off all data uploads to servers."), ""}, + {"UseFrogServer", tr("Switch to FrogPilot Server"), tr("Use the Frogpilot connect instead of Comma connect"), ""}, {"IncreaseThermalLimits", tr("Increase Thermal Safety Limit"), tr("Allow the device to run at a temperature above comma's recommended thermal limits."), ""}, {"LowVoltageShutdown", tr("Low Voltage Shutdown Threshold"), tr("Automatically shut the device down when your battery reaches a specific voltage level to prevent killing your battery."), ""}, {"OfflineMode", tr("Offline Mode"), tr("Allow the device to be offline indefinitely."), ""}, @@ -1138,6 +1139,29 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil } }); + QObject::connect(static_cast(toggles["UseFrogServer"]), &ToggleControl::toggleFlipped, [this](bool state) { + const QString enable_promt_text = tr("By keeping this toggle enabled, you agree to the following: " + "We collect, use, and share information from and about you and your vehicle in connection with OpenPilot or variations thereof. " + "This information may be accessed by third parties without additional notice or consent, for purposes including, but not limited to, " + "providing OpenPilot services, data collection, software updates, safety and cybersecurity measures, and the suspension or removal of your account. " + "Further details are outlined in our Privacy Policy (available at https://frogpilot.wiki.gg/wiki/privacy)."); + if (state) { + if (ConfirmationDialog(enable_promt_text, tr("I agree"), tr("I do not agree"), true, this).exec()) { + if (ConfirmationDialog(tr("Make sure you are connected to the internet before rebooting!"), tr("Reboot now"), tr("Reboot later"), false, this).exec()) { + Hardware::reboot(); + } + } else { + params.putBool("UseFrogServer", false); + } + } else { + if (ConfirmationDialog(tr("Are you sure you want to connect to commas servers?"), tr("Yes and reboot"), tr("Use FrogPilot server"), false, this)) { + Hardware::reboot(); + } else { + params.putBool("UseFrogServer", true); + } + } + }); + std::set rebootKeys = {"AlwaysOnLateral", "NNFF", "NNFFLite"}; for (const QString &key : rebootKeys) { QObject::connect(static_cast(toggles[key.toStdString().c_str()]), &ToggleControl::toggleFlipped, [this, key](bool state) { diff --git a/selfdrive/frogpilot/ui/qt/offroad/control_settings.h b/selfdrive/frogpilot/ui/qt/offroad/control_settings.h index 65dadcc4ee06dd3..d501bcd3c093f98 100644 --- a/selfdrive/frogpilot/ui/qt/offroad/control_settings.h +++ b/selfdrive/frogpilot/ui/qt/offroad/control_settings.h @@ -45,7 +45,7 @@ class FrogPilotControlsPanel : public FrogPilotListWidget { std::set aolKeys = {"AlwaysOnLateralLKAS", "AlwaysOnLateralMain", "HideAOLStatusBar", "PauseAOLOnBrake"}; std::set conditionalExperimentalKeys = {"CESpeed", "CESpeedLead", "CECurves", "CELead", "CEModelStopTime", "CENavigation", "CESignal", "HideCEMStatusBar"}; std::set customdrivingPersonalityKeys = {"AggressivePersonalityProfile", "RelaxedPersonalityProfile", "StandardPersonalityProfile", "TrafficPersonalityProfile"}; - std::set deviceManagementKeys = {"DeviceShutdown", "IncreaseThermalLimits", "LowVoltageShutdown", "NoLogging", "NoUploads", "OfflineMode"}; + std::set deviceManagementKeys = {"DeviceShutdown", "IncreaseThermalLimits", "LowVoltageShutdown", "NoLogging", "NoUploads", "UseFrogServer", "OfflineMode"}; std::set drivingPersonalityKeys = {"CustomPersonalities", "OnroadDistanceButton", "OnroadDistanceButtonButtons", "DownloadStatusLabel"}; std::set experimentalModeActivationKeys = {"ExperimentalModeViaDistance", "ExperimentalModeViaLKAS", "ExperimentalModeViaTap"}; std::set laneChangeKeys = {"LaneChangeTime", "LaneDetectionWidth", "MinimumLaneChangeSpeed", "NudgelessLaneChange", "OneLaneChange"}; diff --git a/selfdrive/ui/qt/widgets/prime.cc b/selfdrive/ui/qt/widgets/prime.cc index 2621612f67f4320..cab2e6f12e54aa0 100644 --- a/selfdrive/ui/qt/widgets/prime.cc +++ b/selfdrive/ui/qt/widgets/prime.cc @@ -37,6 +37,9 @@ void PairingQRWidget::hideEvent(QHideEvent *event) { void PairingQRWidget::refresh() { QString pairToken = CommaApi::create_jwt({{"pair", true}}); QString qrString = "https://connect.comma.ai/?pair=" + pairToken; + if (getenv("API_HOST") != nullptr) { + qrString = "https://portal.springerelectronics.com/?pair=" + pairToken; + } this->updateQrCode(qrString); update(); } diff --git a/system/athena/registration.py b/system/athena/registration.py old mode 100644 new mode 100755 index 5710c3c07823fee..9f04f6fead66b25 --- a/system/athena/registration.py +++ b/system/athena/registration.py @@ -27,6 +27,20 @@ def is_registered_device() -> bool: def register(show_spinner=False) -> str | None: params = Params() + if params.get("UseFrogServer"): + os.environ["API_HOST"] = "https://api.springerelectronics.com" + os.environ["ATHENA_HOST"] = "wss://athena.springerelectronics.com" + print("\033[0;36mUsing FrogServer\033[0m") + if params.get("DongleId") != params.get("FrogId"): + params.put("DongleIdPrev", params.get("DongleId")) + if params.get("FrogId") != "": + params.put("DongleId", params.get("FrogId")) + else: + params.remove("DongleId") + + elif params.get("DongleIdPrev"): + params.put("DongleId", params.get("DongleIdPrev")) + IMEI = params.get("IMEI", encoding='utf8') HardwareSerial = params.get("HardwareSerial", encoding='utf8') dongle_id: str | None = params.get("DongleId", encoding='utf8') @@ -95,6 +109,8 @@ def register(show_spinner=False) -> str | None: if dongle_id: params.put("DongleId", dongle_id) + if params.get_bool("UseFrogServer"): + params.put("FrogId", dongle_id) set_offroad_alert("Offroad_UnofficialHardware", (dongle_id == UNREGISTERED_DONGLE_ID) and not PC) return dongle_id diff --git a/system/manager/manager.py b/system/manager/manager.py index cfddaa2f44da98e..3caf1ea0acb7822 100755 --- a/system/manager/manager.py +++ b/system/manager/manager.py @@ -163,6 +163,7 @@ def manager_init() -> None: ("ForceStandstill", "0"), ("ForceStops", "0"), ("FPSCounter", "1"), + ("FrogId", ""), ("FrogsGoMooTune", "1"), ("FullMap", "0"), ("GasRegenCmd", "1"), @@ -346,6 +347,7 @@ def manager_init() -> None: ("TurnDesires", "0"), ("UnlimitedLength", "1"), ("UnlockDoors", "1"), + ("UseFrogServer", "0"), ("UseSI", "1"), ("UseVienna", "0"), ("VisionTurnControl", "1"),