2008-03-13 21:31:53 +08:00
|
|
|
#!/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")
|
2008-03-13 21:31:53 +08:00
|
|
|
|
|
|
|
def extract_uuids(uuid_list):
|
2008-03-15 07:44:23 +08:00
|
|
|
list = ""
|
2008-03-13 21:31:53 +08:00
|
|
|
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]
|
2008-03-13 21:31:53 +08:00
|
|
|
else:
|
2008-03-15 07:44:23 +08:00
|
|
|
val = "0x" + uuid[0:8]
|
2008-03-13 21:31:53 +08:00
|
|
|
else:
|
|
|
|
val = str(uuid)
|
2008-03-15 07:44:23 +08:00
|
|
|
list = list + val + " "
|
2008-03-13 21:31:53 +08:00
|
|
|
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 + " ]"
|
2008-03-13 21:31:53 +08:00
|
|
|
|
|
|
|
properties = adapter.GetProperties()
|
|
|
|
for key in properties.keys():
|
2008-03-15 07:44:23 +08:00
|
|
|
print " %s = %s" % (key, properties[key])
|
2008-03-13 21:31:53 +08:00
|
|
|
|
|
|
|
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 + " ]"
|
2008-03-13 21:31:53 +08:00
|
|
|
|
|
|
|
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)
|
2008-03-13 21:31:53 +08:00
|
|
|
|
|
|
|
print
|