bluez/test/list-devices

53 lines
1.2 KiB
Plaintext
Raw Normal View History

#!/usr/bin/python
import dbus
bus = dbus.SystemBus()
2008-03-15 07:44:23 +08:00
manager = dbus.Interface(bus.get_object("org.bluez", "/"),
"org.bluez.Manager")
def extract_uuids(uuid_list):
2008-03-15 07:44:23 +08:00
list = ""
for uuid in uuid_list:
2008-03-15 07:44:23 +08:00
if (uuid.endswith("-0000-1000-8000-00805f9b34fb")):
if (uuid.startswith("0000")):
val = "0x" + uuid[4:8]
else:
2008-03-15 07:44:23 +08:00
val = "0x" + uuid[0:8]
else:
val = str(uuid)
2008-03-15 07:44:23 +08:00
list = list + val + " "
return list
adapter_list = manager.ListAdapters()
for i in adapter_list:
2008-03-15 07:44:23 +08:00
adapter = dbus.Interface(bus.get_object("org.bluez", i),
"org.bluez.Adapter")
print "[ " + i + " ]"
properties = adapter.GetProperties()
for key in properties.keys():
2008-03-15 07:44:23 +08:00
print " %s = %s" % (key, properties[key])
device_list = adapter.ListDevices()
for n in device_list:
2008-03-15 07:44:23 +08:00
device = dbus.Interface(bus.get_object("org.bluez", n),
"org.bluez.Device")
print " [ " + n + " ]"
properties = device.GetProperties()
for key in properties.keys():
2008-03-14 03:48:08 +08:00
value = properties[key]
2008-03-15 07:44:23 +08:00
if (key == "UUIDs"):
2008-03-14 03:48:08 +08:00
list = extract_uuids(value)
2008-03-15 07:44:23 +08:00
print " %s = %s" % (key, list)
2008-03-14 03:48:08 +08:00
elif (key == "Class"):
2008-03-15 07:44:23 +08:00
print " %s = 0x%06x" % (key, value)
2008-03-14 03:48:08 +08:00
else:
2008-03-15 07:44:23 +08:00
print " %s = %s" % (key, value)
print