Skip to content

Commit 7934df3

Browse files
projectgusespressif-bot
authored andcommitted
ci wifi_tools: Log the wpa_supplicant interface state when trying to connect
Trigger reconnection if wpa_supplicant seems to have dropped the connection.
1 parent 2e8d607 commit 7934df3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tools/ci/python_packages/wifi_tools.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def __init__(self, iface, reset_on_exit=False):
5151
iface_path = service.GetInterface(self.iface_name)
5252
self.iface_obj = bus.get_object("fi.w1.wpa_supplicant1", iface_path)
5353
self.iface_ifc = dbus.Interface(self.iface_obj, "fi.w1.wpa_supplicant1.Interface")
54+
self.iface_props = dbus.Interface(self.iface_obj, 'org.freedesktop.DBus.Properties')
5455
if self.iface_ifc is None:
5556
raise RuntimeError('supplicant : Failed to fetch interface')
5657

@@ -61,6 +62,14 @@ def __init__(self, iface, reset_on_exit=False):
6162
else:
6263
self.connected = True
6364

65+
def _get_iface_property(self, name):
66+
""" Read the property with 'name' from the wi-fi interface object
67+
68+
Note: The result is a dbus wrapped type, so should usually convert it to the corresponding native
69+
Python type
70+
"""
71+
return self.iface_props.Get("fi.w1.wpa_supplicant1.Interface", name)
72+
6473
def connect(self, ssid, password):
6574
if self.connected is True:
6675
self.iface_ifc.Disconnect()
@@ -76,7 +85,13 @@ def connect(self, ssid, password):
7685
ip = None
7786
retry = 10
7887
while retry > 0:
88+
time.sleep(5)
89+
state = str(self._get_iface_property("State"))
90+
print("wpa iface state %s (scanning %s)" % (state, bool(self._get_iface_property("Scanning"))))
91+
if state in ["disconnected", "inactive"]:
92+
self.iface_ifc.Reconnect()
7993
ip = get_wiface_IPv4(self.iface_name)
94+
print("wpa iface %s IP %s" % (self.iface_name, ip))
8095
if ip is not None:
8196
self.connected = True
8297
return ip

0 commit comments

Comments
 (0)