Tuesday, November 27, 2007

Initializing bluetooth-enabled phones and devices in Linux

The bluez-utils package as mentioned in the previous post contains the everything you need to configure and test your Bluetooth configuration. After you've installed the tool package, run the init script (/etc/init.d/bluez-utils start on Debian, /etc/init.d/bluetooth start on Red Hat) to initialize the Bluetooth subsystem. In latest kernels these scripts normally run on boot, so they may be started already if you installed from RPMs or especially Debian distributions.

The hcid daemon should now be loaded after your run this package. This daemon controls the initialization of Bluetooth devices on the system and handles the pairing process with other devices.

hci is short initial for Host Controller Interface.


Examine the local devices.
The hciconfig tool allows the configuration of the characteristics of your Bluetooth adapter. If you are used to modify configuration of network interfaces, you will find it to have many similarities in operation to ifconfig. Use -a to show detailed information about each Bluetooth device attached to the computer:

# hciconfig -a
hci0: Type: USB
BD Address: 00:80:98:24:15:6D ACL MTU: 128:8 SCO MTU: 64:8
UP RUNNING PSCAN ISCAN
RX bytes:4923 acl:129 sco:0 events:168 errors:0
TX bytes:2326 acl:87 sco:0 commands:40 errors:0
Features: 0xff 0xff 0x05 0x00
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: HOLD SNIFF PARK
Link mode: SLAVE ACCEPT
Name: 'saag-0'
Class: 0x100100
Service Classes: Object Transfer
Device Class: Computer, Uncategorized
HCI Ver: 1.1 (0x1) HCI Rev: 0x73 LMP Ver: 1.1 (0x1) LMP Subver: 0x73
Manufacturer: Cambridge Silicon Radio (10)

Scanning for remote devices.
The normal test is to see if your computer can detect other Bluetooth devices. You can utilize the hcitool tool to do this. Switch on your other Bluetooth device, and ensure it is in "discoverable" mode. Issue the command hcitool scan and wait. You don't need to be root to run this command.

$ hcitool scan
Scanning …
00:0A:D9:15:CB:B4 N 6600
00:40:05:D0:DD:69 saag-1


I tested this with Nokia 6600 and Bluetooth adapter, saag-1, are shown as discoverable.

No comments: