summaryrefslogtreecommitdiffstats
path: root/hcid/list-devices
blob: 5e27b84d2a4a89f5a67f29ff0a6687f1f489edbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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