mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-05 00:05:59 +08:00
FrogPilot features - Enable tethering when going onroad / all the time
This commit is contained in:
@@ -126,9 +126,12 @@ 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<QString> tetheringSelection{tr("Off"), tr("Only Onroad"), tr("Always")};
|
||||
tetheringToggle = new FrogPilotButtonParamControl("TetheringEnabled", "Enable Tethering", "", "", tetheringSelection);
|
||||
list->addItem(tetheringToggle);
|
||||
QObject::connect(tetheringToggle, &ToggleControl::toggleFlipped, this, &AdvancedNetworking::toggleTethering);
|
||||
QObject::connect(tetheringToggle, &FrogPilotButtonParamControl::buttonClicked, [this](int id) {
|
||||
toggleTethering(id);
|
||||
});
|
||||
|
||||
// Change tethering password
|
||||
ButtonControl *editPasswordButton = new ButtonControl(tr("Tethering Password"), tr("EDIT"));
|
||||
@@ -220,9 +223,10 @@ void AdvancedNetworking::refresh() {
|
||||
update();
|
||||
}
|
||||
|
||||
void AdvancedNetworking::toggleTethering(bool enabled) {
|
||||
wifi->setTetheringEnabled(enabled);
|
||||
void AdvancedNetworking::toggleTethering(int id) {
|
||||
wifi->setTetheringEnabled(id == 2);
|
||||
tetheringToggle->setEnabled(false);
|
||||
updateFrogPilotToggles();
|
||||
}
|
||||
|
||||
// WifiUI functions
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include "selfdrive/ui/qt/widgets/toggle.h"
|
||||
#include "selfdrive/ui/ui.h"
|
||||
|
||||
#include "selfdrive/frogpilot/ui/qt/widgets/frogpilot_controls.h"
|
||||
|
||||
class WifiItem : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -63,7 +65,7 @@ public:
|
||||
|
||||
private:
|
||||
LabelControl* ipLabel;
|
||||
ToggleControl* tetheringToggle;
|
||||
FrogPilotButtonParamControl* tetheringToggle;
|
||||
ToggleControl* roamingToggle;
|
||||
ButtonControl* editApnButton;
|
||||
ButtonControl* hiddenNetworkButton;
|
||||
@@ -76,7 +78,7 @@ signals:
|
||||
void requestWifiScreen();
|
||||
|
||||
public slots:
|
||||
void toggleTethering(bool enabled);
|
||||
void toggleTethering(int id);
|
||||
void refresh();
|
||||
};
|
||||
|
||||
|
||||
@@ -268,6 +268,11 @@ void ui_update_frogpilot_params(UIState *s, Params ¶ms) {
|
||||
cereal::CarParams::Reader CP = cmsg.getRoot<cereal::CarParams>();
|
||||
scene.longitudinal_control = hasLongitudinalControl(CP);
|
||||
}
|
||||
|
||||
scene.tethering_config = params.getInt("TetheringEnabled");
|
||||
if (scene.tethering_config == 2) {
|
||||
WifiManager(s).setTetheringEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void UIState::updateStatus() {
|
||||
@@ -290,6 +295,9 @@ void UIState::updateStatus() {
|
||||
started_prev = scene.started;
|
||||
scene.world_objects_visible = false;
|
||||
emit offroadTransition(!scene.started);
|
||||
if (scene.tethering_config == 1) {
|
||||
wifi->setTetheringEnabled(scene.started);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,6 +323,8 @@ UIState::UIState(QObject *parent) : QObject(parent) {
|
||||
timer->start(1000 / UI_FREQ);
|
||||
|
||||
// FrogPilot variables
|
||||
wifi = new WifiManager(this);
|
||||
|
||||
ui_update_params(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "common/mat.h"
|
||||
#include "common/params.h"
|
||||
#include "common/timing.h"
|
||||
#include "selfdrive/ui/qt/network/wifi_manager.h"
|
||||
#include "selfdrive/ui/qt/util.h"
|
||||
#include "system/hardware/hw.h"
|
||||
|
||||
@@ -121,8 +122,10 @@ typedef struct UIScene {
|
||||
bool online;
|
||||
bool parked;
|
||||
bool right_hand_drive;
|
||||
bool tethering_enabled;
|
||||
|
||||
int alert_size;
|
||||
int tethering_config;
|
||||
|
||||
} UIScene;
|
||||
|
||||
@@ -151,6 +154,9 @@ public:
|
||||
|
||||
QTransform car_space_transform;
|
||||
|
||||
// FrogPilot variables
|
||||
WifiManager *wifi = nullptr;
|
||||
|
||||
signals:
|
||||
void uiUpdate(const UIState &s);
|
||||
void offroadTransition(bool offroad);
|
||||
|
||||
Reference in New Issue
Block a user