Sync Palm via Bluetooth

palmbluetooth

We have introduced how to synchronize Palm via IrDA, let’s move on to the next level: Synchronize Palm via Bluetooth.

Kernel matters

Linux kernel has built-in support for Bluetooth devices, you could build it into kernel or modules. The following configuration also includes the optional bluetooth headphone support, it does not hurt since everything is built into modules.

 Bluetooth subsystem support --->
 --- Bluetooth subsystem support
  L2CAP protocol support
  SCO links support
  RFCOMM protocol support
 [*] RFCOMM TTY support
  BNEP protocol support
 [*] Multicast filter support
 [*] Protocol filter support
  HIDP protocol support
 Bluetooth device drivers --->
  HCI USB driver
 [*] SCO (voice) support
  HCI UART driver

In the user land, we need to install BlueZ, the Linux Bluetooth protocol stack, in Gentoo, just

emerge bluez-libs bluez-utils

We need to modify /etc/bluetooth/hcid.conf to make it fit into our needs:

options {
 autoinit yes;
 security user;
 pairing multi;
 pin_helper /usr/bin/bluepin;
}
device {
 name "BlueZ (%d)";
 class 0x100;
 iscan enable; pscan enable;
 lm accept,master;
 lp hold,sniff,park;
 auth enable;
 encrypt enable;
}

bluepin is a PyGTK-based dialog to prompt the password, if you don’t install X or do not change the PIN whenever a new device is connected, you could just feed the pin directly like this [2]:

pin_helper /etc/bluetooth/pin;

in /etc/bluetooth/pin:

MY Personal Pin

OK, plugin the bluetooth adapter. Enable your Palm’s Bluetooth for the first test drive:

hcitool scan
Scanning ...
 00:07:E0:0E:B6:CC My Palm

OK, at least the Bluetooth adapter works, kernel modules loaded, and BlueZ take actions for the new device.

NOTE: For the curious users, please check /etc/udev/rules.d/70-bluetooth.rules

Tie a knot

In Palm side, create a new connection named “Bluetooth to PC” in Preference| Connection| New … like this, then click Device: Tap to find. If this is the first time to bind the handheld and desktop, bluepin will pop up and ask for the authentication token.

Discover and Bind
Discover and Bind

Then create a new Network in Preference| Network| New, click Details …, then click Script …, and delete all scripts, like this:

Network setting
Network setting

The light of the tunnel

Bluetooth synchronization is quite different than the previous two local HotSync, it is a Modem HotSync via dial-up network on bluetooth tunnel. We need to build the dial-in server in Linux side:

Build the kernel modules in Device Drivers| Networking Support

 PPP (point-to-point protocol) support
[ ] PPP multilink support (EXPERIMENTAL)
[ ] PPP filtering
 PPP support for async serial ports
 PPP support for sync tty ports
 PPP Deflate compression
 PPP BSD-Compress compression
 PPP over Ethernet (EXPERIMENTAL)
...

In the user land, install the ppp package and enable the ip forwarding:

emerge ppp
echo 1 > /proc/sys/net/ipv4/ip_forward

Set up the peer-to-peer network, /etc/ppp/peer/dun

noauth
local
noipdefault
proxyarp
nodefaultroute
noipx
idle 0

# Host IP: target IP
192.168.15.100:192.168.15.88

ms-dns 192.168.15.1
netmask 255.255.255.0

Gentoo’s magic bluetooth service would launch the following service for us:

  • hcid: the Host Control Interface daemon to talk with L2CAP kernel module.
  • sdpd: the Service Discovery Profile daemon to discover nearby bluetooth devices.
  • pand: the Personal Area Network daemon to organize an Ad-Hoc PAN.
  • dund: Dial-up Network daemon to build a virtual serial link for dial-up network.
  • pppd: Point-to-Point Protocol daemon

Edit the /etc/conf.d/bluetooth:

# Bluetooth configuraton file
# Start of hcid (allowed values are "true" and "false")
HCID_ENABLE=true
# Config file for hcid
HCID_CONFIG="/etc/bluetooth/hcid.conf"
# Start sdpd (allowed values are "true" and "false")
SDPD_ENABLE=true
# Start hidd (allowed values are "true" and "false")
HIDD_ENABLE=false
# Arguments to hidd
HIDD_OPTIONS=""
# Run hid2hci (allowed values are "true" and "false")
HID2HCI_ENABLE=false
# Bind rfcomm devices (allowed values are "true" and "false")
RFCOMM_ENABLE=true
# Config file for rfcomm
RFCOMM_CONFIG="/etc/bluetooth/rfcomm.conf"
# Start dund (allowed values are "true" and "false")
# If you want to use dund, you must install: net-dialup/ppp .
DUND_ENABLE=true
# Arguments to dund
DUND_OPTIONS="--listen --persist --msdun call dun"
# Start pand (allowed values are "true" and "false")
PAND_ENABLE=true
# Arguments to pand
PAND_OPTIONS="--listen --role NAP"

Once the bluetooth adapter is plugged in, the corresponding services are launched, you can test the connection with either Merge Ping, or use the command line: Preference| Network| Option| View Log, then write ping example.com.

The last, but not the least

In HotSync | Options | Modem Sync Prefs…, highlight Network. In HotSync | Options | Primary PC Setup…

  • Primary PC Name: leave blank
  • Primary PC Address: IP Address of the computer
  • Subnet Mask: Netmask of your network

NOTE Primary PC Name is parsed by the DNS, the best practice is to leave it blank.

When HotSync, select Modem and Unix as the network. In the desktop side, use net:any to replace /dev/pilot in the previous HotSync settings.

Reference

  1. Synchronize your PalmOS Handheld over Bluetooth in Linux
  2. HOWTO mobile phone, Bluetooth and GNOME
  3. [HOWTO] Bluetooth and Palm (or PocketPC) Network and Sync