auto-t: iwd.py: allow certain APIs to be used in AP mode

AP mode implements a few DBus methods/properties which are named
the same as station: Scan, Scanning, and GetOrderedNetworks. Allow
the Device object to work with these in AP mode by calling the
correct method if the Mode is 'ap'.
This commit is contained in:
James Prestwood 2022-11-04 09:37:56 -07:00 committed by Denis Kenzior
parent 606769dbea
commit 9ef440eb8e
1 changed files with 16 additions and 8 deletions

View File

@ -521,13 +521,16 @@ class Device(IWDDBusAbstract):
def scanning(self):
'''
Reflects whether the device is currently scanning
for networks. net.connman.iwd.Network objects are
updated when this property goes from true to false.
for networks. For station devices net.connman.iwd.Network
objects are updated when this property goes from true to false
@rtype: boolean
'''
props = self._station_properties()
return bool(props['Scanning'])
if self._properties['Mode'] == 'station':
props = self._station_properties()
return bool(props['Scanning'])
else:
return bool(self._ap.scanning)
@property
def autoconnect(self):
@ -544,12 +547,14 @@ class Device(IWDDBusAbstract):
Possible exception: BusyEx
FailedEx
'''
self._iface.Scan(dbus_interface=IWD_STATION_INTERFACE,
if self._properties['Mode'] == 'station':
self._iface.Scan(dbus_interface=IWD_STATION_INTERFACE,
reply_handler=self._success,
error_handler=self._failure)
if wait:
self._wait_for_async_op()
if wait:
self._wait_for_async_op()
else:
self._ap.scan()
def disconnect(self):
'''Disconnect from the network
@ -576,6 +581,9 @@ class Device(IWDDBusAbstract):
groups the maximum relative signal-strength is the
main sorting factor.
'''
if self._properties['Mode'] == 'ap':
return self._ap.get_ordered_networks()
ordered_networks = []
if not full_scan:
for bus_obj in self._station.GetOrderedNetworks():