7.1 Quick Start

 <  Day Day Up  >  

We tested a Belkin Bluetooth USB adapter with several Linux distributions on an IBM ThinkPad A20m. In all cases, we got it up and running to the point where we created a serial port connection between a Bluetooth cell phone (Nokia 3650) and the Linux machine.

After we set up Bluetooth on each distribution, we completed the following steps (all of this is explained in detail throughout the chapter):

  1. Set the pinin /etc/bluetooth/pin to a numeric-only pin ( 1234 )

  2. Restarted the hcid daemon with killall -HUP hcid

  3. Plugged in the adapter

  4. Discovered the cell phone's Bluetooth address with hcitool scan

  5. Configured the serial port ( /dev/rfcomm0 ) with:

     #  rfcomm bind 0   bluetooth_address    

Upon completion, we conversed with the phone over the serial port using Kermit (see Section 9.3).

The following sections describe our distribution-specific notes. Even if your distribution isn't listed here, check these notes out.

7.1.1 Debian 3.0r1

We abandoned the older 2.4.18 kernel that was the latest 2.4 kernel available for Debian 3.0, and we compiled kernel 2.4.24 according to the instructions in "Configuring the kernel," later in this chapter. To get Bluetooth to the point where we could make an rfcomm connection, we follow these steps:

  1. Edited /etc/apt/sources.list according to the instructions at http:// bluez . sourceforge .net/download/debian/APT-README.

  2. Next, we completed an apt-get update and then installed the following packages:

    • bluez-hcidump

    • bluez-pan

    • bluez-sdp

    • bluez- utils

    • hotplug

  3. The bluez-utils and bluez-sdp packages configured themselves to start in runlevel 3 and 5. After installing these packages, we started them with the following commands (but we could also have rebooted):

     /etc/init.d/bluez-utils  start /etc/init.d/bluez-sdp start 
  4. The /dev/rfcomm* devices already exist, so we didn't need to create them.

7.1.2 SuSE 9.0

We used SuSE 9.0 (FTP install) with the latest available kernel package (2.4.21-166-default). To enable Bluetooth, we followed these steps:

  1. Installed the following packages using YaST:

    • bluez-bluefw

    • bluez-libs

    • bluez-pan

    • bluez-sdp

    • bluez-utils

  2. The packages configured themselves to start in runlevels 3 and 5. After installing these packages, we started them with /etc/init.d/bluetooth start (but we could also have rebooted).

  3. The /dev/rfcomm* devicesdid not exist, so we created them as shown in Example 7-4.

7.1.3 Mandrake 9.2 and RedHat 9

On Mandrake, we used the latest available kernel package (2.4.22-10mdk), but on Red Hat, we rebuilt the kernel the same way we built it for Debian. For rfcomm to work on RedHat and Mandrake, we followed these steps:

  1. Downloaded the following RedHat RPMs from http://bluez.sourceforge.net:

    • bluez-bluefw

    • bluez-hcidump

    • bluez-libs

    • bluez-pan

    • bluez-sdp

    • bluez-utils

  2. Next, we ran rpm --test -ivh bluez-* , and all looked well, so we installed them with rpm -ivh bluez-* .

  3. To make sure that the Bluetooth scripts were started on boot, we ran chkconfig --add bluetooth .

  4. We ran /etc/init.d/bluetooth start (we could also have rebooted).

  5. The /dev/rfcomm* devices did not exist, so we created them as shown in Example 7-4.

7.1.4 Troubleshooting

Generally, following the previous steps went smoothly, but we did run into some problems. Here are some tips that should help you out:


Start hcid in the foreground

By default, the startup scripts launch hcid in the background. If you want to see verbose messages from it, kill it and then start it with -n :

 #  killall hcid  #  hcid -n  

This helps you figure out what's going on with failed PIN requests .


Restart hcid after PIN changes

If you edit the PIN in /etc/bluetooth/pin , restart hcid ( killall -HUP hcid should do the trick).


Replace bluepin

In theory, the bluepin utility should either use the PIN in /etc/bluetooth/pin or prompt you when it needs a PIN. However, on Mandrake, the PIN exchange was silently failing. So, we replaced bluepin with a script that spat out the PIN in /etc/bluetooth/pin :

 #!/bin/sh # file: /usr/local/bin/bluepincat     echo -n "PIN:" cat /etc/bluetooth/pin 

Then we set the pin_helper line in /etc/bluetooth/hcid.conf :

 pin_helper /usr/local/bin/bluepincat 

Make sure the rfcomm module is loaded

When we installed Bluetooth support on Mandrake and Red Hat, the rfcomm module wasn't loaded automatically, so we received a complaint when we ran /etc/init.d/bluetooth start :

 "Can't open RFCOMM control socket: Address family not supported by protocol" 

So, we added modprobe rfcomm to the start( ) section of the /etc/init.d/bluetooth script and rebooted to make sure everything worked OK.


Double-check your kernel configuration

If you're compiling the kernel from source, be sure everything is configured the way it should be. For example, one of us was testing the examples in this chapter and received an Operation not supported error when we tried to make a connection over /dev/rfcomm0 . We hadn't configured RFCOMM TTY support ( CONFIG_BLUEZ_RFCOMM_TTY ) in the kernel. Well, we had, but it was configured as a module rather than statically compiled into the kernel. Although make menuconfig showed [*] , a peek inside our .config file showed:

 CONFIG_BLUEZ_RFCOMM_TTY=  m  

So we changed m to y , recompiled the kernel, installed it, and rebooted, and all was well.

 <  Day Day Up  >  


Linux Unwired
Linux Unwired
ISBN: 0596005830
EAN: 2147483647
Year: 2004
Pages: 100

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net