Skip to content

Commit

Permalink
emit refreshSignal in refreshNetworkds
Browse files Browse the repository at this point in the history
  • Loading branch information
deanlee committed Jan 8, 2022
1 parent a55c48f commit 79df9d0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 24 deletions.
5 changes: 1 addition & 4 deletions selfdrive/ui/qt/offroad/networking.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@ void Networking::wrongPassword(const QString &ssid) {

void Networking::showEvent(QShowEvent* event) {
// Wait to refresh to avoid delay when showing Networking widget
QTimer::singleShot(300, this, [=]() {
wifi->start();
refresh();
});
QTimer::singleShot(300, this, [this]() { wifi->start(); });
}

void Networking::hideEvent(QHideEvent* event) {
Expand Down
21 changes: 4 additions & 17 deletions selfdrive/ui/qt/offroad/wifiManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ void WifiManager::setup() {
bus.connect(NM_DBUS_SERVICE, NM_DBUS_PATH_SETTINGS, NM_DBUS_INTERFACE_SETTINGS, "NewConnection", this, SLOT(newConnection(QDBusObjectPath)));

raw_adapter_state = call<uint>(adapter, NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE_DEVICE, "State");

initActiveAp();
activeAp = call<QDBusObjectPath>(adapter, NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE_DEVICE_WIRELESS, "ActiveAccessPoint").path();

initConnections();
requestScan();
}
Expand Down Expand Up @@ -71,6 +71,7 @@ void WifiManager::refreshNetworks() {
}
seenNetworks[ssid] = {ssid, strength, ctype, security};
}
emit refreshSignal();
}

QString WifiManager::get_ipv4_address() {
Expand Down Expand Up @@ -179,18 +180,10 @@ uint WifiManager::getAdapterType(const QDBusObjectPath &path) {
return call<uint>(path.path(), NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE_DEVICE, "DeviceType");
}

bool WifiManager::isWirelessAdapter(const QDBusObjectPath &path) {
return getAdapterType(path) == NM_DEVICE_TYPE_WIFI;
}

void WifiManager::requestScan() {
call(adapter, NM_DBUS_INTERFACE_DEVICE_WIRELESS, "RequestScan", QVariantMap());
}

uint WifiManager::get_wifi_device_state() {
return call<uint>(adapter, NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE_DEVICE, "State");
}

QByteArray WifiManager::get_property(const QString &network_path , const QString &property) {
return call<QByteArray>(network_path, NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE_ACCESS_POINT, property);
}
Expand Down Expand Up @@ -218,7 +211,6 @@ void WifiManager::stateChange(unsigned int new_state, unsigned int previous_stat
connecting_to_network = "";
if (!stop_) {
refreshNetworks();
emit refreshSignal();
}
}
}
Expand All @@ -228,7 +220,6 @@ void WifiManager::propertyChange(const QString &interface, const QVariantMap &pr
if (interface == NM_DBUS_INTERFACE_DEVICE_WIRELESS && props.contains("LastScan")) {
if (!stop_ || firstScan) {
refreshNetworks();
emit refreshSignal();
firstScan = false;
}
} else if (interface == NM_DBUS_INTERFACE_DEVICE_WIRELESS && props.contains("ActiveAccessPoint")) {
Expand All @@ -237,7 +228,7 @@ void WifiManager::propertyChange(const QString &interface, const QVariantMap &pr
}

void WifiManager::deviceAdded(const QDBusObjectPath &path) {
if (isWirelessAdapter(path) && (adapter.isEmpty() || adapter == "/")) {
if (getAdapterType(path) == NM_DEVICE_TYPE_WIFI && (adapter.isEmpty() || adapter == "/")) {
adapter = path.path();
setup();
}
Expand Down Expand Up @@ -391,10 +382,6 @@ void WifiManager::setTetheringEnabled(bool enabled) {
}
}

void WifiManager::initActiveAp() {
activeAp = call<QDBusObjectPath>(adapter, NM_DBUS_INTERFACE_PROPERTIES, "Get", NM_DBUS_INTERFACE_DEVICE_WIRELESS, "ActiveAccessPoint").path();
}

bool WifiManager::isTetheringEnabled() {
if (activeAp != "" && activeAp != "/") {
return get_property(activeAp, "Ssid") == tethering_ssid;
Expand Down
3 changes: 0 additions & 3 deletions selfdrive/ui/qt/offroad/wifiManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,11 @@ class WifiManager : public QObject {
bool firstScan = true;
QString getAdapter(const uint = NM_DEVICE_TYPE_WIFI);
uint getAdapterType(const QDBusObjectPath &path);
bool isWirelessAdapter(const QDBusObjectPath &path);
QString get_ipv4_address();
QString activeAp;
void initActiveAp();
void deactivateConnectionBySsid(const QString &ssid);
void deactivateConnection(const QDBusObjectPath &path);
QVector<QDBusObjectPath> get_active_connections();
uint get_wifi_device_state();
QByteArray get_property(const QString &network_path, const QString &property);
unsigned int get_ap_strength(const QString &network_path);
SecurityType getSecurityType(const QString &path);
Expand Down

0 comments on commit 79df9d0

Please sign in to comment.