Search:  
Gentoo Wiki

HOWTO_The_host-to-host_Bluetooth

This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc

Contents

Introduction

This howto is intented to explain the users how to successfully install a host bluetooth device, configure the kernel properly, and finally explain all the possibilities that the host-to-host bluetooth interconnection offers.

Supported Devices

A list of the currently supported devices can be found at: http://www.holtmann.org/linux/bluetooth/devices.html Below is a list of the devices supported by following this method during the development of this document:

Bluetooth USB Adapters

  1. Device - Chipset - Spec.
  2. Ericsson Application Toolkit - Ericsson - 1.0b
  3. Ericsson Development Kits - Ericsson - 1.0b
  4. Bluefrog Development Kits - Silicon Wave -
  5. Minikits based on STLC2410 - ST - 1.1
  6. Minikits based on STLC2415 - ST - 1.1
  7. CSR Casira USB Adapter - CSR - 1.1
  8. CSR Microsira USB Dongle - CSR - 1.1
  9. TDK USB Adaptor - CSR - 1.1
  10. 3Com USB Dongle - CSR - 1.1
  11. Intel USB Adapter - CSR - 1.1
  12. Brain Boxes BL-554 - CSR - 1.1
  13. COM1 USB Module - CSR - 1.1
  14. Anycom USB Adapter - CSR - 1.1
  15. Anycom USB-100 - CSR - 1.1
  16. Anycom USB-220 - Transilica - 1.1
  17. SuperBT SBT-100 - Ericsson - 1.1
  18. Digianswer USB Development Kit - Motorola - 1.1
  19. AVM BlueFRITZ! USB v2.0 - AVM - 1.1
  20. ELSA Vianect blue USB - CSR - 1.1
  21. Mitsumi USB Adapter - CSR - 1.1
  22. BlueGear USB Adapter - CSR - 1.1
  23. Acer USB Adapter - CSR - 1.1
  24. A-Link USB Adapter - CSR - 1.1
  25. Typhoon USB Adapter - CSR - 1.1
  26. Silicon Wave USB Module - Silicon Wave - 1.1
  27. Taiyo Youden USB Module - Silicon Wave - 1.1
  28. D-Link DBT-120 (Rev B1) - CSR - 1.1
  29. D-Link DBT-120 (Rev B2) - CSR - 1.1
  30. D-Link DBT-120 (Rev B3) - CSR 1.1
  31. D-Link DBT-120 (Rev B4) - CSR - 1.1
  32. Gigabyte GN-BTD01 - CSR - 1.1
  33. Linksys USBBT100 - CSR - 1.1
  34. EPoX BT-MD01 - CSR - 1.1
  35. EPoX BT-DG02 - CSR - 1.1
  36. EPoX BT-DG03 - CSR - 1.1
  37. MSI MS-6967 - CSR - 1.1
  38. MSI MS-6968 - CSR - 1.1
  39. MSI MS-6970 - CSR - 1.1
  40. Gericom Adapter - CSR - 1.1
  41. SCM Bluetooth Zio - CSR - 1.1
  42. EIO WaveLinker - CSR - 1.1
  43. Microsoft Wireless Transceiver - CSR - 1.1
  44. Sony PCGA-BA1 - CSR - 1.1
  45. Deluo USB Dongle - CSR - 1.1
  46. Digicom Palladio USB Dongle - CSR - 1.1
  47. BlueTake USB Dongle BT007S - CSR - 1.1
  48. BlueTake USB Dongle BT007X - CSR - 1.1
  49. BlueTake USB Dongle BT009S - CSR - 1.1
  50. BlueTake USB Dongle BT009V - CSR - 1.1
  51. BlueTake USB Dongle BT009X - CSR - 1.1
  52. i-Tec Bluetooth USB Dongle - CSR - 1.1
  53. Sitecom USB Dongle - CSR - 1.1
  54. IVT USB Dongle - CSR - 1.1
  55. AboCom USB Dongle - CSR - 1.1
  56. Samsung USB Dongle - CSR - 1.1
  57. CCnC USB Dongle - CSR - 1.1
  58. Windigo USB Dongle - CSR - 1.1
  59. Billionton USB Dongle - CSR - 1.1
  60. Allnet ALL1575 USB Dongle - CSR - 1.1
  61. freeControl BR0R02 USB Dongle - Transilica - 1.1
  62. i-Tec 3033 USB Dongle - Broadcom - 1.1
  63. Belkin F8T003 USB Adapter - CSR - 1.1
  64. Belkin F8T008 USB Adapter - CSR - 1.1
  65. Belkin F8T009 USB Adapter - CSR - 1.1
  66. Planet BT-200U USB Adapter - CSR - 1.1
  67. Digitus Network DN-3008 - CSR - 1.1
  68. Conceptronic CBT100U - CSR - 1.1
  69. M-CAB Class 2 Adapter - CSR - 1.1
  70. Zoom USB Adaptor Model 4310 - CSR - 1.1
  71. Trust BT120 USB Adapter - Transilica - 1.1
  72. AIPTEK Instant Blue USB - Transilica - 1.1
  73. DSE XH4104 USB Adapter - Transilica - 1.1
  74. Abe UB20 USB Bluetooth Dongle - RTX - 1.1
  75. Sitecom CN-512 Bluetooth 2.0 Adapter USB - CSR - 1.2

Kernel Configuration

As the latest linux stable kernel is 2.6.x, the configuration will be done for these series of the kernel. Most Bluetooth devices are connected to a USB port, so USB will be enabled too. If you want, you can use hotplugging in case you want to use modules instead of compiling support built into the kernel, refer to the last chapters of the Gentoo Installation Guide.

Networking  --->
  <*> Bluetooth subsystem support  --->
      <*> L2CAP protocol support
      <*> SCO links support
      <*> RFCOMM protocol support
          [*] RFCOMM TTY support
      <*> BNEP protocol support
          [*] Multicast filter support
          [*] Protocol filter support
              Bluetooth device drivers  --->
                <*> HCI USB driver
                    [*] SCO (voice) support
USB support  --->
  <*> Support for Host-side USB
  --- USB Host Controller Drivers
  <M> EHCI HCD (USB 2.0) support
  <M> OHCI HCD support
  <*> UHCI HCD (most Intel and VIA) support
  --- USB Device Class drivers
  <*> USB Audio support

After that, we have to boot with our new kernel. If all the process went fine, we can run the following command:

# grep ^[TPD] /proc/bus/usb/devices | grep Cls=e0 -B1 -A1
T:  Bus=02 Lev=02 Prnt=03 Port=00 Cnt=01 Dev#=  4 Spd=12  MxCh= 0
D:  Ver= 1.10 Cls=e0(unk. ) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=0a12 ProdID=0001 Rev= 5.25

NOTICE: The Cls=e0(unk. ) identifies the bluetooth adapter.

BlueZ Installation, Configuration & PIN Pairing

Now that the device was detected by the kernel, we need a layer that lets applications communicate with the bluetooth device. We will use BlueZ for doing so. We will need the following bluez packages:

*  net-wireless/bluez-libs
     Latest version available: 2.7
     Latest version installed: 2.7
     Size of downloaded files: 208 kB
     Homepage:    http://bluez.sourceforge.net/
     Description: Bluetooth Userspace Libraries
     License:     GPL-2

*  net-wireless/bluez-utils
     Latest version available: 2.7
     Latest version installed: 2.7
     Size of downloaded files: 276 kB
     Homepage:    http://bluez.sourceforge.net/
     Description: bluetooth utilities
     License:     GPL-2

NOTE: Additional bluez packages might need to be installed in following chapters, depending on what your are planning to do.

IMPORTANT: Some devices, which are not listed here, might also need net-wireless/bluez-bluefw (eg Broadcom chips). These will not be handled by this document yet.

WARNING: Do not emerge bluez-kernel neither bluez-sdp, as they will break bluez-utils!

After having installed bluez-libs and bluez-utils, the command hciconfig should return something like:

# hciconfig
hci0:   Type: USB
   BD Address: 00:10:60:A2:DD:2A ACL MTU: 192:8  SCO MTU: 64:8
   DOWN
   RX bytes:131 acl:0 sco:0 events:18 errors:0
   TX bytes:565 acl:0 sco:0 commands:17 errors:0

Perhaps you might not see it up and running. We have to configure the bluetooth service before starting it. A sample file with an already configured device is below. For additional details: man hcid.conf.

FILE: /etc/bluetooth/hcid.conf

#
# HCI daemon configuration file.
#

# HCId options
options {
       # Automatically initialize new devices
       autoinit yes;

       # Security Manager mode
       #   none - Security manager disabled
       #   auto - Use local PIN for incoming connections
       #   user - Always ask user for a PIN
       #
       #<-- I really recommend you here setting it to auto -->
       security auto;

       # Pairing mode
       #   none  - Pairing disabled
       #   multi - Allow pairing with already paired devices
       #   once  - Pair once and deny successive attempts
       pairing multi;

       # PIN helper
       pin_helper /usr/bin/bluepin;

       # D-Bus PIN helper
       #dbus_pin_helper;
}

# Default settings for HCI devices
device {
       # Local device name
       #   %d - device id
       #   %h - host name
       name "Blackhat BlueZ";

       # Local device class
       class 0x100;

       # Default packet type
       #pkt_type DH1,DM1,HV1;

       # Inquiry and Page scan
       iscan enable; pscan enable;

       # Default link mode
       #   none   - no specific policy
       #   accept - always accept incoming connections
       #   master - become master on incoming connections,
       #            deny role switch on outgoing connections
       #
       #lm accept,master;
       #
       lm accept;

       # Default link policy
       #   none    - no specific policy
       #   rswitch - allow role switch
       #   hold    - allow hold mode
       #   sniff   - allow sniff mode
       #   park    - allow park mode
       #
       #lp hold,sniff;
       #
       lp rswitch,hold,sniff,park;

       # Authentication and Encryption
       auth enable;
       encrypt enable;
}

Now authentification: /etc/bluetooth/pin file on host machine should be like this :

123456

and this is the code the client host that wants to connect to this master host has to have in its /usr/bin/bluepin in the following form

#!/bin/sh
echo "PIN:123456"

To make things simple we assume that the codes for both hosts will be the same so /etc/bluetooth/pin and /usr/bin/bluepin on host A will be the same as on host B

IMPORTANT: This number (of your choice) must be the same in all your hosts with bluetooth devices. Alright, now we are ready to start the service and add it to the default runlevel:

# /etc/init.d/bluetooth start
# rc-update add bluetooth default

Now let's check that the bluetooth daemons started successfully:

# ps -ae | grep hcid
26050 ?        00:00:00 hcid
# ps -ae | grep sdpd
26054 ?        00:00:00 sdpd

After that, we have to check that the device is up and running. If it isn't, stop the bluetooth service, unplug the bluetooth device, plug it back and start the bluetooth service again. A successful initialization would show something like:

# hciconfig
hci0:   Type: USB
   BD Address: 00:10:60:A2:DD:2A ACL MTU: 192:8  SCO MTU: 64:8
   UP RUNNING PSCAN ISCAN AUTH ENCRYPT
   RX bytes:408 acl:0 sco:0 events:21 errors:0
   TX bytes:574 acl:0 sco:0 commands:20 errors:0

# hciconfig -a
hci0:   Type: USB
   BD Address: 00:10:60:A2:DD:2A ACL MTU: 192:8  SCO MTU: 64:8
   UP RUNNING PSCAN ISCAN AUTH ENCRYPT
   RX bytes:408 acl:0 sco:0 events:21 errors:0
   TX bytes:574 acl:0 sco:0 commands:20 errors:0
   Features: 0xff 0xff 0x0f 0x00 0x00 0x00 0x00 0x00
   Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
   Link policy: RSWITCH HOLD SNIFF PARK
   Link mode: SLAVE ACCEPT
   Name: 'Blackhat BlueZ'
   Class: 0x000100
   Service Classes: Unspecified
   Device Class: Computer, Uncategorized
   HCI Ver: 1.1 (0x1) HCI Rev: 0x20d LMP Ver: 1.1 (0x1) LMP Subver: 0x20d
   Manufacturer: Cambridge Silicon Radio (10)

NOTICE: If we run hciconfig -a, we can see whether the parameters configured in /etc/bluetooth/hcid.conf were set correctly.

Detecting Bluetooth Devices in Other Hosts

At this point we are now ready to detect bluetooth devices installed in other machines. This is independent of the host Operating System. We will make use of the hcitool command along this chapter.

To check for local devices before trying to detect remote ones:

# hcitool dev
Devices:
  hci0    00:10:60:A2:DD:2A

On host A: To scan for remote devices:

# hcitool scan
Scanning ...
  00:10:60:A3:CB:41   Grayhat


To inquire remote devices:

# hcitool inq
Inquiring ...
  00:10:60:A3:CB:41   clock offset: 0x5579    class: 0x72010c


Now we need to pair the bluetooth devices. executing

# hcitool cc 00:10:60:A3:CB:41

on the host B we do the same using btaddr of the bluetooth device on host A

# hcitool inq
Inquiring ...
  00:10:60:A2:DD:2A   clock offset: 0x5579    class: 0x72010c
# hcitool cc  00:10:60:A2:DD:2A


If the pairing doesnt work try deleting files /etc/bluetooth/link_key on host A and B. In some setups, the link_key file is located in /var/bluetooth/00:10:60:A2:DD:2A/linkkeys (where "00:10:60:A2:DD:2A" is the MAC-address of your local bluez-device). linkkeys might also be in /var/lib/bluetooth.


After having paired the devices, now we can do whatever we want with them. Let's start by a simple ping:

# l2ping 00:10:60:A3:CB:41
Ping: 00:10:60:A3:CB:41 from 00:10:60:A2:DD:2A (data size 20) ...
20 bytes from 00:10:60:A3:CB:41 id 200 time 69.5ms
20 bytes from 00:10:60:A3:CB:41 id 201 time 9.97ms
20 bytes from 00:10:60:A3:CB:41 id 202 time 56.6ms
20 bytes from 00:10:60:A3:CB:41 id 203 time 39.2ms
4 sent, 4 received, 0% loss

Personal Area Network

You can use Bluetooth Network Encapsulation Protocol (BNEP) to have a TCP/IP link over bluetooth. There are several options of network architecture (peer-to-peer, client-server) - just like Wifi. In this simple example, we will make a connection between two hosts only.

At first, the bnep kernel module has to be compiled and loaded.

On one host start (as root):

one # pand --listen --role NAP

On the other one (assuming the same device ID from previous sections):

two # pand --connect 00:10:60:A3:CB:41

This should make a 'bnep0' network interface on both hosts. Now assign IP adresses to both sides:

one # ifconfig bnep0 10.20.30.1 netmask 255.255.255.0 broadcast 10.20.30.255
two # ifconfig bnep0 10.20.30.2 netmask 255.255.255.0 broadcast 10.20.30.255

Now, you can try to ping it:

one # ping 10.20.30.2
PING 10.20.30.2 (10.20.30.2) 56(84) bytes of data.
64 bytes from 10.20.30.2: icmp_seq=1 ttl=128 time=40.8 ms
64 bytes from 10.20.30.2: icmp_seq=2 ttl=128 time=19.5 ms
64 bytes from 10.20.30.2: icmp_seq=3 ttl=128 time=42.7 ms

--- 10.20.30.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 19.580/34.401/42.768/10.510 ms

Note: If you try to connect a Linux box with a Windows box, try to make the first (Linux) a NAP (Access Point) and the latter (Windows) the PANU (User). Other combinations didn't work for me (Linux <--> W98).

More information here:

Discussion

Can be found here

Retrieved from "http://www.gentoo-wiki.info/HOWTO_The_host-to-host_Bluetooth"

Last modified: Wed, 14 Nov 2007 04:28:00 +0000 Hits: 53,033