[PATCH v3 08/15] test: Use ObjectManager instead of Devices property

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Mikel Astiz <mikel.astiz@xxxxxxxxxxxx>

Use the objects and interfaces reported by the ObjectManager in order
to list the available devices per adapter.
---
 test/list-devices | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/test/list-devices b/test/list-devices
index fcff3e7..e8f3f24 100755
--- a/test/list-devices
+++ b/test/list-devices
@@ -30,6 +30,10 @@ def extract_uuids(uuid_list):
 	return list
 
 objects = manager.GetManagedObjects()
+
+all_devices = (str(path) for path, interfaces in objects.iteritems() if
+					"org.bluez.Device" in interfaces.keys())
+
 for path, interfaces in objects.iteritems():
 	if "org.bluez.Adapter" not in interfaces.keys():
 		continue
@@ -39,19 +43,13 @@ for path, interfaces in objects.iteritems():
 	properties = interfaces["org.bluez.Adapter"]
 	for key in properties.keys():
 		value = properties[key]
-		if (key == "Devices"):
-			list = extract_objects(value)
-			print("    %s = %s" % (key, list))
-		elif (key == "UUIDs"):
+		if (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 = []
+	device_list = [d for d in all_devices if d.startswith(path + "/")]
 
 	for dev_path in device_list:
 		print("    [ " + dev_path + " ]")
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux