Sunday, October 21, 2007

Bluetooth: Command-line


Devices with Bluetooth include phones, PDAs, keyboards and mice.



  • bluez-utils / bluetooth - - tools and system daemons for using Bluetooth devices. Provides ciptool, dund, hcitool, hidd, l2ping, pand, rfcomm, sdptool.
  • bluez-firmware - this firmware is required for operation of Bluetooth dongles based on the Broadcom BCM203x 'Blutonium'chipset [non-free]. This is for Linux 2.6 kernels, for Linux 2.4 kernels the package was called bluez-bcm203x [contrib].
  • bluez-cups - - Bluetooth printer driver for CUPS
  • bluez-pcmcia-support - - support for PCMCIA Bluetooth adapters. As it depends on both Bluetooth and pcmciautils I only recommend this if you specifically have a Bluetooth PCMCIA adapter.


  • bluez-gnome - - provides Bluetooth preferences and a GNOME applet for prompting when a Bluetooth passkey (PIN) is required. The applet pops up in the system tray when you insert a Bluetooth device and provides access to the Bluetooth preferences. Log out and back in again for this to take effect. This package is installed by the virtual package bluez-passkey-gnome.
  • gnome-bluetooth - tragically not included in Debian 4.0/Etch. It's available in Debian Testing and will be included in Debian Lenny.
    The gnome-bluetooth package includes gnome-obex-server (for receiving files) and gnome-obex-send (for sending files). gnome-bluetooth-manager (for configuring Bluetooth devices) is planned for future inclusion in gnome-bluetooth; you can see the plans for it at

    There's an unofficial repository where you can get gnome-bluetooth, nautilus-sendto, libgnomebt0 and libbtctl4 by adding the following repository source for Debian Testing and Unstable, not Stable (though in April 2007 I found the testing package to work with Debian 4.0/Etch) (I don't know if these people are trustworthy or not): deb testing gnome-bluetooth. Their key is available at
  • nautilus-sendto - an updated version of Ubuntu's nautilus-sendto that includes Bluetooth support, as opposed to ther version already included in Debian

File Transfer

  • obexftp - command-line file transfer utility for devices that use the OBEX protocol (
  • obexpushd - command-line utility for receiving files via Bluetooth or IRDA (how does this differ from obexserver?)
  • ussp-push - Client for OBEX PUSH - allows you to send objects using the OBEX PUSH protocol. The OBEX PUSH protocol is used to transfer files to a mobile device, generally via Bluetooth or IrDA. The protocol does not allow any other action than sending and generally requires less strict authentication, which is why it is sometimes preferred to the OBEX FTP protocol (which allows full filesystem access and is provided by the obexftp package).
  • I don't recommend openobex-apps because it is "the example applications ... they aren't intended for normal use..."


  • bluemon - Activate or deactivate programs based on Bluetooth link quality. BlueMon monitors the quality of the link to a Bluetooth device and can start or stop programs when the threshold drops below a certain value. This can be used to perform actions like locking the terminal when you walk away from it.
  • bluez-hcidump - - allows the monitoring of Bluetooth activity using the hcidump program. Useful for troubleshooting.
  • btscanner - Bluetooth traffic scanner similar to Kismet for wireless


The version of Bluetooth you're using can make a big difference. For a list of improvements in successive Bluetooth versions (i.e. faster speed, lower power consumption) see To check which version of Bluetooth you're using, look for the 'LMP version':

  • For the remote device: hcitool info . You should see something like: LMP Version: 2.0 (0x3) LMP Subversion: 0x6cc
  • For the local adapter: # hciconfig -a or hciconfig hci0 version. You should see something like: HCI Ver: 1.1 (0x1) HCI Rev: 0x175 LMP Ver: 1.1 (0x1) LMP Subver: 0x175


bluez-gnome provides Desktop → Preferences → Bluetooth Preferences which you use to configure the mode of operation, adapter name and class of device.


Bluetooth service manipulation: /etc/init.d/bluetooth start, /etc/init.d/bluetooth stop and /etc/init.d/bluetooth restart

Set the device name in /etc/bluetooth/hcid.conf.

Check whether the Bluetooth adapter is up and running:
hcitool dev
You should see the adapter device name and MAC address.


There is a list of supported hardware at

If you have trouble connecting look in /var/log/syslog.


Examine your Bluetooth adapter

Using the command-line

Examine all connected adapters:
hciconfig -a.


This isn't currently possible with GNOME, it is planned for inclusion in GNOME Bluetooth Manager.

Scan for remote devices

Using the command-line

Get the MAC address and name of available devices:
hcitool scan


This isn't currently possible with GNOME, it is planned for inclusion in GNOME Bluetooth Manager. However you can get something like this when sending a file where you choose the device to send to.

Ping a remote device

Using the command-line

# l2ping


This isn't currently possible with GNOME, it is planned for inclusion in GNOME Bluetooth Manager which will be included in the gnome-bluetooth package.

Bond / pair with a device

You can bond with devices such as Bluetooth keyboards or phones.

Using the command-line

Connect to the device:
# hcid connect

Setting a PIN/passkey using the command-line isn't supported so use the GNOME PIN helper, bluez-gnome, whose bonding dialog should appear in the GNOME Notification Area.


If you have the bluez-gnome package's Bluetooth Applet running in the Notification Area it will prompt you for a PIN when a device tries to connect. You cannot initiate a connection from the Bluetooth Applet. Initiation will be possible with the forthcoming GNOME Bluetooth Manager.

Service discovery of devices around you

Using the command-line

sdptool browse


This isn't currently possible with GNOME and it doesn't look as though it's planned to be part of the forthcoming GNOME Bluetooth Manager.

Serial connections

Users must be in group 'dialout' to have privileges to use these devices.

Using the command-line

Some features require the Bluetooth device to appear as a traditional serial interface.

Create /dev/rfcomm0 bound to port 3 (the dial-up networking port) on a remote device:
# rfcomm bind 0 3

Check how the rfcomm ports are setup:

Release /dev/rfcomm0:
# rfcomm release 0


This is planned for inclusion in the forthcoming, as yet unwritten, GNOME Bluetooth Manager.

Transfer files from a device to a computer

Using the command-line

Run obexpushd and it will sit there waiting for files to be sent from the device, which it saves to the current working directory.


This requires the gnome-bluetooth package. Run Applications → Accessories → Bluetooth File Sharing. This will provide a Notification Area applet. Send a file to the computer, the file will be saved to the desktop and a dialog will appear asking whether you want to open or delete the file. You may have to set the mode of operation by right-clicking on the Bluetooth Notification Area applet and choosing 'Visible and connectable for other devices'.

Transfer files from a computer to a device

Using the command-line

ussp-push @10 (assumes the OBEX File Transfer channel is 10, which you can check with sdptool browse )


This requires gnome-bluetooth and the updated nautilus-sendto not available in the stock Debian. You right-click on a file and choose 'Send To...' and are able to choose Bluetooth from the 'Send as...' list and the device from the 'Send to...' list.

Internet access through a GPRS or 3G / W-CDMA phone for a computer

See Internet access through a GPRS or 3G / W-CDMA phone from a computer over Bluetooth

Internet access through a computer for a phone


Linux Unwired by Roger Weeks, Edd Dumbill, Brian Jepson:

Connect a Bluetooth keyboard

Initiate the process from the computer.

Using the command-line

(the Debian documentation mentions loads of patches but i didn't need them to get it working)

# hidd --connect

Though you can provide the pin using the command-line, the documentation warns against it, so use the GNOME PIN helper bluez-gnome. The bonding dialog appears in the GNOME Notification Area, you type the key in there, then type it on the Bluetooth keyboard and press [Enter].


I Don't see how it can be initiated from the computer using GNOME, without the proposed GNOME Bluetooth Manager which isn't yet available, so initiate it from the keyboard.

Connect a Bluetooth mouse

Initiate this from the computer.

Using the command-line

# hidd --connect


This isn't currently possible with GNOME, it is planned for inclusion in GNOME Bluetooth Manager which will be included in the gnome-bluetooth package.

Further Information

No comments: