WebCam

Home Webcam
Home arrow Bluetooth
Bluetooth on Linux E-mail

For those of you interested, here is how i've got Bluetooth support on my SuSE 9.0 system.
Firstly, you need a bluetooth adapter. I went for a cheap USB adapter, and it was supported by the BLUEZ kernel drivers (http://www.bluez.org/)
Just do a regular download, ./configure make make install
So now your should have something like
bluez                  28612   7  [rfcomm bnep l2cap hci_vhci hci_uart hci_usb]
showing up as a kernel module.

Note: The following isn't finished. Just a quick way of displaying all my other configs:
Paul has also contributed the Palm side of things here, and on his SuSE 9.1 with 2.6 kernel got things working, see his notes lower down the page

/etc/bluetooth/hcid.conf
options {
autoinit yes;
security auto;
pairing multi;
pin_helper /bin/bluepincat;
}

device {
name "BlueZ (%d)";
class 0x100;
iscan enable; pscan enable;
lm accept,master;
lp hold,sniff,park,rswitch;
auth enable;
encrypt enable;
}

---------------------------------------------------
/etc/bluetooth/pin
1234
---------------------------------------------------
/etc/bluetooth/rfcomm.conf

rfcomm0 {
bind no;
device 00:05:xx:xx:xx:xx;
channel 3; #that't the channel that the T3 seems to be using
comment "t3"; #change that to what you want (no difference)
}

In pap-secrets & chap-secrets, I added in a blank entry:
"" * ""

---------------------------------------------------
/etc/ppp/peers/btpalm
noauth
local
proxyarp
nodefaultroute
noipx
idle 0
192.168.2.99:192.168.1.10
ms-dns 192.168.0.10
netmask 255.255.255.0
connect "sleep 1; echo -n CLIENTSERVER"
---------------------------------------------------
/etc/init.d/start_bluetooth.sh
#!/bin/bash

modprobe bluez
hciconfig hci0 up
hcid
/usr/sbin/sdpd
pand --listen --master --role=NAP
dund -s call btpalm


iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward


Make the devices:
#!/bin/sh
N=0
while [ $N -lt 255 ]
do
if [ -e /dev/rfcomm$N ] ; then
echo "/dev/rfcomm$N already exists"
else
echo "/dev/rfcomm$N being created"
mknod /dev/rfcomm$N c 216 $N
fi
N=`expr $N + 1`
done



A neat script to get things up and running
#!/bin/bash

# need the following lines for kernel 2.4, not for 2.6
uname -r | grep 2.4 > /dev/null
if [ $? == 0 ] ; then
modprobe bluez
hciconfig hci0 up
fi

N=`ps -ef | grep hcid | grep -v grep | wc -l`
if [ $N -ne 1 ] ; then
hcid
fi

N=`ps -ef | grep sdp | grep -v grep | wc -l`
if [ $N -ne 1 ] ; then
/usr/sbin/sdpd
fi

N=`ps -ef | grep pand | grep -v grep | wc -l`
if [ $N -ne 1 ] ; then
pand --listen --master --role=NAP
fi

N=`ps -ef | grep dund | grep -v grep | wc -l`
if [ $N -ne 1 ] ; then
dund -s call btpalm
fi

# create &fix /dev/rfcomm* devices
N=0
while [ $N -lt 9 ]
do
if [ -e /dev/rfcomm$N ] ; then
echo "/dev/rfcomm$N already exists"
else
echo "/dev/rfcomm$N being created"
mknod /dev/rfcomm$N c 216 $N
fi
N=`expr $N + 1`
done
chmod ugo+r /dev/rfcomm*



Also, thanks to Paul for this, on Palm you need to create the connection:

* Palm t3, latest firmware patch.
* prefs
   * bluetooth options
        -> choose a name for your palm (your hotsync name is good)
        -> trusted devices
        -> find the PC and pair with it
   * connections (http://howto.pilot-link.org/bluesync/eb.html)
        -> create a new connection
        -> set the following options
            Name: "btcon linux"
            Connect to: PC
            Via: Bluetooth
            Device: [your PCs BT trusted device name]
                -> Details
                   speed: 115,200 (probably irrelevant)
                   flow ctl: automatic
   * network (http://howto.pilot-link.org/bluesync/ec.html)
        -> create a new service
        -> set the following options (name MUST be different
        from the "btcon" name!)
            Service: btnet linux
            User name: blank
            Password: [prompt]
            Connection: btcon linux
                 -> Details
                    Connection type: ppp
                    Idle timeout: never
                    Query DNS: [checked]
                    IP address: [automatic]
                    -> script
                        just says "End:"

* install the WEBPRO browser off the PalmT3 disk.
* also recommended, the brilliant freeware "bluefang" program which will
allow you to automatically enable and disable bluetooth when certain
applications run.
http://palminfocenter.palmgear.com/index.cfm?fuseaction=software.showsoftware&prodid=65608


Updates (21/08/05)
After changing distro's to Slackware (which I'm a lot more comfortable with, since it does away with RPM and SuSE's way of things). I also went to a vanilla kernel from kernel.org (again a preference).

Unfortunately this has caused some bluetooth problems!
I can still connect to my two mobile phones via bluetooth (using rfcomm to create the virtual serial ports) and can query/use them and connect to the internet.
However, the connection from my PocketPC won't work any longer. I've tried many things, different kernel versions, module updates, etc but it keeps behaving as follows:

Initial bluetooth connection/pairing works as before.

Initial connection works, PDA connects, linux server starts pppd and assigns IPs to local/remote, the PDA can now be pinged over bluetooth from the linux box.

This lasts for approx 60 seconds, or if I try to transfer a large amount of data (stream music, graphic intensive website, etc) the connection hangs.

The pings stop, and nothing else passes over the BT link. Strangely, neither side shows/sees the hangup, so both believe the interface is still up/functioning.

The small LED on the bluetooth adapter (on the PDA) also doesn't show any flashes in time to the ping requests, so its not getting to the PDA from what I can tell.

After a minute PPPD then terminates due to lack of activity and brings the interface down. The PDA still hasn't disconnected, and I have to force it to disconnect.

At this point, the BT on the linux server has also become unresponsive and canot talk to any other BT devices that it could previously (my two mobile phones), and I have to rmmod all the bluetooth modules and re modprobe them to get BT up and running again.

Therefore I suspect its the kernel drivers/modules on the linux side of things causing the problem, but I cannot track them down as no errors appear to be reported. (I haven't enabled verbose logging however).
If you have any suggestions/ideas, please do get in touch! I'm very confused.



Updates (08/07/06)

Having changed distro to Debian, the bluetooth hardware operated easily after installation, without any tweaking of the kernel, etc, so bluetooth support is appearing more and more in stock kernel images, etc.
I've not yet tried to use it as a dialup again with my PDA, i'll post an update if I try this.
However, after getting a new bluetooth phone (Sony Ericsson W550i) I found that I couldn't use my bluetooth communication scripts to query the phone for battery life, signal strength, etc. This was a problem for me, as I used this interaction quite heavily (detecting I was home, checking strength and backing up my phonebook).
After a bit of googling, and finding that I could send AT commands under windows, I realised it was linux-specific. To solve it, I found that the channel the phone used wasn't default for its internal modem.
The way to find out the channels and services on the bluetooth destination is by using the command:
sdptool browse 00:16:xx:xx:xx:xx

Which will give you the capabilities, and also the correct channel, which in my case was channel 2, so to talk to it via rfcomm:
rfcomm bind 3 00:16:xx:xx:xx:xx 2

So I can then use the device /dev/rfcomm2 to talk to the phones internal modem, to query various information.

 

(C) 2008 thebmwz3.co.uk
Joomla! is Free Software released under the GNU/GPL License.