From 8be9168ec20d1860972047c7a5cdb76ae609daa5 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 28 Sep 2008 06:00:57 +0200 Subject: List device and node objects --- test/list-devices | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/list-devices b/test/list-devices index ec6c580a..511d0cfa 100755 --- a/test/list-devices +++ b/test/list-devices @@ -7,6 +7,13 @@ 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: @@ -29,9 +36,17 @@ for i in adapter_list: properties = adapter.GetProperties() for key in properties.keys(): - print " %s = %s" % (key, properties[key]) + value = properties[key] + if (key == "Devices"): + list = extract_objects(value) + print " %s = %s" % (key, list) + else: + print " %s = %s" % (key, value) - device_list = adapter.ListDevices() + try: + device_list = properties["Devices"] + except: + device_list = [] for n in device_list: device = dbus.Interface(bus.get_object("org.bluez", n), @@ -41,7 +56,10 @@ for i in adapter_list: properties = device.GetProperties() for key in properties.keys(): value = properties[key] - if (key == "UUIDs"): + 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"): @@ -49,4 +67,18 @@ for i in adapter_list: 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 -- cgit