Edward’s Notes

Technical topics and photos.

Bluethooth Headset Under Gentoo Linux

These are my notes on getting a Plantronics Voyager 855 bluetooth headset and Buffalo USB Bluetooth 2.1 dongle working under hardened amd64 Gentoo Linux with Skype.

I installed the latest kernel and

$ echo "sys-kernel/gentoo-sources ~amd64" >> /etc/portage/package.keywords
$ emerge -av =gentoo-sources-2.6.33

rebuilt with the following options added.

Networking --->
<*> Bluetooth subsystem support  --->
<M>   L2CAP protocol support
<M>   SCO links support
<M>   RFCOMM protocol support
[*]     RFCOMM TTY support
<M>   BNEP protocol support
[*]     Multicast filter support
[*]     Protocol filter support
<M>   HIDP protocol support
Bluetooth device drivers  --->
<M> HCI USB driver
[*]   SCO (voice) support
<M> HCI UART driver
[*]   UART (H4) protocol support
[*]   BCSP protocol support
[*]   Transmit CRC with every BCSP packet
<M> HCI BCM203x USB driver
<M> HCI BPA10x USB driver
<M> HCI BlueFRITZ! USB driver

After rebooting I verified the card device was recognized using lsusb

$ lsusb
..
Bus 003 Device 003: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

I then made the following packages changes.

$ euse -E consolekit gstreamer usb acpi dbus hal bluetooth pulseaudio libsamplerate
$ emerge bluez bluez-gnome alsa-libs alsa-plugins alsa-utils pulseaudio pavucontrol
$ emerge --newuse world

I edited the following bluetooth daemon configuration files.

/etc/bluetooth/audio.service
1
2
3
4
5
[Bluetooth Service]
Identifier=audio
Name=Audio service
Description=Bluetooth Audio service
Autostart=true
/etc/bluetooth/audio.conf
1
2
3
4
5
[General]
AutoConnect=true
[Headset]
HFP=false
MaxConnections=1

I added the bluetooth daemon to the default runlevel and started it.

$ rc-update add bluetooth default
$ /etc/init.d/bluetooth start

Using hciconfig I found the dongles address.

$ hciconfig
hci0:  Type: USB
  BD Address: AA:AA:AA:AA:AA:AA ACL MTU: 310:10 SCO MTU: 64:8
  UP RUNNING PSCAN
  RX bytes:3412344 acl:32 sco:5143324 events:258 errors:1
  TX bytes:4132432 acl:32 sco:1895236 commands:76 errors:6

I then put the headset into pairing mode. If the device has not been paired before it automatically goes into pairing mode when you turn it on. If it has already been paired you need to

Turn it off by pressing the big button on the side until it goes red then release. Press and hold the same button until it starts flashing red and blue. It will turn blue before it gets to this state but don’t release until it flashes red and blue.

Find the headset address.

$ hcitool scan
Scanning ...
        BB:BB:BB:BB:BB:BB       8XXPlantronics

Under root run the bluez-gnome pairing wizard.

$ bluetooth-wizard

This will display the 8XXPlantronics device and prompt you for a password which is set to 0000 for this sort of headset.

I then added access to all computer Bluetooth resources for the headset.

/var/lib/bluetooth/AA:AA:AA:AA:AA:AA/trusts
1
BB:BB:BB:BB:BB:BB [all]

Get the default adapter path

$ dbus-send --print-reply --system --dest=org.bluez / org.bluez.Manager.DefaultAdapter
method return sender=:1.0 -> dest=:1.19 reply_serial=2
   object path "/org/bluez/CCCCC/hci0"

Get the path for the headset.

$ dbus-send --print-reply --system --dest=org.bluez /org/bluez/CCCCC/hci0 org.bluez.Adapter.FindDevice string:BB:BB:BB:BB:BB:BB
method return sender=:1.0 -> dest=:1.20 reply_serial=2
   object path "/org/bluez/CCCCC/hci0/dev_BB_BB_BB_BB_BB_BB

Open a connection to the headset using A2DP sterio audio.

$ dbus-send --print-reply --system --dest=org.bluez /org/bluez/CCCCC/hci0/dev_BB_BB_BB_BB_BB_BB org.bluez.AudioSink.Connect
$ dbus-send --print-reply --system --dest=org.bluez /org/bluez/CCCCC/hci0/dev_BB_BB_BB_BB_BB_BB org.bluez.AudioSink.Disconnect

Test connecting to the headset using Headset Profile HSP / Hands-Free Profile HFP

$ dbus-send --print-reply --system --dest=org.bluez /org/bluez/CCCCC/hci0/dev_BB_BB_BB_BB_BB_BB org.bluez.Headset.Connect
$ dbus-send --print-reply --system --dest=org.bluez /org/bluez/CCCCC/hci0/dev_BB_BB_BB_BB_BB_BB org.bluez.Headset.Disconnect

I added the following to my alsa configuration file to set pulseaudio as the default alsa device.

~/.asoundrc
1
2
3
4
5
6
7
8
9
10
11
12
pcm.pulse {
    type pulse
}
ctl.pulse {
    type pulse
}
pcm.!default {
    type pulse
}
ctl.!default {
    type pulse
}

I then rebooted my system and logged into Xwindows. From a terminal I listed the cards registered with pulseaudio as follows.

$ pacmd list-cards
Welcome to PulseAudio! Use "help" for usage information.
>>> 1 card(s) available.
    index: 1
  name: <bluez_card.BB_BB_BB_BB_BB_BB>
  driver: <module-bluetooth-device.c>
  owner module: 26
  properties:
    device.description = "8XXPlantronics"
    device.string = "BB:BB:BB:BB:BB:BB"
    device.api = "bluez"
    device.class = "sound"
    device.bus = "bluetooth"
    device.form_factor = "headset"
    bluez.path = "/org/bluez/CCCCC/hci0/dev_BB_BB_BB_BB_BB_BB"
    bluez.class = "0x240404"
    bluez.name = "8XXPlantronics"
    device.icon_name = "audio-headset-bluetooth"
  profiles:
    a2dp: High Fidelity Playback (A2DP) (priority 10)
    hsp: Telephony Duplex (HSP/HFP) (priority 20)
    off: Off (priority 0)
  active profile: <hsp>
  sinks:
    bluez_sink.BB_BB_BB_BB_BB_BB/#3: 8XXPlantronics
  sources:
    bluez_sink.BB_BB_BB_BB_BB_BB.monitor/#7: Monitor of 8XXPlantronics
    bluez_source.BB_BB_BB_BB_BB_BB/#8: 8XXPlantronics

I then set the card to use HSP/HFP profile using the card name from above.

$ pacmd "set-card-profile bluez_card.BB_BB_BB_BB_BB_BB hsp"

And set the headset as the default source and sink device.

$ pacmd "set-default-sink bluez_sink.BB_BB_BB_BB_BB_BB"
$ pacmd "set-default-source bluez_source.BB_BB_BB_BB_BB_BB"

I use pavucontrol to control volumes and select which device is used to play sound. If you have any questions/comments advice please post a comment.

I found some of the information in the following links helpful.

  1. http://fosswire.com/post/2008/1/a2dp-stereo-linux/
  2. http://wiki.bluez.org/wiki/HOWTO/AudioDevices
  3. http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=530774#10
  4. http://en.gentoo-wiki.com/wiki/BluetoothNetworkAggregation_Point
  5. http://www.gentoo.org/doc/en/bluetooth-guide.xml

Comments