Sync Palm via Bluetooth

Palm October 13th, 2006

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.

<M>   Bluetooth subsystem support  —>
 — Bluetooth subsystem support
      <M>   L2CAP protocol support
      <M>   SCO links support
      <M>   RFCOMM protocol support
      [*]     RFCOMM TTY support
      <M>   BNEP protocol support
      [*]     Multicast filter support
      [*]     Protocol filter support
      <M>   HIDP protocol support 
            Bluetooth device drivers  —>
                <M> HCI USB driver                                                 
                [*]   SCO (voice) support
                <M> 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 0×100;
    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 adpater. 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 to demystify the magic.

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 would popup to ask for the authentification token.

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


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 dail-in server in Linux side:

Build the kernel modules in Device Drivers | Networking Support


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

In the userland, 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 Arean 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 adpater 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 www.foo.com

The last, but not the least

In HotSync | Options | Modem Sync Prefs…, hightlight 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

Sync Palm via IrDA

Desktop, Gentoo, Palm August 3rd, 2006

I have complained the lame Palm Sync socket for quite a long time, eventually, I decide to try HotSync my Palm via IrDA on my Dell Latitude D600, which is equipped with SMSC IrDA Controller.

Prepare Hardware

The very first thing is to enable IrDA in the BIOS setting, since D600 has a COM1 serial port, IrDA is then assigned to COM2, aka /dev/ttyS1 in Linux.

BIOS setting



Boot to the overweighted Windows XP, and check the IRQ/DMA/SIR/FIR in Device Manager.

Device Manager


The findchip in irda-utils package is supposed to probe the system, unfortunately, it does not work in D600.

Build the Kernel

Just follow this HOWTO to build IrDA modules.

— IrDA (infrared) subsystem support
—   IrDA protocol
<M>  IrLAN protocol
<M>  IrNET protocol
<M>  IrCOMM protocol
[*]   Ultra (connectionless) protocol
—   IrDA options
[*]   Cache last LSAP
[*]   Fast RRs (low latency)

— SIR device drivers                 
<M> IrTTY (uses Linux serial driver)
<M> IrPORT (IrDA serial driver)     
— FIR device drivers                 
<M> SMSC IrCC (EXPERIMENTAL)

SIR stands for Standard IR, which uses generic serial protocol to talk with IrDA; FIR needs specific driver to achieve Fast IR. Although IrLAN and IrNET are rarely used, it does not hurt to build them as modules.

Test drive

Since /dev/ttyS1 is also driven by serial, we need explicitly to tell the kernel this device is controlled by irda:

sudo setserial /dev/ttyS1 uart none

Then configure the module options in a Gentoo way, put the information collected from Windows into /etc/modules.d/irda:

options smsc-ircc2 ircc_irq=3 ircc_dma=3 ircc_sir=0×2f8 ircc_fir=0×280
alias irda0 smsc-ircc2

run modules-update to refresh the environment.

Insert the necessary modules and bind the device and port together:

sudo modprobe smsc-ircc2
sudo modprobe irda
sudo modprobe rcomm
sudo modprobe ircomm_tty
sudo /usr/sbin/irattach irda0 -s

Open another console and run

sudo irdadump

If everything is OK, some packets are dumped when the Palm is close to the laptop’s IR port.

Sync the Palm

I am using korganizer/kontact/kpilot suite. Configure the Pilot device as /dev/ircomm0[1]; Uncheck Do not sync when screensaver is active, this is essential for the lightweight WM(e.g FVWM, Fluxbox) users. Bingo !

Glue the pieces together

Inspired by Gentoo official irda init script and this. I develops the /etc/init.d/irda-fir, and /etc/conf.d/irda-fir. Add irda-fir to default runlevel if Palm is a part of your life.

Further work

[1] Are we still using the high-speed FIR if the kopete is configured to access /dev/ircomm0? Since FIR maps IR port to the network interface, irda0, I have tried to configure the Pilot devcie to net:irda0 or net:any according to this undocumented hack, but it does not work and kpilot hangs sometimes.

I still prefer the USB sync when downloading huge files for the sake of speed. Any idea to make dbus/ivman to link /dev/pilot to /dev/ircomm0 or /dev/ttyUSB0 automatically?

Is Google Browser Sync Plugin a troublemaker?

Gentoo July 23rd, 2006

I just installed Google Browser Sync a few days ago, to manage my Firefox profiles across the computers, one in Gentoo, one in Windows XP(VMWare), one in Mac. Today, after the upgrade the world, the firefox failed to launch with this error message:

bookstack@tiger ~ $ firefox
No running windows found
firefox-bin exited with non-zero status (1)

Have I broken something in the upgrade? I double checked the emerge log via genlop, and found nothing relavent. Then I check the strace output:

bookstack@tiger ~/.mozilla/firefox $ strace -e stat64 firefox
… …
stat64(“/home/bookstack/.firefox/*/compreg.dat”, 0xbfefb368) = -1 ENOENT (No such file or directory)
stat64(“/home/bookstack/.firefox/*/chrome.rdf”, 0xbfefb368) = -1 ENOENT (No such file or directory)

It is quite strange that the Firefox would check $HOME/.firefox, it is supposed to check $HOME/.mozilla/firefox instead. There must be something wrong with the current profile. Here we are, the $HOME/.mozilla/firefox/profiles.ini is truncated to zero bytes! Once this is fixed, Firefox works again.

I don’t want to FUD Google Browser Sync, but it is the only relavent change about Firefox. If you have met the same problem, could you drop a comment here? I might need to dig into the source code before jumping to a conclusion.

Lame Tungsten T’s Sync

Palm September 19th, 2005

I have a Palm powered device, Tungsten T. This device is released to fill the gap between the classical PalmOS4 and legendary PalmOS6 aka Garnet. As the first generation OS5 device, no SSL support, digitization drift prone, short battery life… nevertheless, the device itself is still solid for daily user, while the connection to the external world is really pain of the ass.

  • The Palm. Inc prefers the same sophisticated socket for the power adapter and the USB cradle is not the standard accessory. I have to put the device leaning on the wall when charging. Thank you, the gravity.
  • The Sync cable really drives me nuts. The connection depends on the pin-to-pin hitting, why not use the standard USB socket?