#!/bin/bash # background information: http://gentoo-wiki.com/HOWTO_use_a_bluetooth_headset http://www.wahlau.org/failed_getting_bluetooth_headset_to_work_with_ubuntu_edgy_eft http://www.think-future.de/wiki/index.php?title=Bluetooth http://sourceforge.net/mailarchive/forum.php?thread_name=alpine.LNX.1.00.0802052112140.20192%40nge2.ngu.pk&forum_name=bluez-users # step 1: install bluetooth alsa software sudo apt-get install bluetooth-alsa bluez-utils sudo /etc/init.d/bluetooth stop sudo /etc/init.d/alsa-utils stop echo | sudo tee /var/log/syslog sudo rm --recursive /var/lib/bluetooth/* sudo modprobe --remove hci_usb sudo modprobe hci_usb force_scofix=1 # system information: cd $HOME apt-cache show bluez-utils > bluez-utils-version-log.txt lsmod > $HOME/lsmod-log.txt # step 2: enable bluetooth audio service sudo cp /etc/bluetooth/audio.service /etc/bluetooth/audio.service.backup #~ sudo mv /etc/bluetooth/audio.service.backup /etc/bluetooth/audio.service echo '[Bluetooth Service] Identifier=audio Name=Audio service Description=Bluetooth Audio service Autostart=true' | sudo tee /etc/bluetooth/audio.service sudo cat /etc/bluetooth/audio.service sudo cp /etc/bluetooth/audio.service $HOME/audio.service # step 3: sudo cp /etc/bluetooth/audio.conf /etc/bluetooth/audio.conf.backup #~ sudo mv /etc/bluetooth/audio.conf.backup /etc/bluetooth/audio.conf echo '[General] SCORouting=HCI [Headset] DisableHFP=false' | sudo tee /etc/bluetooth/audio.conf sudo cat /etc/bluetooth/audio.conf sudo cp /etc/bluetooth/audio.conf $HOME/audio.conf # step 4: cp $HOME/.asoundrc $HOME/.asoundrc.backup echo 'pcm.bluetooth { type plug slave { pcm "bluetooth_hardware" } } pcm.bluetooth_hardware { type bluetooth device 20:07:09:15:A9:5A # profile "auto" }' | tee $HOME/.asoundrc sudo cp $HOME/.asoundrc $HOME/asoundrc # step 5: sudo cp /etc/bluetooth/hcid.conf /etc/bluetooth/hcid.conf.backup echo 'options { autoinit yes; security user; pairing multi; passkey "0000"; } device { name "[%h] / BT Device %d"; class 0x020108; pkt_type DH1,DM1,HV1; iscan enable; pscan enable; lm accept; lp rswitch,hold,sniff,park; }' | sudo tee /etc/bluetooth/hcid.conf cat /etc/bluetooth/hcid.conf sudo cp /etc/bluetooth/hcid.conf $HOME/hcid.conf echo 0000 | sudo tee /etc/bluetooth/pin sudo cp /etc/bluetooth/pin $HOME/pin sudo hcidump -X > $HOME/hcidump.txt sudo /etc/init.d/sysklogd start sudo /etc/init.d/klogd start sudo /etc/init.d/bluetooth restart sudo /etc/init.d/alsa-utils restart sudo python simple-agent 2> $HOME/simple-agent-log.txt sudo tail --lines=100 --follow /var/log/syslog sudo cp /var/log/syslog $HOME/syslog sudo apt-get install mplayer mplayer -ao alsa:device=bluetooth test.mp3 arecord -D bluetooth -f S16_LE | aplay -D bluetooth -f S16_LE hcitool scan 20:07:09:15:A9:5A sudo sdptool browse 20:07:09:15:A9:5A sudo sdptool search HS > sptool-search-hs-log.txt hcitool con > hcitool-con-log.txt sudo hcitool cc 20:07:09:15:A9:5A sdptool search 20:07:09:15:A9:5A hcitool cc 20:07:09:15:A9:5A ls -hal /var/lib/bluetooth/ # note: why is this not avalible in debian sid passkey-agent 0000 20:07:09:15:A9:5A