Property 'bluetooth_hci.address' not reliable?

Roel Huybrechts lists at rulus.be
Sat Apr 4 07:56:07 PDT 2009


Good afternoon :)


I'm using HAL to find any Bluetooth devices attached to my computer in
order to get (amongst other things) their MAC address. I've found the
'bluetooth_hci.address' property to be no reliable way to do this.

For example: I have two Bluetooth devices, one internal and one attached
via USB. The output of this code:

#!/usr/bin/python

import dbus

dbus_systembus = dbus.SystemBus()
hal_obj = dbus_systembus.get_object('org.freedesktop.Hal',
'/org/freedesktop/Hal/Manager')
dbus_hal = dbus.Interface(hal_obj, 'org.freedesktop.Hal.Manager')

for item in dbus_hal.FindDeviceByCapability('bluetooth_hci'):
    device_obj = dbus_systembus.get_object('org.freedesktop.Hal', item)
    device = dbus.Interface(device_obj, 'org.freedesktop.Hal.Device')
    print hex(device.GetProperty('bluetooth_hci.address'))

gives me:

0x1a7d0ac265L
0x0L

As you can see, the first is the correct MAC address of the external
device, but the address of the internal device is 0. The output of
'hcitool dev', which, I assume, bypasses HAL, gives me:

Devices:
	hci0	00:22:68:DD:FF:96
	hci1	00:1A:7D:0A:C2:65

What causes HAL to be unable to get the correct address? Is it something
wrong in my code? 

Thanks!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Dit berichtdeel is digitaal ondertekend
Url : http://lists.freedesktop.org/archives/hal/attachments/20090404/75062507/attachment.pgp 


More information about the hal mailing list