Rainers Home

Bluetooth-headset with alsa

This is an quite old tutorial I have unearthed due to public request. I haven’t tried it again since 2003, so there’s no warranty that this will work...

So below the original text from the old homepage:

Some words in the beginning:

I’m an absolute newbie to the whole bluetooth stuff and I’m glad that I was able to get everything working in two days although it wasn’t that easy all the time. All the stuff described here worked for me. It’s quite possible that there are still some mistakes or unneccessary things in there, so use it on your own risk. A big "Thank you!" goes to Jonathan Paisley who wrote the snd-bluez-sco driver and also was patient with me to help me with my first steps in the Bluetooth-world. Of course not to forget all the others of bluez: kudos to all of you! I have tested it using

  • Anycom AHS-10 Headset
  • Anycom USB100 Bluetooth-dongle
  • Anycom USB220 Bluetooth-dongle
  • Bluetake BT007SV Bluetooth-dongle
  • Kernel 2.4.22
  • Kernel 2.4.21-ac4
  • Alsa 0.9.6 (http://www.alsa-project.org) (Alsa 0.9.7 currently won’t work)
  • alsa-driver-0.9.6
  • alsa-lib-0.9.6

from http://bluez.sourceforge.net:

  • bluez-libs-2.4.tar.gz
  • bluez-utils-2.3.tar.gz
  • bluez-sdp-1.5.tar.gz
  • bluez-pan-1.1.tar.gz
  • bluez-hcidump-1.5.tar.gz
  • bluez-hciemu-1.0.tar.gz
  • bluez-bluefw-0.9.tar.gz

from http://www.dcs.gla.ac.uk/~jp/snd-bl...

  • snd-bluez-sco-2003-09-15.tar.gz
  • Time (lots of)...

Let’s start: First, you’ll need to patch the alsa-driver, alsa-libs and your kernel: Unpack the alsa stuff and the snd-bluez-sco package from J. Paisley. You’ll find the required patches in the snd-bluez-sco directory. So do a:

cd alsa-driver-0.9.6
patch -p1 < alsa-driver-0.9.6-bluezsco.patch

cd alsa-libs-0.9.6
patch -p1 < alsa-lib-0.9.6-bluezsco.patch

cd /usr/src/linux (or where your kernel-sources are)
patch -p1 < hciusb-isoc.patch
(this should not produce any errors)

You might need to give the patch command the absolute path to the .patch-files (e.g. patch -p1 < /tmp/snd-bluez-sco-2003-09-15/hciusb-isoc.patch) Depending on the version of your snd-bluez-sco package it might be neccessary to add this line to alsa-driver-0.9.6/alsa-kernel/core/Makefile:

obj-$(CONFIG_SND_BLUEZ_SCO) += snd-pcm.o snd-page-alloc.o snd.o snd-hwdep.o

(see http://sourceforge.net/mailarchive/...) This line was forgotten in the patch and I got "unresolved symbols" when I tried to load the module without it.

Having everything patched, you’ll need bluetooth support in your kernel:

cd /usr/src/linux
make menuconfig(or xconfig, or whatever you like)

in "Bluetooth support" enable all the modules. Then build and install your kernel (and the modules).

Now, it’s time for alsa:

cd alsa-driver-0.9.6
aclocal
autoconf
./configure --with-cards=bluez-sco

(depending on your system you might want to add other soundcards or things like oss too - see ./configure —help for all the possibilities)

make
make install

cd alsa-lib-0.9.6
./configure
make
make install

Then install the bluez-packages: Unpack every archive and install each one:

cd
./configure
make
make install
...build the bluezsco-tool

cd snd-bluez-sco-2003-09-15/bluezsco-0.1/
./configure
make

After having built and installed everything you’ll need to edit some files in /etc: in /etc/modules.conf add the following lines:

     alias net-pf-31 bluez
     alias bt-proto-0 l2cap
     alias bt-proto-2 sco
     alias bt-proto-3 rfcomm
     alias bt-proto-4 bnep
     alias tty-ldisc-15 hci_uart

or - depending on your distro (e.g. debian), write these lines in /etc/modutils/bluez (and do an update-modules)

in /etc/bluetooth/ you’ll find these files:

     hcid.conf
     pin
     rfcomm.conf

I didn’t need to edit hcid.conf. Just enter the pin of your headset in the pin-file and change the device-entry in rfcomm.conf to the MAC (or btaddr how it’s called in the bluetooth-world) of your Bluetooth-USB-dongle.

If you managed it to proceed until here, it’s now time to reboot your machine with your new kernel. Testing... Plug-in your Bluetooth adapter and start the Bluetooth-subsystem with

/etc/init.d/bluetooth start Check if the following modules are loaded (using lsmod):

   
    snd-bluez-sco
    hci_usb
    rfcomm
    l2cap
    bluez

If not, load them with modprobe. Now, hciconfig hci0 should show you the Bluetooth-Adapter:

hci0:   Type: USB
       BD Address: xx:xx:xx:xx:xx:xx ACL MTU: 192:8  SCO MTU: 64:8
       UP RUNNING PSCAN ISCAN
       RX bytes:52636 acl:27 sco:1905 events:80 errors:0
       TX bytes:52112 acl:25 sco:1895 commands:31 errors:0

Then, switch the Headset on in Pairing-mode (on the AHS-10: hold the On-Off-Switch pressed for 10 seconds until the LED starts flashing red and green) Do sdptool search HSET. If a window appears asking for the headset-pin, enter it (0000 is factory default). After this you should see an output similar to this:

   Inquiring ...
   Searching for HSET on xx:xx:xx:xx:xx:xx ...
   Service Name: Headset
   Service RecHandle: 0x20000
   Service Class ID List:
     "Headset" (0x1108)
     "Generic Audio" (0x1203)
   Protocol Descriptor List:
     "L2CAP" (0x0100)
     "RFCOMM" (0x0003)
     Channel: 6
   Language Base Attr List:
     coade_ISO639: 0x656e
     encoding:    0x6a
     base_offset: 0x100

xx:xx:xx:xx:xx:xx is the btaddr of your headset (called MAC ID on the sticker of the headset) ...aaand Action! If everything worked fine until here, the following command should finally let you send and receive audio from your headset:

snd-bluez-sco-2003-09-15/bluezsco-0.1/bluezsco where channel is the same as in the output of the sdptool command above. i.e.

   bluezsco xx:xx:xx:xx:xx:xx 6 And you should get an output similar to this:

   Device is 2:0
   Voice setting: 0x0040
   RFCOMM channel connected
   SCO audio channel connected (handle 44, mtu 64)
   Setting sco fd
   Done setting sco fd
   AT+VGS=15
   Sending up speaker change 15

That’s it! Now you should be able to play s.th. using

   aplay -D plughw:Headset blah.wav
or
   alsaplayer -d plughw:Headset blah.mp3
And for recording:
   arecord -D plughw:Headset blah.wav

If you examine your audiodevices, you should also find your headset there. On my PC it was /dev/dsp1, on my notebook /dev/unknown ...yes, really... Quite easy, isn’t it? *SCNR* Notes for devfs-users: If you installed the debian packages and have s.th. like /etc/devfs/devices.d/bluez on your system - delete the file, or uncomment every entry as described in: http://sourceforge.net/mailarchive/... It’ll work then. (my notebook has devfs and I needed to do so)

That’s all folks... Again, I’m a complete bluetooth-newbie and just a linux-geek who wanted to get his bluetooth headset working. So if you have any questions about some details or why something isn’t working: I’m the wrong person to ask. Search the Mailing-list archives and read the stuff on http://bluez.sf.net or if this shouldn’t help, ask the bluetooth-gurus on the mailing-list.

Of course I welcome any feedback and improvements on this topic :)

SPIP | | Aktivitäten verfolgen RSS 2.0