replace connect_to_network, about same time (yes i removed thread call)

pull/36039/head
Shane Smiskol 4 days ago
parent eb07990c3f
commit 52223a726b
  1. 44
      system/ui/lib/wifi_manager.py

@ -157,7 +157,7 @@ class WifiManager:
self._lock = threading.Lock() self._lock = threading.Lock()
self._tmp_init() self._tmp_init()
sys.exit() # sys.exit()
self._scan_thread = threading.Thread(target=self._network_scanner, daemon=True) self._scan_thread = threading.Thread(target=self._network_scanner, daemon=True)
self._scan_thread.start() self._scan_thread.start()
@ -168,6 +168,15 @@ class WifiManager:
atexit.register(self.stop) atexit.register(self.stop)
def _tmp_init(self): def _tmp_init(self):
return
t = time.monotonic()
self.connect_to_network_old('...', '...')
print('first', time.monotonic() - t)
t = time.monotonic()
self.connect_to_network('...', '...')
print('second', time.monotonic() - t)
return
self._wait_for_wifi_device() self._wait_for_wifi_device()
self._update_networks_old() self._update_networks_old()
import copy import copy
@ -351,36 +360,33 @@ class WifiManager:
connection = { connection = {
'connection': { 'connection': {
'type': '802-11-wireless', 'type': ('s', '802-11-wireless'),
'uuid': str(uuid.uuid4()), 'uuid': ('s', str(uuid.uuid4())),
'id': f'openpilot connection {ssid}', 'id': ('s', f'openpilot connection {ssid}'),
'autoconnect-retries': 0, 'autoconnect-retries': ('i', 0),
}, },
'802-11-wireless': { '802-11-wireless': {
'ssid': dbus.ByteArray(ssid.encode("utf-8")), 'ssid': ('ay', ssid.encode("utf-8")),
'hidden': is_hidden, 'hidden': ('b', is_hidden),
'mode': 'infrastructure', 'mode': ('s', 'infrastructure'),
}, },
'ipv4': { 'ipv4': {
'method': 'auto', 'method': ('s', 'auto'),
'dns-priority': 600, 'dns-priority': ('i', 600),
}, },
'ipv6': {'method': 'ignore'}, 'ipv6': {'method': ('s', 'ignore')},
} }
if password: if password:
connection['802-11-wireless-security'] = { connection['802-11-wireless-security'] = {
'key-mgmt': 'wpa-psk', 'key-mgmt': ('s', 'wpa-psk'),
'auth-alg': 'open', 'auth-alg': ('s', 'open'),
'psk': password, 'psk': ('s', password),
} }
settings = dbus.Interface( settings_addr = DBusAddress(NM_SETTINGS_PATH, bus_name=NM, interface=NM_SETTINGS_IFACE)
self._main_bus.get_object(NM, NM_SETTINGS_PATH),
NM_SETTINGS_IFACE
)
conn_path = settings.AddConnection(connection) conn_path = self._conn_main.send_and_get_reply(new_method_call(settings_addr, 'AddConnection', 'a{sa{sv}}', (connection,)))
print('Added connection', conn_path) print('Added connection', conn_path)

Loading…
Cancel
Save