view · edit · print · history

See also BluetoothAdapter

This goes over what I had to do to setup my Bluetooth USB dongle on my slug to get full IP connectivity.

Note that all this was done on an alpha version Openslug connecting to a RedHat 9 desktop using two Bluegear USB Bluetooth dongles (see the BlueZ Hardware Support page for compatibility info).

The Bluetooth protocol stack under Linux is implemented by the BlueZ project. So the first thing to do is to add the BlueZ packages to your OE build:

In your distro configuration file ($OEROOT/packages/conf/distro/openslug.conf in my case)

There are two different bluez module: one with dbus support and one without it. The dbus support is not needed by the nslu2 because generally it is used to interact with the GUI. So you should't have to use dbus. But if you want dbus, just replace the "nodbus" below by dbus
  • Append the bluez-utils-nodbus package to your BOOTSTRAP_EXTRA_DEPENDS so it gets compiled.
  • Append the bluez-utils-nodbus package to your BOOTSTRAP_EXTRA_RDEPENDS so it gets installed to your ramdisk.

Next you need to make sure the kernel enables the required Bluetooth stuff. Although you can simply build them as loadable kernel modules I didn't bother at first and made them static in the kernel:

Make the following changes to your kernel's defconfig (In my case in $OEROOT/packages/linux/nslu2-openslug-2.6.7/defconfig):


Some optional ones are:

CONFIG_BT_RFCOMM (allow you to map a serial port over a Bluetooth link)
CONFIG_SCO (to support voice over Bluetooth as used in some cell phone headsets)

NOTE: Because my Bluetooth dongle is older and uses USB 1.1 I ran in trouble as I only had EHCI-HCD available, which only supports USB 2.0 devices. For the slug, you need to have OHCI_HCD loaded also to recognise USB 1.1 devices. So make sure your kernel config has both CONFIG_USB_OHCI_HCD and CONFIG_USB_EHCI_HCD set!.

If you use Symlinks for building the firmware, be sure to add the followed symlinks to your symlinks directory (generally /home/slug/nslu2-package-symlinks/packages if you have followed the how to :-).

for adding symlinks use these commands:

cd /home/slug/nslu2-package-symlinks/packages
ln -s /home/slug/openembedded/packages/bluez-utils
ln -s /home/slug/openembedded/packages/bluez-libs

The NSLU2 hasn't pcmcia support so you must commente it out in the bluez-utils conf file: in the $OEROOT/packages/bluez-utils/bluez-utils-common_2.13.inc file, delete the pcmcia-cs in DEPENDS. In EXTRA_OECONF, delete also --enable-pcmcia. And finally delete this line : chmod 755 ${D}/etc/pcmcia/bluetooth

Now you should be able to build your kernel without problems

Once you have all this built to the point you can boot, check your syslog to see if the kernel recognizes your USB dongle on insertion.

You should also see the following if the BlueZ stack is loaded correctly:

Jul 28 20:13:30 romulan kernel: BlueZ Core ver 2.0 Copyright (C) 2000,2001 Qualcomm Inc
Jul 28 20:13:30 romulan kernel: BlueZ HCI USB driver ver 2.0 Copyright (C) 2000,2001 Qualcomm Inc

Some sources recommend adding the following to the modules.conf file (but I did't need to as I had my Bluetooth stuff built-in the kernel):

alias net-pf-31 bluez
alias bt-proto-0 l2cap
alias bt-proto-2 sco
alias bt-proto-3 rfcomm
alias bt-proto-4 bnep

You should now be able to do:

hciconfig hci0 up

to make the Bluetooth interface available to the Bluetooth protocol stack.

Run hciconfig by itself again should give something like this:

hci0: Type: USB
BD Address: 00:03:0D:00:07:8A ACL MTU: 192:8 SCO MTU: 64:8
RX bytes:8567 acl:125 sco:0 events:409 errors:0
TX bytes:4518 acl:128 sco:0 commands:130 errors:0

The `BDAddr` (short for `BD Address`) is the unique hardware address of the Bluetooth adapter.

You can scan for the presence of Bluetooth nodes in your vicinity:

hcitool inq

To prove that the low-level link is up, try pinging the other Bluetooth adapter (using the address hcitool inq returned):

l2ping [BDAddr]

There is different ways to connect Bluetooth modules as the protocol is very flexible but my goal was to just get IP connectivity between my slug and my main desktop so I could SSH to it. This is accomplished using the LAN service. (see BlueZ's documentation for more info on the various network topology possibles)

Configure the /etc/bluetooth/hcid.conf file:

auth disable;
encrypt disable;

This might seem unsafe but I wanted to simplify things to start as the slug doesn't seem to have the necessary helper for requesting the PIN number from the user.

Now make sure the various daemons are started properly (this should be done on startup using OE)


And on my RedHat desktop:

service bluetooth start

Note: For my first test I used used my desktop Linux machine as the gateway Keep in mind that you need to make sure your desktop Linux machine used to test this network connection will need to similar stuff done.

Now for the actual IP networking connection:

on master side (the desktop which has the internet access):

modprobe bnep (if it's a kernel module)
pand --listen --master --role=NAP
ifconfig bnep0 netmask

on slave (the slug):

modprobe bnep
pand -c <bt_addr_of_master>
ifconfig bnep0 netmask
route add default gw

This should create a network interface called bnep0 on each machine and associate an address (192.168.1.x) so they can pass IP traffic through the Bluetooth link.

Automating the process: To automate the loading of the bnep0 interface simply add all the necessary configuration to the /etc/network/interfaces config file:

        iface bnep0 inet static

Then create a folder called pan in /etc/bluetooth/. Create a script called dev-up with the following content:

        ifup bnep0

and make it executable:

        chmod u+x dev-up

Now, once the pand subsystem successfully connects to a NAP, it will execute the dev-up script thus creating the bnep0 interface.

And Voila! A full TCP/IP link!

Keep in mind that there are various other ways to pass data via Bluetooth devices.

For example there is a way to associate a TTY device to a Bluetooth device so you can have older application use Bluetooth transparently. This is accomplished with the RFCOMM module and tools.

There are also the OBEX tools for pushing/pulling files off devices like PDA/phones.

See the various Howtos on the BlueZ's Documentation Page for more details...

Some other good links:

view · edit · print · history · Last edited by eFfeM.
Based on work by VoodooZ, mathieu_xwave, jkpeters_37, and tman.
Originally by VoodooZ.
Page last modified on February 16, 2006, at 03:54 AM