3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-23 22:42:37 +01:00

autotests: Add a utilities for the SignalLevelAgent API

This commit is contained in:
Andrew Zaborowski 2017-05-20 01:39:40 +02:00 committed by Denis Kenzior
parent c2a39f5c22
commit ca1ef2d82f

View File

@ -28,6 +28,7 @@ IWD_DEVICE_INTERFACE = 'net.connman.iwd.Device'
IWD_KNOWN_NETWORKS_INTERFACE = 'net.connman.iwd.KnownNetworks'
IWD_NETWORK_INTERFACE = 'net.connman.iwd.Network'
IWD_WSC_INTERFACE = 'net.connman.iwd.WiFiSimpleConfiguration'
IWD_SIGNAL_AGENT_INTERFACE = 'net.connman.iwd.SignalLevelAgent'
IWD_AGENT_MANAGER_PATH = '/'
IWD_KNOWN_NETWORKS_PATH = '/'
@ -167,6 +168,31 @@ class NetworkType(Enum):
return type
class SignalAgent(dbus.service.Object):
def __init__(self, passphrase = None):
self._path = '/test/agent/' + str(int(round(time.time() * 1000)))
dbus.service.Object.__init__(self, dbus.SystemBus(), self._path)
@property
def path(self):
return self._path
@dbus.service.method(IWD_SIGNAL_AGENT_INTERFACE,
in_signature='', out_signature='')
def Release(self):
print("SignalAgent released")
@dbus.service.method(IWD_SIGNAL_AGENT_INTERFACE,
in_signature='oy', out_signature='')
def SignalLevelChanged(self, path, level):
self.handle_new_level(str(path), int(level))
@abstractmethod
def handle_new_level(self, path, level):
pass
class Device(IWDDBusAbstract):
'''
Class represents a network device object: net.connman.iwd.Device
@ -307,6 +333,21 @@ class Device(IWDDBusAbstract):
error_handler=self._failure)
self._wait_for_async_op()
def register_signal_agent(self, signal_agent, levels):
self._iface.RegisterSignalLevelAgent(signal_agent.path,
dbus.Array(levels, 'n'),
dbus_interface=self._iface_name,
reply_handler=self._success,
error_handler=self._failure)
self._wait_for_async_op()
def unregister_signal_agent(self, signal_agent):
self._iface.UnregisterSignalLevelAgent(signal_agent.path,
dbus_interface=self._iface_name,
reply_handler=self._success,
error_handler=self._failure)
self._wait_for_async_op()
def __str__(self, prefix = ''):
return prefix + 'Device: ' + self.device_path + '\n'\
+ prefix + '\tName:\t\t' + self.name + '\n'\