GNU/Linux + Bluetooth

Abstract

This article explains how to install, configure and use Bluetooth under GNU/Linux. Both send and receive files, and more: syncronize our handset with our favourite contacts-program, make conections to surf on Internet via routing, etc. As a important note, gotta say that everything is though of a concret GNU/Linux distro, Debian Sid, which I use; but it should be the same way in any GNU/Linux distro without many changes.

Getting ready

All what we need to install Bluetooth in our computer is:

I use Debian GNU/Linux Sid distro, although Bluetooth will run in any distribution. Moreover, modern distros like Ubuntu or Fedora Core integrate already Bluetooth system installed and well configured, ready to go.

To get the latest kernel, we gotta go to www.kernel.org and download the latest version. I am using a 2.6.15.

When we compile our kernel, we need to activate first the following options:

  • <*> Networking support ->
    • <*> Bluetooth subsystem support --->
      • <*> L2CAP protocol support
      • <*> RFCOMM protocol support
      • [*] RFCOMM TTY support
      • Bluetooth device drivers --->
        • <*> HCI USB driver

Apart from all this, be sure you activated the USB support in the right way and that you have EHCI USB 2.0 support, just in case that the USB transceiver would need USB 2.0 support.

The last thing we need to do is download and install Bluetooth software to check that everything went all right. To do that, we will download the following packages:

I suggest to install every package and try to configure all. I know it's hard but it's also worthy. For instance, only a few people know that is possible to use computer's speakers/microphone as a handsfree kit, or either conect to Internet via phone's modem; that's true, there's a list of things that, even that they seem magic or that they would work just under hasefroch, they may also work in GNU/Linux perfectly.

Installing

To install the packages mentioned above, in Debian GNU/Linux, we need to do the following:

~$ sudo apt-get install bluez-hcidump bluez-pin bluez-utils obexftp obexserver gnome-bluetooth

Once we got everything installed and, of course, we run the new kernel with Bluetooth support, the next thing is to connect the Bluetooth dongle and try hciconfig with no arguments.

This command should show us something like the following shot:

hci_sshot.jpg
Screenshot showing commands hciconfig and hcitool

As you can see, the command hciconfig, with no arguments, shows the settings of the Bluetooth device(s) which are present in our computer. This command let you specify a lot of parameters of the connection as well, like type of connection, bluetooth profile tu use, etc. But for now it is ok with this. If the command hciconfig does not show anything, it means that we do not have the Bluetooth support well configured in the kernel or the device is not connected in the right way.

Also, we can see from the screenshot that the command hcitool let us perform several actions, such as device lookups or specify some special settings about the connections to work with. hcitool scan looks for devices in range and show us their MAC address and showname. hcitool inq looks for devices in range and show us their MAC address, their clock offset and type of device.

What else can we do now? Well, now that we have the software installed and that we see our bluetooth dongle working with our kernel we gotta configure all parameters for the connection and the devices. If our bluetooth device doesn't work at all, we'll have to go the www.linux-usb.org web page to see what's wrong and if the device is supported or not, that's all I can say.

Setting it up

First we need to configure the PIN for sending/receiving files in our bluetooth connections in our computer. To do that we go to /etc/bluetooth/pin and put a code to use. Default is 1234.

To set up our computer to receive files, before we run the command obexserver, we need to register the OPUSH service with the following command:

~$ sdptool add --channel=10 OPUSH

If we want to send files, there's nothing weird to configure then. To pair our phone with the computer, we have to search bluetooth devices in range and select our computer, which name is the same as the hostname in our system. And I suggest to set the computer as a friend-device in our phone to make it not to ask confirmation ever and ever. To find our phone from the computer, we need to execute: hcitool scan. Then, we get the MAC and we do a ping to the device like this: l2ping MAC_ADDRESS. If our phone doesn't answer the ping, it means that something goes wrong; but if hcitool finds the phone and the phone finds the computer, it's so weird that l2ping doesn't work.

Using Bluetooth

I use gnome-bluetooth; which is available in Debian, although the sources are not official. Apart from this software, we also have the kdebluetooth framework for Qt and KDE environments. And for console lovers, we have these tools: obex_test, obexftp and obexserver.

Before performing apt-get, we need to add a line into our /etc/apt/sources.list:

deb http://cslug.linux.it/cslug/gnome-bluetooth/ ./

~$ sudo apt-get install gnome-bluetooth kdebluetooth

The command in Gnome to send a file is the following: gnome-obex-send

In KDE, the Bluetooth system is integrated in the file menu, so you'll just need to go on a selected file(s) and press mouse's right-button and choose Send with Bluetooth.

www.claudiocamacho.org
Updated on Friday, 19 September 2008 21:03