|
|
|
@ -123,9 +123,13 @@ class WifiManager: |
|
|
|
|
self._networks_updated = networks_updated |
|
|
|
|
self._connection_failed = connection_failed |
|
|
|
|
|
|
|
|
|
def __del__(self): |
|
|
|
|
self.stop() |
|
|
|
|
|
|
|
|
|
def stop(self): |
|
|
|
|
self._running = False |
|
|
|
|
self._thread.join() |
|
|
|
|
self._bus.close() |
|
|
|
|
|
|
|
|
|
def _run(self): |
|
|
|
|
while True: |
|
|
|
@ -189,6 +193,7 @@ class WifiManager: |
|
|
|
|
return wifi_device |
|
|
|
|
|
|
|
|
|
def connect_to_network(self, ssid: str, password: str | None): |
|
|
|
|
def worker(): |
|
|
|
|
t = time.monotonic() |
|
|
|
|
|
|
|
|
|
# Clear all connections that may already exist to the network we are connecting |
|
|
|
@ -233,6 +238,8 @@ class WifiManager: |
|
|
|
|
|
|
|
|
|
print(f'Connecting to network took {time.monotonic() - t}s') |
|
|
|
|
|
|
|
|
|
threading.Thread(target=worker, daemon=True).start() |
|
|
|
|
|
|
|
|
|
def _get_connections(self) -> list[dbus.ObjectPath]: |
|
|
|
|
settings_iface = dbus.Interface(self._bus.get_object(NM, NM_SETTINGS_PATH), NM_SETTINGS_IFACE) |
|
|
|
|
return settings_iface.ListConnections() |
|
|
|
|