Notes on Using BlueTooth COM-ports in Linux



Copyright C.Bingel 2008

 Last updated 2006-04-27

TODO: Test on more recent Fedora! I hope this information is not too outdated.

This was tested on Fedora Core 3.

Getting started

1. Insert bluetooth device (USB dongle/PCMCIA card) into your PC

2. Start bluetooth service (if it's not already started automatically):

bash# /etc/init.d/bluetooth start

3. Check that bluetooth device (on your PC) is recognized:

bash # hcitool dev
        hci0    00:13:46:00:50:FC

4. Make serial device (if it does not already exist). This you do only once.

# mknod /dev/rfcomm0 c 216 0

5. Scan for BT devices in range (not necessary, but useful for discovering device names)

bash# hcitool scan
Scanning ...
    00:0F:DE:C5:74:67       Kalles K700i
    00:10:C6:86:37:BB       n/a
    00:10:C6:E6:04:21       EGU5FDF90056273

6. Maybe try pinging the device (mostly because you could :-)

bash# l2ping 00:0F:DE:C5:74:67
Ping: 00:0F:DE:C5:74:67 from 00:13:46:00:50:FC (data size 20) ...
0 bytes from 00:0F:DE:C5:74:67 id 200 time 89.79ms
0 bytes from 00:0F:DE:C5:74:67 id 201 time 10.65ms
2 sent, 2 received, 0% loss

7. Search available BT devices for anyone offering a serial port (SP)

# sdptool search SP
Inquiring ...
Failed to connect to SDP server on 00:10:60:A6:DC:B2: Host is down
Searching for SP on 00:0F:DE:C5:74:67 ...
Service Name: Serial Port
Service RecHandle: 0x10003
Service Class ID List:
  "Serial Port" (0x1101)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 2
Service Name: Serial Port 2
Service RecHandle: 0x10004
Service Class ID List:
  "Serial Port" (0x1101)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 3

8. Bind rf-device to bluetooth-device

bash# rfcomm bind /dev/rfcomm0 00:0F:DE:C5:74:67

Bind does not establish the communication per se, only tells the BT daemon to remember (until you reboot) that every time someone tries opening the /dev/rfcomm0 device, it should contact the thing at the specified address.

This can of course be setup to happen automatically using the config file /etc/bluetooth/rfcomm.conf, which is quite self explainatory.

The first time you access the serial port, the phone and computer are not associated. If you are running X, a window will pop-up asking you to enter a PIN, which the same you also must enter in the phone. That trust is then remembered between reboots etc.

9. Then it's all done and you may specify the /dev/rfcomm0 device and use it in any application where you wan't to communicate with the phones serial interface (minicom/PhoneUtil etc).