Subject: bluetooth devices
To: None <>
From: Iain Hibbert <>
List: tech-kern
Date: 09/03/2006 19:34:40
   I have received some kindly criticism about the way in which bluetooth
devices are handled in the system, and this has spurred me into a slight
rethink as I would like to get it right before 4.0 is fixed and we have to
support a clunky method forever.

   Originally I made a 'pseudo hub' and devices were configured with a
binary method. I moved on from this, because in the future it was not
going to be extensible and I couldnt see a way to properly identify
devices (for detaching, or to guard against multiple configurations), as
different devices use different protocols and addressing.

   So, the second (current) incarnation moved to proplib dictionary
configuration and was based on a flat file structure, one btdev
pseudo-device per /dev/btdevN entry which provides locators for the admin
to detach devices at will. This was justifiably criticised because there
is a kernel hard coded limit on how many devices you can have, and also
the pseudo-device was not sitting comfortably with some.

  The proposed new system is essentially that a bthub device will be
attached to a bluetooth controller (bt3c, ubt) when it is enabled (there
is no device address until that time), and bluetooth devices attach to the
hub. For identification I added a function so the device itself can
confirm its presence against the same configuration that was used to
attach with.

  I had to work the userland configuration to match also; currently it
seems a bit clunky to me, so the new system works on the same addressing
scheme that the rest of the bluetooth utilities use. The btdevctl(8)
program will do a query if necessary and uses a /var/db/btdev.plist file
as a cache, but can generate a config on the fly. I am working on an
/etc/bluetooth/btdev.conf file that would contain a flat list of
address/device/service values that the /etc/rc.d/btdevctl script will
parse and use to know which devices to configure.

  The latest diff (my source is a few weeks out of date and I'm still
tidying up a couple of loose ends), or an archive of the affected files
are at:

  I like this layout a lot better and I'm hoping for third time lucky and
request comments - if nothing adverse is brought up, I will commit this
later in the week and request a pullup for 4.0