Skip to content

Commit

Permalink
FrogPilot Server Toggle
Browse files Browse the repository at this point in the history
- Use richtext for FrogPilotConfirmationDialog::toggle
  • Loading branch information
MoreTore committed Sep 1, 2024
1 parent 42e0a40 commit a9a4a7a
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 2 deletions.
3 changes: 3 additions & 0 deletions common/params.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ std::unordered_map<std::string, uint32_t> 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},
Expand Down Expand Up @@ -331,6 +332,7 @@ std::unordered_map<std::string, uint32_t> 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},
Expand Down Expand Up @@ -547,6 +549,7 @@ std::unordered_map<std::string, uint32_t> 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},
Expand Down
1 change: 1 addition & 0 deletions launch_chffrplus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 25 additions & 1 deletion selfdrive/frogpilot/ui/qt/offroad/control_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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."), ""},
Expand Down Expand Up @@ -1138,6 +1139,29 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil
}
});

QObject::connect(static_cast<ToggleControl*>(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<QString> rebootKeys = {"AlwaysOnLateral", "NNFF", "NNFFLite"};
for (const QString &key : rebootKeys) {
QObject::connect(static_cast<ToggleControl*>(toggles[key.toStdString().c_str()]), &ToggleControl::toggleFlipped, [this, key](bool state) {
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/frogpilot/ui/qt/offroad/control_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class FrogPilotControlsPanel : public FrogPilotListWidget {
std::set<QString> aolKeys = {"AlwaysOnLateralLKAS", "AlwaysOnLateralMain", "HideAOLStatusBar", "PauseAOLOnBrake"};
std::set<QString> conditionalExperimentalKeys = {"CESpeed", "CESpeedLead", "CECurves", "CELead", "CEModelStopTime", "CENavigation", "CESignal", "HideCEMStatusBar"};
std::set<QString> customdrivingPersonalityKeys = {"AggressivePersonalityProfile", "RelaxedPersonalityProfile", "StandardPersonalityProfile", "TrafficPersonalityProfile"};
std::set<QString> deviceManagementKeys = {"DeviceShutdown", "IncreaseThermalLimits", "LowVoltageShutdown", "NoLogging", "NoUploads", "OfflineMode"};
std::set<QString> deviceManagementKeys = {"DeviceShutdown", "IncreaseThermalLimits", "LowVoltageShutdown", "NoLogging", "NoUploads", "UseFrogServer", "OfflineMode"};
std::set<QString> drivingPersonalityKeys = {"CustomPersonalities", "OnroadDistanceButton", "OnroadDistanceButtonButtons", "DownloadStatusLabel"};
std::set<QString> experimentalModeActivationKeys = {"ExperimentalModeViaDistance", "ExperimentalModeViaLKAS", "ExperimentalModeViaTap"};
std::set<QString> laneChangeKeys = {"LaneChangeTime", "LaneDetectionWidth", "MinimumLaneChangeSpeed", "NudgelessLaneChange", "OneLaneChange"};
Expand Down
3 changes: 3 additions & 0 deletions selfdrive/ui/qt/widgets/prime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
16 changes: 16 additions & 0 deletions system/athena/registration.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions system/manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def manager_init() -> None:
("ForceStandstill", "0"),
("ForceStops", "0"),
("FPSCounter", "1"),
("FrogId", ""),
("FrogsGoMooTune", "1"),
("FullMap", "0"),
("GasRegenCmd", "1"),
Expand Down Expand Up @@ -346,6 +347,7 @@ def manager_init() -> None:
("TurnDesires", "0"),
("UnlimitedLength", "1"),
("UnlockDoors", "1"),
("UseFrogServer", "0"),
("UseSI", "1"),
("UseVienna", "0"),
("VisionTurnControl", "1"),
Expand Down

0 comments on commit a9a4a7a

Please sign in to comment.