Bluetooth Audio

Version 4 (mihanson, 03/03/2011 12:33 pm)

1 3 mihanson
h3. Bluetooth Audio
2 1
3 1
You will need two things:
4 1
# Bluetooth dongle (i.e. USB type) or integrated Bluetooth on your system
5 1
# Bluetooth audio device (Speakers, headphones, etc.)
6 1
7 1
Plug in your Bluetooth dongle
8 1
Install _bluez_
9 1
<pre>$ pacman -Sy bluez</pre>
10 3 mihanson
Ensure your dongle is showing _UP RUNNING_.
11 1
<pre>$ hciconfig -a
12 1
13 1
hci0:	Type: BR/EDR  Bus: USB
14 1
	BD Address: 00:0A:94:02:9C:8C  ACL MTU: 310:10  SCO MTU: 64:8
15 1
	UP RUNNING PSCAN 
16 1
	RX bytes:1074400 acl:20 sco:0 events:153362 errors:0
17 1
	TX bytes:88752435 acl:319268 sco:0 commands:25 errors:0
18 1
	Features: 0xff 0xff 0x8f 0xfe 0x9b 0xf9 0x00 0x80
19 1
	Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
20 1
	Link policy: RSWITCH HOLD SNIFF PARK 
21 1
	Link mode: SLAVE ACCEPT 
22 1
	Name: 'zotac-0'
23 1
	Class: 0x480104
24 1
	Service Classes: Capturing, Telephony
25 1
	Device Class: Computer, Desktop workstation
26 1
	HCI Version: 1.1 (0x1)  Revision: 0xc5c
27 1
	LMP Version: 1.1 (0x1)  Subversion: 0xc5c
28 1
	Manufacturer: Cambridge Silicon Radio (10)</pre>
29 2 mihanson
If not _UP_
30 2 mihanson
<pre>$ hciconfig hci0 up</pre>
31 1
Place your Bluetooth audio device in pairing mode, then scan for it and make a note of the MAC address.
32 1
<pre>$ hcitool scan</pre>
33 1
Use bluez-simple-agent to pair your audio device to your dongle.
34 1
<pre>$ bluez-simple-agent hci0 <MAC Address></pre>
35 1
Enter your audio device's PIN number when prompted.
36 1
If you do not have an /etc/asound.conf, create one with the following information. If you already have that file, append the following to the end. Substitute the correct MAC Address.
37 1
<pre>#/etc/asound.conf
38 1
39 1
 pcm.btheadset {
40 1
    type plug
41 1
    slave {
42 1
        pcm {
43 1
            type bluetooth
44 1
            device <MAC Address> 
45 1
            profile "auto"
46 1
        }   
47 1
    }   
48 1
49 1
    hint {
50 1
        show on
51 1
        description "Bluetooth headset audio output device"
52 1
    }   
53 1
 }
54 1
55 1
 ctl.btheadset {
56 1
   type bluetooth
57 1
 }</pre>
58 1
Check that your audio device is seen by ALSA
59 1
<pre>$ aplay -L
60 1
...<snip>...
61 1
btheadset
62 1
    Bluetooth headset audio output device</pre>
63 1
Main Menu -> Service Menu -> MythTV Configuration -> Setup -> General -> 4th Page
64 1
<pre>Audio output device: ALSA:btheadset</pre>
65 3 mihanson
_Note: you may have to manually type the above setting into the "Audio output device" field_
66 3 mihanson
67 4 mihanson
Test out your new Bluetooth headset! A link to a bash script called _toggleBT.sh_ is located at the bottom of this page. Use irexec and bind it to a remote control key press for easy toggling.  You may have to adjust variables in the script.
68 1
69 3 mihanson
h1. Troubleshooting
70 3 mihanson
71 3 mihanson
* _bluez-simple-agent_ bails out complaining about dbus.
72 3 mihanson
> Try rebooting your machine. I had some issues getting the _bluez-simple-agent_ step to complete successfully until I rebooted. This probably had something to do with bluetoothd, hal and dbus starting in the right order. In theory hal and dbus should be started before bluetoothd, but when I restarted the services manually it still complained.  After reboot this came up fine.
73 1
* Adjust the class in /etc/bluetooth/main.conf
74 3 mihanson
75 3 mihanson
<pre>$ sudo hciconfig hci0 class
76 3 mihanson
hci0:	Type: BR/EDR  Bus: USB
77 3 mihanson
	BD Address: 00:0A:94:02:9C:8C  ACL MTU: 310:10  SCO MTU: 64:8
78 3 mihanson
	Class: 0x480104
79 3 mihanson
	Service Classes: Capturing, Telephony
80 3 mihanson
	Device Class: Computer, Desktop workstation
81 3 mihanson
</pre>
82 3 mihanson
> Define the hexidecimal value for Class (0x480104 in the above case) in _/etc/bluetooth/main.conf_