3 from __future__ import absolute_import, print_function, unicode_literals
9 manager = dbus.Interface(bus.get_object("org.bluez", "/"),
12 def extract_objects(object_list):
14 for object in object_list:
16 list = list + val[val.rfind("/") + 1:] + " "
19 def extract_uuids(uuid_list):
21 for uuid in uuid_list:
22 if (uuid.endswith("-0000-1000-8000-00805f9b34fb")):
23 if (uuid.startswith("0000")):
24 val = "0x" + uuid[4:8]
26 val = "0x" + uuid[0:8]
29 list = list + val + " "
32 adapter_list = manager.ListAdapters()
34 for i in adapter_list:
35 adapter = dbus.Interface(bus.get_object("org.bluez", i),
37 print("[ " + i + " ]")
39 properties = adapter.GetProperties()
40 for key in properties.keys():
41 value = properties[key]
42 if (key == "Devices"):
43 list = extract_objects(value)
44 print(" %s = %s" % (key, list))
45 elif (key == "UUIDs"):
46 list = extract_uuids(value)
47 print(" %s = %s" % (key, list))
49 print(" %s = %s" % (key, value))
52 device_list = properties["Devices"]
57 device = dbus.Interface(bus.get_object("org.bluez", n),
59 print(" [ " + n + " ]")
61 properties = device.GetProperties()
62 for key in properties.keys():
63 value = properties[key]
65 list = extract_objects(value)
66 print(" %s = %s" % (key, list))
67 elif (key == "UUIDs"):
68 list = extract_uuids(value)
69 print(" %s = %s" % (key, list))
70 elif (key == "Class"):
71 print(" %s = 0x%06x" % (key, value))
72 elif (key == "Vendor"):
73 print(" %s = 0x%04x" % (key, value))
74 elif (key == "Product"):
75 print(" %s = 0x%04x" % (key, value))
76 elif (key == "Version"):
77 print(" %s = 0x%04x" % (key, value))
79 print(" %s = %s" % (key, value))
82 node_list = properties["Nodes"]
87 node = dbus.Interface(bus.get_object("org.bluez", x),
89 print(" [ " + x + " ]")
91 properties = node.GetProperties()
92 for key in properties.keys():
93 print(" %s = %s" % (key, properties[key]))