mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-01-03 02:02:33 +01:00
auto-t: iwd.py: use IO watch for station debug events
Similarly to hostapd.wait_for_event, IWD's variant needed to act on an IO watch because events were being received prior to even calling wait_for_event.
This commit is contained in:
parent
31b5275c1f
commit
5c7f34d66b
@ -232,16 +232,14 @@ class StationDebug(IWDDBusAbstract):
|
|||||||
_iface_name = IWD_STATION_DEBUG_INTERFACE
|
_iface_name = IWD_STATION_DEBUG_INTERFACE
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self._last_event = None
|
self._events = []
|
||||||
self._last_event_data = []
|
|
||||||
|
|
||||||
IWDDBusAbstract.__init__(self, *args, **kwargs)
|
IWDDBusAbstract.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
self._iface.connect_to_signal("Event", self._event_handler)
|
self._iface.connect_to_signal("Event", self._event_handler)
|
||||||
|
|
||||||
def _event_handler(self, event, data):
|
def _event_handler(self, event, data):
|
||||||
self._last_event = event
|
self._events.insert(0, (event, data))
|
||||||
self._last_event_data = data
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def autoconnect(self):
|
def autoconnect(self):
|
||||||
@ -257,19 +255,18 @@ class StationDebug(IWDDBusAbstract):
|
|||||||
frequencies = dbus.Array([dbus.UInt16(f) for f in frequencies])
|
frequencies = dbus.Array([dbus.UInt16(f) for f in frequencies])
|
||||||
self._iface.Scan(frequencies)
|
self._iface.Scan(frequencies)
|
||||||
|
|
||||||
|
def _poll_event(self, event):
|
||||||
|
for idx, e in enumerate(self._events):
|
||||||
|
if event == e[0]:
|
||||||
|
# Consume any older events
|
||||||
|
self._events = self._events[:idx]
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def wait_for_event(self, event, timeout=10):
|
def wait_for_event(self, event, timeout=10):
|
||||||
try:
|
return ctx.non_block_wait(self._poll_event, timeout, event,
|
||||||
if self._last_event is not None:
|
exception=TimeoutError("waiting for event"))
|
||||||
return self._last_event_data
|
|
||||||
|
|
||||||
ctx.non_block_wait(lambda s, e : s._last_event == e, timeout, self, event,
|
|
||||||
exception=TimeoutError("waiting for StationDebug.Event"))
|
|
||||||
|
|
||||||
return self._last_event_data
|
|
||||||
finally:
|
|
||||||
# Consume the event
|
|
||||||
self._last_event_data = None
|
|
||||||
self._last_event = None
|
|
||||||
|
|
||||||
class DeviceProvisioning(IWDDBusAbstract):
|
class DeviceProvisioning(IWDDBusAbstract):
|
||||||
'''
|
'''
|
||||||
|
Loading…
Reference in New Issue
Block a user