Got the bluez

August 2, 2006 9:35pm

One of the neat things about my Treo 650 is that it has Bluetooth. To date, the only thing I ever used bluetooth for was a wireless earpiece, so that I could enjoy hands-free convenience while using my mobile phone. Bluetooth can do a whole lot more than that, but I've never had the gadgets or the need to try them.

My PowerBook has built-in Bluetooth, and a nice graphical program to manage Bluetooth devices and services. I can transfer files between the PowerBook and the Treo with point-and-click convenience. I can also use the Treo as a modem, to give the PowerBook internet access in situations where wired and wireless LAN are unavailable. The speed is slow compared to today's broadband standards, but in many situations slow access is better than no access. I followed this tutorial, and everything worked on the first try.

I have a PowerBook, but I don't use it nearly as much as I could. Instead, I rely on my Averatec running Ubuntu for the bulk of my day-to-day computing. If I'm going to travel, I'm almost certainly going to take the Linux laptop, so Bluetooth on the PowerBook is nice but not something on which I'll rely.

I purchased an el cheapo USB Bluetooth adapter, and set to figuring out how to do in Linux everything that I can do with the PowerBook.

HotSync

The first order of business was to try to sync the Treo with my laptop over Bluetooth. I used several different resources to get started. Most of what I found online assumed a Fedora-based system, so I needed to figure out what changes were necessary in Ubuntu. Useful links include Synchronize your PalmOSĀ® Handheld over Bluetooth in Linux at the pilot-link site; Syncing the Treo 650 with Bluetooth from LinuxJournal; and Bluetooth HotSync with Linux from Ian Burrell's blog.

The Surf the Web with Bluetooth section of the pilot-link howto never worked for me. I was able to make a TCP connection over Bluetooth from the Treo to the laptop, but I could never get Blazer, the Treo's browser, to actually deliver any pages to me; even though Mergic Ping (at the bottom of that page) was able to ping internet addresses.

skippy@skippy:~$ hciconfig dev
hci0: Type: USB
BD Address: 00:10:60:D1:4D:78 ACL MTU: 384:8 SCO MTU: 64:8
UP RUNNING PSCAN ISCAN
RX bytes:40459 acl:596 sco:0 events:667 errors:0
TX bytes:35929 acl:611 sco:0 commands:32 errors:0
skippy@skippy:~$ hcitool scan
Scanning ...
00:07:E0:62:58:EA skippy
skippy@skippy:~$ sudo hcitool info 00:07:E0:62:58:EA
Password:
Requesting information ...
BD Address: 00:07:E0:62:58:EA
Device Name: skippy
LMP Version: 1.1 (0x1) LMP Subversion: 0x700
Manufacturer: Broadcom Corporation (15)
Features: 0xbf 0xfe 0x0d 0x00 0x00 0x00 0x00 0x00
<3-slot packets> <5-slot packets> <encryption> <slot offset>
<timing accuracy> <role switch> <sniff mode> <RSSI>
<channel quality> <SCO link> <HV2 packets> <HV3 packets>
<u-law log> <A-law log> <CVSD> <power control>
<transparent SCO>

I didn't need to make any kernel modifications on my Dapper Drake installation, and most of the example commands worked as expected. The big difference on Ubuntu is that the bluez-utils package bundles both the dund and pand services. Use /etc/default/bluez-utils to configure the basics:

# Defaults for bluez-utils

# This file supersedes /etc/default/bluez-pan. If
# that exists on your system, you should use this
# file instead and remove the old one. Until you
# do so, the contents of this file will be ignored.

############ HIDD
#
# To have Bluetooth mouse and keyboard support, get the
# Linux 2.6.6 patch or better from bluez.org, and set
# HIDD_ENABLED to 1.
HIDD_ENABLED=0
HIDD_OPTIONS="--master --server"
# to make hidd always use a particular interface, use something
# like this, substituting the bdaddr of the interface:
# HIDD_OPTIONS="-i AA:BB:CC:DD:EE:FF --server"
#
# remove '--master' if you're having trouble working with Ericsson
# T630 phones with hidd operational at the same time.

############ COMPATIBILITY WITH OLD BLUEZ-PAN
# Compatibility: if old PAN config exists, use it
# rather than this file.
if test -f /etc/default/bluez-pan; then
. /etc/default/bluez-pan
return
fi
############

############ DUND
#
# Run dund -- this allows ppp logins. 1 for enabled, 0 for disabled.
DUND_ENABLED=1

# Arguments to dund: defaults to acting as a server
DUND_OPTIONS="--listen --persist --msdun call treo"

############ PAND
#
# Run pand -- ethernet: creates new network interfaces bnep# that can be configured in /etc/network/interfaces
# set to 1 for enabled, 0 for disabled
PAND_ENABLED=0

# Arguments to pand
# Read the PAN howto for ways to set this up
# http://bluez.sourceforge.net/contrib/HOWTO-PAN
PAND_OPTIONS="--listen --role GN"

The --msdun call treo bit in the DUND_OPTIONS specifies the name of a file in /etc/ppp/peers/ to use to control the PPP connection.

skippy@skippy:~$ cat /etc/ppp/peers/treo
115200
noauth
local
debug
10.10.13.13:10.10.13.14
ms-dns 127.0.0.1

I use dnsmasq as a local DNS resolver (see here for an Ubuntu-specific guide to dnsmasq). If you're not using a local DNS cache, modify the ms-dns line above to define the IP address of your DNS server.

The two IP addresses -- 10.10.13.13:10.10.13.14 -- define the IP address to assign to each end of the point-to-point link. The first address is used by the laptop, and the second address is used by the Treo. Make sure these are unique and not in use on your network. Ideally they should be addresses in a completely separate subnet.

Configure a modem hotsync connection on your Treo following the example in the pilot-link howto. When you're done, everything should work:

skippy@skippy:~/Treo$ pilot-xfer -p net:any -l


Listening to port: net:any

Please press the HotSync button now... Connected

Reading list of databases in RAM...
lockbox
Blazer Bookmarks
CarrierProfiles2
DefaultHelperDB
ContactsDB-PAdd
CalendarDB-PDat
MemosDB-PMem
...
AddressTitlesDB
BtDeviceLibraryUserDeviceDB
USBClientBulverdeIntel

List complete. 119 files found.
Time elapsed: 0:00:20

Dial-Up Networking

I had a wee bit more trouble getting Dial-Up Networking to work over Bluetooth to my Treo. Using Linux and Bluetooth DUN on the Treo 650 at Guru Labs was the most helpful document. Many of the other HOWTOs I read were entirely too complicated.

You may or may not need to twiddle the hcid.conf file. Here's my /etc/bluetooth/hcid.conf:

skippy@skippy:~$ cat /etc/bluetooth/hcid.conf
#
# HCI daemon configuration file.
#

# HCId options
options {
# Automatically initialize new devices
autoinit yes;

# Security Manager mode
# none - Security manager disabled
# auto - Use local PIN for incoming connections
# user - Always ask user for a PIN
#
security auto;

# Pairing mode
# none - Pairing disabled
# multi - Allow pairing with already paired devices
# once - Pair once and deny successive attempts
pairing multi;

# PIN helper
pin_helper /usr/bin/pinwrapper;

# D-Bus PIN helper
#dbus_pin_helper;
}

# Default settings for HCI devices
device {
# Local device name
# %d - device id
# %h - host name
name "%h-%d";

# Local device class
class 0x3e0100;

# Default packet type
#pkt_type DH1,DM1,HV1;

# Inquiry and Page scan
iscan enable; pscan enable;

# Default link mode
# none - no specific policy
# accept - always accept incoming connections
# master - become master on incoming connections,
# deny role switch on outgoing connections
lm accept;

# Default link policy
# none - no specific policy
# rswitch - allow role switch
# hold - allow hold mode
# sniff - allow sniff mode
# park - allow park mode
lp rswitch,hold,sniff,park;

# Authentication and Encryption (Security Mode 3)
#auth enable;
#encrypt enable;
}

I don't think I needed the pinhelper bit, bit maybe I did and have already forgotten. :( Note that I did not need to enable auth and encrypt.

Here's my /etc/bluetooth/rfcomm.conf:

skippy@skippy:~$ cat /etc/bluetooth/rfcomm.conf
#
# RFCOMM configuration file.
#
rfcomm0 {
bind yes;
device 00:07:E0:62:58:EA;
channel 1;
comment "treo";
}

Insert the ID of your Treo, unless you're near me and want to leech free internet from my phone...

The next bits were where I went astray initially. Ubuntu doesn't use the same graphical network configuration system as Fedora, so I mistakenly thought that using a GUI would be complex. Using the Palm Treo 650 with Debian provided console-based configuration advice for a Debian system. Since Ubuntu is derived from Debian, I thought this would be the tutorial to follow. It helped, but my complete lack of experience with modems in Linux introduced a few hurdles. The chatscripts threw me for a loop, too.

Using the previous howtos as basic reference, here's how I configured Ubuntu to use my Treo for internet access.
Click System -> Administration -> Networking.configuring PPP on Ubuntu for Dial-Up Networking with a Treo 650Select the modem connection (assuming you don't actually use a modem for regular internet access), and click Properties.configuring PPP on Ubuntu for Dial-Up Networking with a Treo 650You can fill any information you want into the name and password field, as clarified in the GuruLabs howto.configuring PPP on Ubuntu for Dial-Up Networking with a Treo 650configuring PPP on Ubuntu for Dial-Up Networking with a Treo 650

I initially had problems connecting, so I used the chatscripts from newt.com and came up with this for /etc/chatscripts/ppp0:

skippy@skippy:~$ cat /etc/chatscripts/ppp0
TIMEOUT 60
ABORT ERROR
ABORT BUSY
ABORT VOICE
ABORT "NO CARRIER"
ABORT "NO DIALTONE"
ABORT "NO DIAL TONE"
ABORT "NO ANSWER"
"" "ATZ"
OK "ATDT#777"
TIMEOUT 20
CONNECT ' '

Executing sudo ifup ppp0 produced the following in /var/log/messages:

Aug 2 20:38:43 localhost pppd[13926]: pppd 2.4.4b1 started by root, uid 0
Aug 2 20:38:45 localhost chat[13936]: timeout set to 60 seconds
Aug 2 20:38:45 localhost chat[13936]: abort on (ERROR)
Aug 2 20:38:45 localhost chat[13936]: abort on (BUSY)
Aug 2 20:38:45 localhost chat[13936]: abort on (VOICE)
Aug 2 20:38:45 localhost chat[13936]: abort on (NO CARRIER)
Aug 2 20:38:45 localhost chat[13936]: abort on (NO DIALTONE)
Aug 2 20:38:45 localhost chat[13936]: abort on (NO DIAL TONE)
Aug 2 20:38:45 localhost chat[13936]: abort on (NO ANSWER)
Aug 2 20:38:45 localhost chat[13936]: send (ATZ^M)
Aug 2 20:38:46 localhost chat[13936]: expect (OK)
Aug 2 20:38:46 localhost chat[13936]: ATZ^M^M
Aug 2 20:38:46 localhost chat[13936]: OK
Aug 2 20:38:46 localhost chat[13936]: -- got it
Aug 2 20:38:46 localhost chat[13936]: send (ATDT#777^M)
Aug 2 20:38:46 localhost chat[13936]: timeout set to 20 seconds
Aug 2 20:38:46 localhost chat[13936]: expect (CONNECT)
Aug 2 20:38:46 localhost chat[13936]: ^M
Aug 2 20:38:50 localhost chat[13936]: ATDT#777^M^M
Aug 2 20:38:50 localhost chat[13936]: CONNECT
Aug 2 20:38:50 localhost chat[13936]: -- got it
Aug 2 20:38:50 localhost chat[13936]: send ( ^M)
Aug 2 20:38:50 localhost pppd[13926]: Serial connection established.
Aug 2 20:38:50 localhost pppd[13926]: Using interface ppp0
Aug 2 20:38:50 localhost pppd[13926]: Connect: ppp0 < --> /dev/rfcomm0
Aug 2 20:38:51 localhost pppd[13926]: local IP address 68.30.241.136
Aug 2 20:38:51 localhost pppd[13926]: remote IP address 68.28.153.69
Aug 2 20:41:21 localhost pppd[13926]: No response to 4 echo-requests
Aug 2 20:41:21 localhost pppd[13926]: Serial link appears to be disconnected.
Aug 2 20:41:21 localhost pppd[13926]: Connect time 2.5 minutes.
Aug 2 20:41:21 localhost pppd[13926]: Sent 19684 bytes, received 168518 bytes.
Aug 2 20:41:21 localhost pppd[13926]: Connection terminated.
Aug 2 20:41:21 localhost ifplugd.agent[14057]: Stopping ifplugd for ppp0

To my delight, it worked! I confirmed everything was working by turning off the wireless LAN. I executed sudo ifup ppp0 again, pointed Firefox to http://www.whatismyip.org/, and confirmed that the IP address displayed was not the static IP assigned to my DSL provider. Success!

If you have any suggestions for improvement, or other Bluetooth tips or tricks, feel free to share them in the comments.


Leave a comment

Tags used: general technology

a Flickr photoa Flickr photoa Flickr photo