From: Daniel Wagner <daniel.wag...@bmw-carit.de> --- test/dundee-connect | 20 +++++++++ test/dundee-disconnect | 20 +++++++++ test/monitor-dundee | 109 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+), 0 deletions(-) create mode 100755 test/dundee-connect create mode 100755 test/dundee-disconnect create mode 100755 test/monitor-dundee
diff --git a/test/dundee-connect b/test/dundee-connect new file mode 100755 index 0000000..6cbc629 --- /dev/null +++ b/test/dundee-connect @@ -0,0 +1,20 @@ +#!/usr/bin/python + +import dbus +import sys + +bus = dbus.SystemBus() + +if len(sys.argv) == 2: + path = sys.argv[1] +else: + manager = dbus.Interface(bus.get_object('org.ofono.dundee', '/'), + 'org.ofono.dundee.Manager') + devices = manager.GetDevices() + path = devices[0][0] + +print "Connect device %s..." % path +device = dbus.Interface(bus.get_object('org.ofono.dundee', path), + 'org.ofono.dundee.Device') + +device.Connect() diff --git a/test/dundee-disconnect b/test/dundee-disconnect new file mode 100755 index 0000000..76ff74c --- /dev/null +++ b/test/dundee-disconnect @@ -0,0 +1,20 @@ +#!/usr/bin/python + +import dbus +import sys + +bus = dbus.SystemBus() + +if len(sys.argv) == 2: + path = sys.argv[1] +else: + manager = dbus.Interface(bus.get_object('org.ofono.elect', '/'), + 'org.ofono.elect.Manager') + devices = manager.GetDevices() + path = devices[0][0] + +print "Disonnect device %s..." % path +device = dbus.Interface(bus.get_object('org.ofono.elect', path), + 'org.ofono.elect.Device') + +device.Disconnect() diff --git a/test/monitor-dundee b/test/monitor-dundee new file mode 100755 index 0000000..cf96ceb --- /dev/null +++ b/test/monitor-dundee @@ -0,0 +1,109 @@ +#!/usr/bin/python + +import gobject + +import dbus +import dbus.mainloop.glib + +_dbus2py = { + dbus.String : unicode, + dbus.UInt32 : int, + dbus.Int32 : int, + dbus.Int16 : int, + dbus.UInt16 : int, + dbus.UInt64 : int, + dbus.Int64 : int, + dbus.Byte : int, + dbus.Boolean : bool, + dbus.ByteArray : str, + dbus.ObjectPath : str + } + +def dbus2py(d): + t = type(d) + if t in _dbus2py: + return _dbus2py[t](d) + if t is dbus.Dictionary: + return dict([(dbus2py(k), dbus2py(v)) for k, v in d.items()]) + if t is dbus.Array and d.signature == "y": + return "".join([chr(b) for b in d]) + if t is dbus.Array or t is list: + return [dbus2py(v) for v in d] + if t is dbus.Struct or t is tuple: + return tuple([dbus2py(v) for v in d]) + return d + +def pretty(d): + d = dbus2py(d) + t = type(d) + + if t in (dict, tuple, list) and len(d) > 0: + if t is dict: + d = ", ".join(["%s = %s" % (k, pretty(v)) + for k, v in d.items()]) + return "{ %s }" % d + + d = " ".join([pretty(e) for e in d]) + + if t is tuple: + return "( %s )" % d + + return str(d) + +def property_changed(name, value, path, interface): + iface = interface[interface.rfind(".") + 1:] + print "{%s} [%s] %s = %s" % (iface, path, name, pretty(value)) + +def added(name, value, member, path, interface): + iface = interface[interface.rfind(".") + 1:] + print "{%s} [%s] %s %s" % (iface, member, name, pretty(value)) + +def removed(name, member, path, interface): + iface = interface[interface.rfind(".") + 1:] + print "{%s} [%s] %s" % (iface, member, name) + +def event(member, path, interface): + iface = interface[interface.rfind(".") + 1:] + print "{%s} [%s] %s" % (iface, path, member) + +def message(msg, args, member, path, interface): + iface = interface[interface.rfind(".") + 1:] + print "{%s} [%s] %s %s (%s)" % (iface, path, member, + str(msg), pretty(args)) + +def ussd(msg, member, path, interface): + iface = interface[interface.rfind(".") + 1:] + print "{%s} [%s] %s %s" % (iface, path, member, str(msg)) + +def value(value, member, path, interface): + iface = interface[interface.rfind(".") + 1:] + print "{%s} [%s] %s %s" % (iface, path, member, str(value)) + +if __name__ == '__main__': + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + + bus = dbus.SystemBus() + + bus.add_signal_receiver(property_changed, + bus_name="org.ofono.dundee", + signal_name = "PropertyChanged", + path_keyword="path", + interface_keyword="interface") + + bus.add_signal_receiver(added, + bus_name="org.ofono.dundee", + signal_name = "DeviceAdded", + member_keyword="member", + path_keyword="path", + interface_keyword="interface") + + bus.add_signal_receiver(removed, + bus_name="org.ofono.dundee", + signal_name = "DeviceRemoved", + member_keyword="member", + path_keyword="path", + interface_keyword="interface") + + + mainloop = gobject.MainLoop() + mainloop.run() -- 1.7.8.2.302.g17b4 _______________________________________________ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono