Bluetooth Activation

Notice

This HowTo guides you through the steps of activating Bluetooth with an iPAQ 3870 and a PC with Debian Linux. However it should work with other iPAQ versions or Linux distributions.

 

Problem

After installing the Linux image, Familiar Linux does not have Bluetooth support yet.

 

Solution

Additional software must be installed. Familiar Linux includes a package administration system called iPKG that is similar to apt-get of Debian Linux. It is developed especially for ARM (Advanced RISC Machines). A working internet connection is needed for this and up to this point a CF network card, WLAN or Bluetooth is unavailable that's why this has to be done via the serial cable at the iPAQ cradle.

 

1. Create a PPP Connection via the Serial Interface

Place the iPAQ in the Cradle and connect it to a serial interface in the Debian PC. The serial interface in linux is usually named /dev/ttySx where x is the number of the interface in the system starting with zero. In Familiar Linux this interface is called /dev/ttyC0.

Run the following command on the Linux PC

pppd /dev/ttyC0 921600 192.168.200.2:192.168.200.1 noauth nodetach

Open a command prompt / shell on the iPAQ with OPIE and enter the following command

pppd /dev/ttyS0 921600 192.168.200.1:192.168.200.2 noauth nodetach

Now there is a working TCP/IP connection between the Linux PC and the iPAQ.

 

2. Access the iPAQ via SSH

It is easier to access the iPAQ via SSH from the PC than typing commands via the touchscreen of the iPAQ Shell. Run the following command from the PC to get a ssh connection (default root password on Familiar Linux is "rootme"):

ssh [email protected]

 

3. Add Kernel Modules

For Familiar Linux to load the needed Bluetooth kernal modules at boot time the file /etc/modules needs to be altered:

vi /etc/modules
 
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
alias tty-ldisc-15 hci_uart
alias char-major-10-250 hci_vhci

 

4. Activate IP-Forwarding and IP-NAT on the PC

The existing PPP connection creates a new additional subnet where the iPAQ can only communicate with the Debian Linux. To use the internet connection on the Linux machine the PC has to route and do NAT. The following lines should be saved in /etc/init.d/bluelinux on the PC:

#! /bin/sh
# Start the Bluetooth Tools
case "$1" in
start)
echo "Enabling IP-Fowarding Kernel Support..."
echo "1" > /proc/sys/net/ipv4/ip_forward
echo "."
echo "Enabling NAT for Bluetooth Net..."
iptables -t nat -A POSTROUTING -s 192.168.200.0/24 -o eth0 ?j MASQUERADE
echo "."
;;
stop)
echo "Nothing to do..."
echo "."
;;
*)
echo "Usage: /etc/init.d/bluelinux {start|stop}"
exit 1
esac
exit 0

Now add the script to the different runlevels (X is the start runlevel, Y the kill runlevel)

ln -s /etc/init.d/bluelinux /etc/rcX.d/S99bluelinux
ln -s /etc/init.d/bluelinux /etc/rcY.d/K01bluelinux

 

5. Adjust ipkg sources on the iPAQ

To let the command "ipkg" know that the files can be loaded directly from the internet The following files in /etc/ipkg/ must be adjusted.

#/etc/ipkg/base.conf
src base familiar.handhelds.org/releases/v0.7.2/base/armv4l
 
#/etc/ipkg/opie.conf
src opie opie.handhelds.org/feed/stable/familiar/
oder (jenachdem welche version von opie gewünscht ist)
#src opie opie.handhelds.org/feed/testing/familiar/gcc3
#src opie opie.handhelds.org/feed/unstable/familiar/gcc3/
 
#/etc/ipkg/5thtoe.conf
src 5thtoe opie.handhelds.org/feed/5thtoe/

 

6. Set the DNS Server and Gateway on the iPAQ

To get the internet connection and DNS working the DNS server needs to be edited and the default gateway has to be set:

#/etc/resolv.conf
nameserver 192.168.1.1  # DNS of the ISP
nameserver 192.168.1.2

Setting the default route - the IP address is the Debian PC

route add default gw 192.168.200.1

 

7. Update the ipkg package manager

With the following command, the local cache of ipkg is updated. This can take several minutes:

ipkg update

 

8. Install the Bluetooth package

 
Now, all additional packages can be installed over the internet:

  # Bluetooth Tools and Profiles
ipkg install bluez-dun # BlueZ DUN
ipkg install bluez-hcidump # BlueZ 2.0 debugging tool
ipkg install bluez-libs # BlueZ 2.0 client libraries
ipkg install bluez-pan # BlueZ PAN
ipkg install bluez-sdp # Service Discovery Protocol server and client tool
ipkg install bluez-utils # BlueZ utilities
# or everything in a single ipkg package
ipkg install task-bluez # The suite of BlueZ tools

# OPIE Bluetooth Tools
ipkg install opie-bluetoothapplet # Bluetooth Applet (the symbol in the task bar)
ipkg install opie-bluetoothmanager # Bluetooth Manager application

 

9. Setup the boot scripts for hcid and sdpd on the iPAQ

Both Bluetooth services (hcid and sdpd) have to be linked to the bootup runlevel folders:

# HCI Daemon
# start hcid by entering runlevel 2
ln -s /etc/init.d/hcid /etc/rc2.d/S25hcid
# exit hcid by entering runlevel 0
ln -s /etc/init.d/hcid /etc/rc0.d/K25hcid
# SDP Daemon
# start sdpd by entering runlevel 2
ln -s /etc/init.d/sdpd /etc/rc2.d/S25sdpd
# exit sdpd by entering runlevel 0
ln -s /etc/init.d/sdpd /etc/rc0.d/K25sdpd

After rebooting the iPAQ, a Bluetooth icon should be in the status bar.