Differences between revisions 38 and 39
Revision 38 as of 2010-05-20 20:07:24
Size: 7718
Editor: ?TanguyOrtolo
Comment: rfcomm takes interface name, ubuntuforums instead of ubuntuformus
Revision 39 as of 2010-09-09 23:10:38
Size: 7676
Deletions are marked like this. Additions are marked like this.
Line 54: Line 54:
aptitude install bluez-gnome

(or {{{apt-get
install gnome-bluetooth}}})
aptitude install gnome-bluetooth
Line 60: Line 59:
aptitude install kdebluetooth aptitude install kbluetooth

Note: This page describes Debian Bluetooth information for end users. For developer information see the Bluetooth page.

Using Bluetooth in a Debian system


We assume you have a Bluetooth adapter in your computer and a Bluetooth device (such as a mobile phone or PDA). This documents describes what you need to do to use Bluetooth to communicate with other Bluetooth devices.

The steps described below are required before you can use the services Bluetooth offers. Once you have setup Bluetooth, you can for example

  • exchange data with devices, such as sending music or videos to/from your phone
  • use a mobile phone to give your computer mobile internet access
  • use Bluetooth peripherials with your computer, such as a Bluetooth wireless mouse

See the links below for details.


Install Bluetooth support (package bluetooth ) :

aptitude install bluetooth

Read /usr/share/doc/bluez-utils/README.Debian.gz to get some understanding of what's going on (in testing/unstable, it's bluez instead of bluez-utils).

Make sure the Bluetooth daemon is running:

# /etc/init.d/bluetooth status
bluetooth is running

It it is not, start it using

# /etc/init.d/bluetooth start


For security reasons, Bluetooth devices will only talk to each other if they have been "introduced" first (a bit like in real life :-)). This is referred to as Pairing.

Note that pairing is usually only required the first time two devices interact. Afterwards, they will remember each other, and no exchange of PINs is necessary. This will however depend on the devices involved (on some devices this may be configurable).

To pair devices, you need a passkey-agent. Options are:

Pairing using a GUI tool

  • gnome-bluetooth

aptitude install gnome-bluetooth
  • or kdebluetooth for KDE

aptitude install kbluetooth

Restart X-Windows. This is required for the pairing pop-up in the next step to appear correctly.

On your Bluetooth device you can now try to pair. On the device you need to choose something like the "setup", "connect" or "Bluetooth" menu and then search for Bluetooth devices. You should find your Debian system, called something like debian-0, where debian is the hostname of your Debian system. On your device, select the Debian system. The device will then ask for a PIN, you can make one up. (choose four digits, say 2309 )

On your computer you will get a pop-up information balloon asking for the PIN, something like Pairing request from Phone (xx:xx:xx:xx:xx:xx) where Phone is the name of your phone and xx:xx:xx:xx:xx:xx is its MAC address.

Click on the information balloon.

Another window will pop-up. It asks for the PIN, enter the one you just made up. (e.g. 2309 ) and press [Enter].

Your phone sees that the PIN matches and shows it on its display.

Both devices are now paired.

Pairing using bluetooth-agent

If you do not want to or cannot use Gnome or KDE, you can also use bluetooth-agent for the pairing. bluetooth-agent is part of package bluez if you use Debian testing or unstable, so should already be installed.

Just start bluetooth-agent (as root), giving an arbitrary PIN, such as 4835:

# bluetooth-agent 4835

Then, as described above, choose something like the "setup", "connect" or "Bluetooth" menu on the device to be paired, and search for Bluetooth devices. Select your computer once found; the device should prompt you for a PIN. Now enter the PIN you gave to bluetooth-agent, and pairing is completed.

Note: Instead of initiating the pairing process from the phone, you can also initiate it from the computer. Start bluetoogh-agent as explained above, then run a command that will try to connect to the phone, e.g.

rfcomm connect hci0 <phone address>

where <phone address> is your phone's bluetooth address, as shown by hcitool scan (note that this will only work if the phone is discoverable, though the computer need not be). This will force a connection from computer to phone, which should cause the phone to ask you to confirm the connection attempt by prompting for a PIN. Enter the pin you used with bluetooth-agent.

Troubleshooting the pairing

In order for the pairing to work as described above, your computer's bluetooth interfaces must be discoverable. A bluetooth dongle may start off in hidden mode (bug report here)

To fix this you can run:

# dbus-send --system --dest=org.bluez /org/bluez/hci0 org.bluez.Adapter.SetMode string:discoverable

Or using hciconfig:

# hciconfig hci0 piscan

Then hciconfig should show the flags ISCAN PSCAN, indicating bluetooth is discoverable (i.e. can be scanned). After you finished pairing, it's best to make your computer hidden again: Or using hciconfig:

# hciconfig hci0 noscan

General tips

Helpful Commands

Display your Bluetooth device (for proof that it was installed properly)

hcitool dev

Search for remote Bluetooth devices

hcitool scan

Restart the Bluetooth services

sudo /etc/init.d/bluetooth restart

Force connection to device

sudo hidd --connect <BT_Address>

Helpful Configuration Files

/etc/default/bluetooth - Default HID bluez setting - enable for mice and keyboards


/etc/bluetooth/hcid.conf - HCI bluez settings - configure static device information

device 00:1E:52:FB:68:55 {
    name "Apple Wireless Keyboard";
    auth enable;
    encrypt enable;}

KDE Issues

Since the PIN should be implemented on a user level, we need to make some changes to /etc/bluetooth/hcid.conf

comment out the line

passkey "2309";

and add the following line directly below it (Note: kdebluetooth includes the program kbluepin):

# passkey "2309";
pin_helper /usr/bin/bluez-pin;

KDE also expects a file /etc/bluetooth/link_key to be present.

# touch /etc/bluetooth/link_key
# chmod 644 /etc/bluetooth/link_key
# /etc/init.d/bluetooth restart

In KDE, run kbluetoothd. Click on the Bluetooth icon in the system tray, this loads Konqueror with the Bluetooth:// URL. You should be able to see your device and do some simple file transfers by clicking on the device and choosing the proper transfer protocol.

Scanning for the PC from your device should bring up a window in KDE that asks you for a PIN. Now you can send files to your PC (KDE should bring up a program to handle this).

Some of this information was gleaned from ubuntuforums

HID : Human Interface Device

See also

CategoryHardware CategoryModem