summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-03-13 13:31:53 +0000
committerMarcel Holtmann <marcel@holtmann.org>2008-03-13 13:31:53 +0000
commitb631c83b6e8c324d7bca97b4dbda9bb93a62d653 (patch)
tree365a4769d0d2ae0dad58d763199fcd7e2ae91719 /hcid
parent3cbb08d04d3db29e887979f5c7d5fce875500c34 (diff)
Add script for listing device properties
Diffstat (limited to 'hcid')
-rw-r--r--hcid/Makefile.am6
-rwxr-xr-xhcid/list-devices52
2 files changed, 55 insertions, 3 deletions
diff --git a/hcid/Makefile.am b/hcid/Makefile.am
index 7ccc4b11..dfa29b82 100644
--- a/hcid/Makefile.am
+++ b/hcid/Makefile.am
@@ -57,8 +57,8 @@ AM_YFLAGS = -d
CLEANFILES = lexer.c parser.c parser.h
-EXTRA_DIST = hcid.8 hcid.conf.5 hcid.conf dbus-api.txt test-device \
- service-record.dtd service-did.xml service-spp.xml \
- service-opp.xml service-ftp.xml
+EXTRA_DIST = hcid.8 hcid.conf.5 hcid.conf dbus-api.txt \
+ list-devices test-device service-record.dtd \
+ service-did.xml service-spp.xml service-opp.xml service-ftp.xml
MAINTAINERCLEANFILES = Makefile.in
diff --git a/hcid/list-devices b/hcid/list-devices
new file mode 100755
index 00000000..5e27b84d
--- /dev/null
+++ b/hcid/list-devices
@@ -0,0 +1,52 @@
+#!/usr/bin/python
+
+import dbus
+
+bus = dbus.SystemBus()
+
+
+def extract_uuids(uuid_list):
+ list = ''
+ for uuid in uuid_list:
+ if (uuid.endswith('-0000-1000-8000-00805f9b34fb')):
+ if (uuid.startswith('0000')):
+ val = '0x' + uuid[4:8]
+ else:
+ val = '0x' + uuid[0:8]
+ else:
+ val = str(uuid)
+ list = list + val + ' '
+ return list
+
+
+manager = dbus.Interface(bus.get_object('org.bluez', '/org/bluez'),
+ 'org.bluez.Manager')
+
+adapter_list = manager.ListAdapters()
+
+for i in adapter_list:
+ adapter = dbus.Interface(bus.get_object('org.bluez', i),
+ 'org.bluez.Adapter')
+ print '[ ' + i + ' ]'
+
+ properties = adapter.GetProperties()
+ for key in properties.keys():
+ print ' %s = %s' % (key, properties[key])
+
+ device_list = adapter.ListDevices()
+
+ for n in device_list:
+ device = dbus.Interface(bus.get_object('org.bluez', n),
+ 'org.bluez.Device')
+ print ' [ ' + n + ' ]'
+
+ properties = device.GetProperties()
+ for key in properties.keys():
+ if (key == 'UUID'):
+ list = extract_uuids(properties[key])
+ print ' %s = %s' % (key, list)
+ continue
+
+ print ' %s = %s' % (key, properties[key])
+
+ print