clear connect state

pull/29378/head
deanlee 2 years ago
parent 0185815482
commit 8032f45343
  1. 2
      selfdrive/ui/qt/offroad/networking.cc
  2. 2
      selfdrive/ui/qt/offroad/networking.h
  3. 20
      selfdrive/ui/qt/offroad/wifiManager.cc
  4. 1
      selfdrive/ui/qt/offroad/wifiManager.h

@ -77,7 +77,7 @@ void Networking::refresh() {
an->refresh(); an->refresh();
} }
void Networking::connectToNetwork(const Network &n) { void Networking::connectToNetwork(const Network n) {
if (wifi->isKnownConnection(n.ssid)) { if (wifi->isKnownConnection(n.ssid)) {
wifi->activateWifiConnection(n.ssid); wifi->activateWifiConnection(n.ssid);
} else if (n.security_type == SecurityType::OPEN) { } else if (n.security_type == SecurityType::OPEN) {

@ -91,6 +91,6 @@ public slots:
void refresh(); void refresh();
private slots: private slots:
void connectToNetwork(const Network &n); void connectToNetwork(const Network n);
void wrongPassword(const QString &ssid); void wrongPassword(const QString &ssid);
}; };

@ -8,8 +8,8 @@
#include "selfdrive/ui/qt/util.h" #include "selfdrive/ui/qt/util.h"
bool compare_by_strength(const Network &a, const Network &b) { bool compare_by_strength(const Network &a, const Network &b) {
return std::tuple(a.connected, strengthLevel(a.strength), b.ssid) > return std::tuple(a.connected == ConnectedType::CONNECTED, strengthLevel(a.strength), b.ssid) >
std::tuple(b.connected, strengthLevel(b.strength), a.ssid); std::tuple(b.connected == ConnectedType::CONNECTED, strengthLevel(b.strength), a.ssid);
} }
template <typename T = QDBusMessage, typename... Args> template <typename T = QDBusMessage, typename... Args>
@ -155,8 +155,7 @@ SecurityType WifiManager::getSecurityType(const QVariantMap &properties) {
} }
void WifiManager::connect(const Network &n, const QString &password, const QString &username) { void WifiManager::connect(const Network &n, const QString &password, const QString &username) {
connecting_to_network = n.ssid; setCurrentConnecting(n.ssid);
seenNetworks[n.ssid].connected = ConnectedType::CONNECTING;
forgetConnection(n.ssid); // Clear all connections that may already exist to the network we are connecting forgetConnection(n.ssid); // Clear all connections that may already exist to the network we are connecting
Connection connection; Connection connection;
connection["connection"]["type"] = "802-11-wireless"; connection["connection"]["type"] = "802-11-wireless";
@ -177,7 +176,6 @@ void WifiManager::connect(const Network &n, const QString &password, const QStri
connection["ipv4"]["dns-priority"] = 600; connection["ipv4"]["dns-priority"] = 600;
connection["ipv6"]["method"] = "ignore"; connection["ipv6"]["method"] = "ignore";
emit refreshSignal();
call(NM_DBUS_PATH_SETTINGS, NM_DBUS_INTERFACE_SETTINGS, "AddConnection", QVariant::fromValue(connection)); call(NM_DBUS_PATH_SETTINGS, NM_DBUS_INTERFACE_SETTINGS, "AddConnection", QVariant::fromValue(connection));
} }
@ -257,6 +255,14 @@ void WifiManager::stateChange(unsigned int new_state, unsigned int previous_stat
} }
} }
void WifiManager::setCurrentConnecting(const QString &ssid) {
connecting_to_network = ssid;
for (auto &network : seenNetworks) {
network.connected = (network.ssid == ssid) ? ConnectedType::CONNECTING : ConnectedType::DISCONNECTED;
}
emit refreshSignal();
}
// https://developer.gnome.org/NetworkManager/stable/gdbus-org.freedesktop.NetworkManager.Device.Wireless.html // https://developer.gnome.org/NetworkManager/stable/gdbus-org.freedesktop.NetworkManager.Device.Wireless.html
void WifiManager::propertyChange(const QString &interface, const QVariantMap &props, const QStringList &invalidated_props) { void WifiManager::propertyChange(const QString &interface, const QVariantMap &props, const QStringList &invalidated_props) {
if (interface == NM_DBUS_INTERFACE_DEVICE_WIRELESS && props.contains("LastScan")) { if (interface == NM_DBUS_INTERFACE_DEVICE_WIRELESS && props.contains("LastScan")) {
@ -310,9 +316,7 @@ void WifiManager::initConnections() {
std::optional<QDBusPendingCall> WifiManager::activateWifiConnection(const QString &ssid) { std::optional<QDBusPendingCall> WifiManager::activateWifiConnection(const QString &ssid) {
const QDBusObjectPath &path = getConnectionPath(ssid); const QDBusObjectPath &path = getConnectionPath(ssid);
if (!path.path().isEmpty()) { if (!path.path().isEmpty()) {
connecting_to_network = ssid; setCurrentConnecting(ssid);
seenNetworks[ssid].connected = ConnectedType::CONNECTING;
emit refreshSignal();
return asyncCall(NM_DBUS_PATH, NM_DBUS_INTERFACE, "ActivateConnection", QVariant::fromValue(path), QVariant::fromValue(QDBusObjectPath(adapter)), QVariant::fromValue(QDBusObjectPath("/"))); return asyncCall(NM_DBUS_PATH, NM_DBUS_INTERFACE, "ActivateConnection", QVariant::fromValue(path), QVariant::fromValue(QDBusObjectPath(adapter)), QVariant::fromValue(QDBusObjectPath("/")));
} }
return std::nullopt; return std::nullopt;

@ -85,6 +85,7 @@ private:
void refreshNetworks(); void refreshNetworks();
void activateModemConnection(const QDBusObjectPath &path); void activateModemConnection(const QDBusObjectPath &path);
void addTetheringConnection(); void addTetheringConnection();
void setCurrentConnecting(const QString &ssid);
signals: signals:
void wrongPassword(const QString &ssid); void wrongPassword(const QString &ssid);

Loading…
Cancel
Save