[LINUX] HOW-TO enable bluetooth in Ubuntu 10.04 and later with the command line
#1
For long I have been struggling to enable bluetooth in Ubuntu.

Ubuntu started using bluez4 from of version 10.04, and the old methods got broken. Normally on the desktop there are applets to ease pairing etc, but on the command line (CLI) there is not such a method.

This thread Learned me how simple and easy it was all the time, however it is poorly documented.

I tested this with an Eminent USB bluetooth dongle and a Logitech Mediaboard Pro on Ubuntu 10.04 and Ubuntu 11.04 (both minimal edition)

What to do:

Get your bluetooth device MAC or BT ADD or BlueTooth Address: XX:XX:XX:XX:XX:XX

Ubuntu 10.04:
Code:
#sudo apt-get install bluez

libbluetooth3 will also be installed.

Code:
#sudo apt-get install python-gobject python-dbus
Code:
#cd  /usr/share/doc/bluez/examples/
Code:
#sudo ./simple-agent hci0 XX:XX:XX:XX:XX:XX

Press the reset or pair button on your keyboard, simple-agent will ask to specify a pin like 1111, then type that pin on the bt keyboard and your bt keyboard is paired.

Code:
#sudo ./test-device trusted XX:XX:XX:XX:XX:XX yes
Code:
#sudo /etc/init.d/bluetooth restart

Now your device should be working
Check

Code:
#dmesg|tail

The last messages should be about the paired keyboard (and mouse in my case)

Ubuntu 11.04:
Code:
#sudo apt-get install bluez

libbluetooth3 will also be installed.

Code:
#sudo apt-get install python-gobject python-dbus

On 11.04 these were installed already, don't know if that came with bluez or not (was not a clean install)

Code:
#sudo bluez-simple-agent hci0 XX:XX:XX:XX:XX:XX

Press the reset or pair button on your keyboard, simple-agent will ask to specify a pin like 1111, then type that pin on the bt keyboard and your bt keyboard is paired.

Code:
#sudo bluez-test-device trusted XX:XX:XX:XX:XX:XX yes
Code:
#sudo /etc/init.d/bluetooth restart

Now your device should be working
Check

Code:
#dmesg|tail

The last messages should be about the paired keyboard (and mouse in my case)

Ubuntu 12.04:
After upgrade to 12.04, the keyboard did not reconnect anymore, so i purged bluez, thereafter I followed below steps:
Code:
#sudo apt-get install bluez

Code:
#bluez-simple-agent hci0 XX:XX:XX:XX:XX:XX

Press the reset or pair button on your keyboard, simple-agent will ask to specify a pin like 1111, then type that pin on the bt keyboard and your bt keyboard is paired.

Code:
#bluez-test-device trusted XX:XX:XX:XX:XX:XX yes

If the device is not connected now (thanks blandoon):

Code:
#bluez-test-input connect 00:07:61:FF:3C:6D

After a restart, it should reconnect now.

Some background:
(bluez-)simple-agent is a python script, bluetooth support is in the kernel nowadays. You have to communicate via D-BUS with the bluetooth daemon (bluetoothd). That is the reason why you have to install python-gobject python-dbus as well.
Reply
#2
Thank you very much, this guide was really helpfull for me !!! Big Grin
Did read some sticky's but with no result, with this one my PS3 keyboard is working.
Reply
#3
This is an excellent guide. It should be noticed that it (almost) works for bluetooth headsets as well.

For audio support you should install bluez-alsa in addtition to the bluez package. Pair your bluetooth headset as shown above. Next create a file .asoundrc in your $HOME listing your headset:
Code:
pcm.bluetooth {
        type bluetooth
        device XX:XX:XX:XX:XX:XX
}
pcm.!default {
        type plug
        slave.pcm "bluetooth"
}
Thats it.

To use it in xbmc go to System --> Audio output to set the audio output device to "Custom" and to name it "bluetooth".
Reply
#4
Thank you for this guide very helpful and for the audio comment.

If you need to find your hidden device number XX:XX:XX:XX
Simply type
$hcitool scan

after you install bluez

It will show you all the available devices and the id number(s) put the number for the appropriate device in replace of the XX:XX's
Reply
#5
Thanks for this - I just got my Bluetooth keyboard/mouse (iPazzPort) working on minimal Oneiric with these steps.

There was one more thing not shown in the steps above - after adding the keyboard as a trusted device, I had to explicitly connect (pair) the keyboard before it would actually work:

Code:
bluez-test-input connect 11:22:33:44:55:66

where 11:22:33:44:55:66 is the hardware address of the new device. If you are pairing another type of device, the name of the test command might be different (bluez-test-audio for an audio device, etc.). But after that, it should automatically reconnect even after rebooting and/or shutting off the Bluetooth device.
Reply
#6
Thanks for the great tutorial.

Tried to connect with Logitech dinovo keyboard with mediapad (two separate devices)
It looks like the laser version but i'm not sure because mine is from a few years ago.

Maybe i can get some people started with this device, together with the information mentioned in the thread.
The device seems to connect, if you follow the steps, but there is no output on the screen if you type anything.

Here's a simple sulotion that worked for me.

After you follow the above tutorial, install the following from the command line.

sudo apt-get install bluez-compat

i think installing the bluez-compat thingie can help alot of people with "unconnected" devices.

then connect to the device with

sudo hidd --connect xx:xx:xx:xx:xx:xx

(xx:xx:xx:xx:xx:xx is the adress of your bluetooth device)
dont forget to hit the pair button on your keyboard or mediapad.

The keys of the mediapad are not mapped correctly.

I can sure use a little help here.


Reply
#7
Great comment, thanks, I have had problems since I upgraded to 12.04, with the bluez-compat package it works again.

Not sure how to map the keys correctly though, are the keys of the keypad mapped wrong, or are the keys mapped wrong to xbmc?
Reply
#8
@chmistry:
I'm happy to hear that the bluetooth connection works for you.

I don't have any experience with keymapping though. so unfortunately i can't help you with that part.

An unconvenient problem for me is that my Dinovo Keyboard is not connected at xbmc startup.
i have to get into the terminal, type in the sudo hidd --connect phrase to get it connected.
Any ideas how to pair the device at startup? (xbmc eden)

I will take a closer look at keymapping in a few days.
Reply
#9
cuebit, my comment on keymapping was related to your post, mine is fine.

annoyingly the sudo hidd --connect phrase is for one session only with me as well, I'll try to figure out how to solve this.
It surely is related to ubuntu/linux, nothing to do with XBMC.
Reply
#10
Updated startpost with a solution that works for me.
Reply
#11
Thanks for the fast reply Chmstry,

Quote:cuebit, my comment on keymapping was related to your post, mine is fine.

i didn't understand at first, my bad.

can you point me in the right direction how to accomplish the right keymapping and how to work with the startpost thing?

Reply

Logout Mark Read Team Forum Stats Members Help
[LINUX] HOW-TO enable bluetooth in Ubuntu 10.04 and later with the command line0