LinuxBluetooth

Connecting to a Gumstix via Bluetooth under Linux.

This should help get some connectivity on a Linux machine to a 'straight from box' Gumstix.

= The Set up =

Gumstix
Attach the Bluetooth antenna, and power-up the board.

Linux
You will need the following packages
 * Bluez-utils

This should be installed by default otherwise under Ubuntu or Debian distros use

= Finding the Gumstix = The first step is to connect to the Gumstix, Turn on your PC's Bluetooth connection and power up the Gumstix then scan for Bluetooth devices using hcitool scan. Hopefully you will find the Gumstix in the output. If you cant find the stick first time round, power the stick on and off. This sometimes solves the problem.

More information can be found using

We need to make a note of the device address. Next check for connectivity. Note: l2ping starts with an 'L' (but lowercase)

= Getting A Serial connection =

Binding to Rfcomm
The next stage in our terminal finding mission is to bind the Bluetooth device to a rfcomm interface, This should create a serial line between the two devices. Rfcomm should be part of the Bluez package, if you encounter any errors a setup guide can be found here: http://www.holtmann.org/linux/bluetooth/rfcomm.html

Bind the Device and check for connectivity.

If this works nicely, all we have to do if fire up Kermit or your preferred serial communications tool and get going.

If you need kermit than do:

configure Kermit with

Finally connect by issuing:. Hopefully you should have a functional serial terminal. Note: you may need to press enter a couple times to get the attention of the gumstix. Then the login screen should come up. The default username and password are root, and gumstix respectively.

= Setting Up Bluetooth Networks =

Having a serial connection is great, But it doesn't allow us to connect using ssh. Or have any real control over network connectivity. A Bluetooth PAN (Personal Area Network) with Ethernet emulation allows us to do this.

for more information on PAN networks look at http://en.wikipedia.org/wiki/Personal_area_network

Basic PAN Configuration
If we only have one stick we want to connect to, then setting up a simple PAND connection appears to be the way forward. This allows us to assign a standard IPv4 address to the stick, giving access to all the normal functions like SSH and SCP.

Slave
Your Gumstix should really be the slave, this means all communication in the network is handled by the PC master.

The First Step is to edit  To start the pand demon. Depending on your kernel version the default options may be 0/1 or True/False. Keep to the same system as they are not interchangeable. We need to modify the pand lines to read.

PAND_ENABLED = True PAND_OPTIONS = ="--connect [master address]"

This tells the stick that it should connect to the device listed at the master address. This can be found using the  command at the master's command line and should be a 6pair hexadecimal number ie. 00:80:37:27:03:8C.

The Next step is to check  for the line. This should exist in a fresh system but it pays to check as it allows the device to accept a link from another device lm accept;

We also want to setup the bnep (Bluetooth Network Encapsulation Protocol) interface on the stick, edit  to give our bluetooth connection an IP address. Although we could assign an address via DHCP it is easier in a simple network to use static addresses, This will mean we always know the IP address of the gumstix we are trying to contact.

auto bnep0 iface bnep0 inet static address 192.168.x.x   netmask 255.255.255.0 network 192.168.x.0 broadcast 192.168.x.255

Finally Restart the Bluetooth networking.
 * 1) /etc/init.d/S30bluetooth stop
 * 2) /etc/init.d/S30bluetooth start

Master
The Master configuration is simple enough, reasonably similar to that of the slave configuration.

First edit  to enable PAND PAND_ENABLED=1 PAND_OPTIONS="--listen --role GN --devup /etc/default/bluetooth/pan/dev-up"

The options here tell the stick to listen for connections. If a connection is accepted adopt the GN (Group Network Controller) Role, The devup section calls the given script when a connection is made. This script can do many things but here we will just use it to bring up the bluetooth device

Then in  lm accept, master;

Finally the dep-up script itself. Create  which should now read

brctl addif pan0 $1 ifconfig $1 0.0.0.0
 * 1) !/bin/sh

When called now, Instead of starting the bnep interface, the script if given the interface id as a parameter. It then adds the interface to the pan0 bridge created earlier.

Hopefully that all makes sense. Any questions or problems ask on the mailing list and I should get back to you.

--Dan Goldsmith 15:09, 24 October 2007 (PDT)

Changelog
 * Added Pand Information for only using one stick. Makes Life much easier.
 * Much Nicer PAND configuration that still works. Less variables required means less scope for Bad Things(TM) to happen
 * Seperated Bridging into its own Section.

--Dan Goldsmith 13:13, 21 October 2007 (PDT) Basic Rfcomm and Bridging info.