Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui/networking: combine connect functions into one #23522

Merged
merged 1 commit into from
Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 6 additions & 18 deletions selfdrive/ui/qt/offroad/wifiManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,32 +161,20 @@ SecurityType WifiManager::getSecurityType(const QString &path) {
}
}

void WifiManager::connect(const Network &n) {
return connect(n, "", "");
}

void WifiManager::connect(const Network &n, const QString &password) {
return connect(n, "", password);
}

void WifiManager::connect(const Network &n, const QString &username, const QString &password) {
void WifiManager::connect(const Network &n, const QString &password, const QString &username) {
connecting_to_network = n.ssid;
// disconnect();
forgetConnection(n.ssid); //Clear all connections that may already exist to the network we are connecting
connect(n.ssid, username, password, n.security_type);
}

void WifiManager::connect(const QByteArray &ssid, const QString &username, const QString &password, SecurityType security_type) {
seenNetworks[n.ssid].connected = ConnectedType::CONNECTING;
forgetConnection(n.ssid); // Clear all connections that may already exist to the network we are connecting
Connection connection;
connection["connection"]["type"] = "802-11-wireless";
connection["connection"]["uuid"] = QUuid::createUuid().toString().remove('{').remove('}');
connection["connection"]["id"] = "openpilot connection "+QString::fromStdString(ssid.toStdString());
connection["connection"]["id"] = "openpilot connection " + QString::fromStdString(n.ssid.toStdString());
connection["connection"]["autoconnect-retries"] = 0;

connection["802-11-wireless"]["ssid"] = ssid;
connection["802-11-wireless"]["ssid"] = n.ssid;
connection["802-11-wireless"]["mode"] = "infrastructure";

if (security_type == SecurityType::WPA) {
if (n.security_type == SecurityType::WPA) {
connection["802-11-wireless-security"]["key-mgmt"] = "wpa-psk";
connection["802-11-wireless-security"]["auth-alg"] = "open";
connection["802-11-wireless-security"]["psk"] = password;
Expand Down
5 changes: 1 addition & 4 deletions selfdrive/ui/qt/offroad/wifiManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ class WifiManager : public QWidget {
void activateModemConnection(const QDBusObjectPath &path);
NetworkType currentNetworkType();
void updateGsmSettings(bool roaming, QString apn);

void connect(const Network &ssid);
void connect(const Network &ssid, const QString &password);
void connect(const Network &ssid, const QString &username, const QString &password);
void connect(const Network &ssid, const QString &password = {}, const QString &username = {});
void disconnect();

// Tethering functions
Expand Down