diff options
author | Adrian Bunk <adrian.bunk@movial.com> | 2011-06-03 09:17:04 +0000 |
---|---|---|
committer | Adrian Bunk <adrian.bunk@movial.com> | 2011-06-03 09:17:04 +0000 |
commit | 799757ccf1d03c33c75bc597cd5ef77741dcb6a7 (patch) | |
tree | a8c3be85c730de28b012586591b76301033d3d21 /test/list-devices |
Imported upstream 4.91upstream-4.91upstreampackaging
Diffstat (limited to 'test/list-devices')
-rwxr-xr-x | test/list-devices | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/test/list-devices b/test/list-devices new file mode 100755 index 0000000..9120714 --- /dev/null +++ b/test/list-devices @@ -0,0 +1,87 @@ +#!/usr/bin/python + +import dbus + +bus = dbus.SystemBus() + +manager = dbus.Interface(bus.get_object("org.bluez", "/"), + "org.bluez.Manager") + +def extract_objects(object_list): + list = "" + for object in object_list: + val = str(object) + list = list + val[val.rfind("/") + 1:] + " " + return list + +def extract_uuids(uuid_list): + list = "" + for uuid in uuid_list: + if (uuid.endswith("-0000-1000-8000-00805f9b34fb")): + if (uuid.startswith("0000")): + val = "0x" + uuid[4:8] + else: + val = "0x" + uuid[0:8] + else: + val = str(uuid) + list = list + val + " " + return list + +adapter_list = manager.ListAdapters() + +for i in adapter_list: + adapter = dbus.Interface(bus.get_object("org.bluez", i), + "org.bluez.Adapter") + print "[ " + i + " ]" + + properties = adapter.GetProperties() + for key in properties.keys(): + value = properties[key] + if (key == "Devices"): + list = extract_objects(value) + print " %s = %s" % (key, list) + elif (key == "UUIDs"): + list = extract_uuids(value) + print " %s = %s" % (key, list) + else: + print " %s = %s" % (key, value) + + try: + device_list = properties["Devices"] + except: + device_list = [] + + for n in device_list: + device = dbus.Interface(bus.get_object("org.bluez", n), + "org.bluez.Device") + print " [ " + n + " ]" + + properties = device.GetProperties() + for key in properties.keys(): + value = properties[key] + if (key == "Nodes"): + list = extract_objects(value) + print " %s = %s" % (key, list) + elif (key == "UUIDs"): + list = extract_uuids(value) + print " %s = %s" % (key, list) + elif (key == "Class"): + print " %s = 0x%06x" % (key, value) + else: + print " %s = %s" % (key, value) + + try: + node_list = properties["Nodes"] + except: + node_list = [] + + for x in node_list: + node = dbus.Interface(bus.get_object("org.bluez", x), + "org.bluez.Node") + print " [ " + x + " ]" + + properties = node.GetProperties() + for key in properties.keys(): + print " %s = %s" % (key, properties[key]) + + print |