Third party cookies may be stored when visiting this site. Please see the cookie information.

Linux Bluetooth Networking Tutorial (Ubuntu)

This is an article I wrote some time ago for the PenguinTutor tutorial pages.

As I am updating the tutorials and this is now too dated to be of use in the main tutorial (What's a Palm PDA I hear you ask) but was something I thought was worth saving in case it was required in future.

Linux Bluetooth Networking Tutorial (Ubuntu)

This explains the steps that required to enable Bluetooth Networking using Ubuntu. The final goal to allow web browsing on a palm using bluetooth, sharing a broadband connection on the linux machine. 

 

This was carried out using Ubuntu 4.10 "The Warty Warthog" and using a Palm Tungsten T3 (PalmOS version 5 and WebPro). Both the linux machine and the palm machine were working systems so may have varied slightly from a vanilla install. If using other distributions of linux, or different palm devices then the instructions may differ. The bluetooth was provided using an unbranded bluetooth USB dongle. I believe this is the same as the "Acer" dongle. The dongle / bluetooth device must be supported by the bluez drivers.

 

Getting started

Insert the bluetooth dongle. 

Using the Synaptic Package Manager Install 

 

 

The kernel must be at least 2.4 (or have the blueZ patches installed), this is the case for Ubuntu, and most other recent distributions. 

 

Basic Bluetooth Config

 

 

Check that the bluez module is loaded 

 

$ lsmod | grep blue 

bluetooth 44036 7 rfcomm,l2cap,hci_usb 

 

If this does not show the bluetooth device then you may need to reboot, although unlikely.  

You can then see the interface 

 

$ hciconfig 

hci0: Type: USB 

BD Address: 00:04:3E:40:6C:FD ACL MTU: 1356:5 SCO MTU: 48:1 

UP RUNNING PSCAN ISCAN 

RX bytes:101 acl:0 sco:0 events:13 errors:0 

TX bytes:300 acl:0 sco:0 commands:13 errors:0 

 

You can use  

hciconfig -a 

to see more details, and if the status is not showing as up using hciconfig hci0 up to activate it.

 

 

Bluetooth Pairing

 

Ensure that the Palm is switched on, and that bluetooth is enabled (under prefs bluetooth on the palm). 

 

You can scan for the device using: 

 

$ hcitool scan 

Scanning ... 

00:07:E0:30:9A:76 Palm 

 

The address shown is of the palm device (and Palm will be replaced with the name of your device). 

This value will be needed later when we come to setting up ppp. 

 

 

The PIN for the computer is stored in /etc/bluetooth/pin

it's default is 1234 (this may differ on other systems) 

 

On Palm Prefs -> Communication (Bluetooth)

(assuming status "on") Choose Trusted Devices Add Device - Show Current Discovery

It should show the linux machine's hostname. Select and it will prompt for PIN (see above). 

The devices are now paired 

 

Setup the basic bluetooth connection

 

The sdpd daemon is required to tell the palm what services are provided by the 

linux machine. Check sdpd daemon is running (using ps -ef | grep sdpd)

 

Check it is setup to act as a LAN 

 

$ sdptool get Lan 

Service Name: SDP Server 

Service Description: Bluetooth service discovery server 

Service Provider: BlueZ 

Service RecHandle: 0x0 

Service Class ID List: 

"SDP Server" (0x1000) 

Protocol Descriptor List: 

"L2CAP" (0x0100) 

PSM: 1 

Version: 0x0001 

Language Base Attr List: 

code_ISO639: 0x656e 

encoding: 0x6a 

base_offset: 0x100 

 

On palm create a "connection" from the prefs 

 

Name - something appropriate 

Connect to - PC 

Via - Bluetooth 

Device - Select previously paired device 

OK 

 

The rfcomm provides the basic connectivity layer 

 

sudo rfcomm bind 0 00:07:E0:30:9A:76 1 

 

address taken from hcitool scan 

The command format is rfcomm <devnum> <bdaddr> [<channel>]. You may see documentation referring to this as a daemon rfcommd, but this is outdated as it is now included in the kernel.

 

You can view this entry  

 

$ rfcomm -a 

rfcomm0: 00:07:E0:30:9A:76 channel 1 clean 

 

This can be added permanently by editing the file /etc/bluetooth/rfcomm.conf

 

Create file /etc/ppp/peers/bluetooth.options

with the following: 

 

# /etc/ppp/bluetooth.options 

 

# Increase debugging level (same as -d). The debug output is written 

# to syslog LOG_LOCAL2. 

# debug 

 

# noauth means do not require the peer to authenticate itself, this must 

# be set if you want to use pppd to connect to the internet. In this case 

# *you* must authenicate yourself to the peer(internet provider), so do 

# not disable this setting unless you are the dial-in server which where 

# the peer has to autenticate to. 

noauth 

 

# Specifies that pppd should use a UUCP-style lock on the serial device 

# to ensure exclusive access to the device. 

lock 

 

# Connect without using a modem 

local 

 

# async character map -- 32-bit hex; each bit is a character 

# that needs to be escaped for pppd to receive it.  0x00000001

# represents '\x01', and 0x80000000 represents '\x1f'. 

asyncmap 0 

 

# Don't fork to become a background process (otherwise pppd will do so 

# if a serial device is specified). 

# nodetach 

 

# Specifies that pppd should disconnect if the link is idle for n seconds. 

idle 600 

 

# Disable the IPXCP and IPX protocols. 

noipx 

 

# Specify which DNS Servers the incoming Win95 or WinNT Connection should use 

# Two Servers can be remotely configured 

 

# set your own dns server here, otherwise on the palm 

# ms-dns 141.3.71.12 

 

# wait for client to re-initiate a connection 

passive  

silent  

 

# the two addresses to use for the client and the local ppp interface 

192.168.1.1:192.168.1.2 

 

You may need to add a ms-dns entry (unless you define this manually in the palm). 

You can normally use the entries from /etc/resolv.conf

 

Now edit /etc/default/bluez-utils to point to this file, when an attempt is made to establish a ppp connection.

 

Find the entry DUND_ENABLED=0, and change it to DUND_ENABLED=1

 

Find the entry  

DUND_OPTIONS="--listen --persist" 

and change it to 

DUND_OPTIONS="--listen --persist --msdun call dun" 

 

Then restart the bluez-utils 

sudo /etc/init.d/bluez-utils restart 

 

Firewall

 

You then need to configure iptables to provide NAT 

 

Details are at www.iptables.org.

I hope to provide some better details soon. 

 

 

Webbrowsing / Email from Palm

You should now set webpro and versamail to use your new network connection, and  

you should be able to access the Internet. 

 

 

Further Reading

manpages: lsmod(1) 

IP Tables Web Site

 

 

Credits

 

 


» PenguinTutor Facebook page