From ca1ef2d82fd46801f23af6e63df39cb9b1488205 Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Sat, 20 May 2017 01:39:40 +0200 Subject: [PATCH] autotests: Add a utilities for the SignalLevelAgent API --- autotests/util/iwd.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py index 70000034..03fe69bf 100755 --- a/autotests/util/iwd.py +++ b/autotests/util/iwd.py @@ -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'\