YouTube On the Go

Development, Gentoo, Palm, Python April 15th, 2007

Everybody loves YouTube, the hub of short video clips uploaded by the users. It makes more sense to watch YouTube clips than King Kong in the Metro. To watch one small clip, you need to:

  1. Install VideoDownloader Firefox Extension
  2. Download the video clips to the harddisk
  3. Manually convert the .flv to .avi using ffmpeg like this ffmpeg -i foo.flv foo.avi
  4. Copy to the Treo 650′s extension card

That is quite tedious. I need a tool to automate the above procedures, here come the tubefetch.txt:

$ ./tubefetch.py –help
TubeFetch: Download the video clips from YouTube
Version 0.1.0. developed by Kun Xi <kunxi@kunxi.org>
Usage: tubefetch.py [options] files …
                       
Examples:
  tubefetch.py -c http://the-url http://the-url2 …

Options:
  -h –help          print this information
  -v –version       version information
  -c                 convert the flv file to avi, needs ffmpeg

This script would download the flv files and convert them to avi file automatically, then copy the files to Treo 650 using CardReader, CardExport.

A better solution may go further:

  • Develop a Firefox addon: one-click would download/convert the file to the specified path
  • Develop a KPilot conduit, download the AVI files to Treo 650′s extension card when HotSync

Well, if I persist the enthusiasm for 3 months, I might roll up the sleeves and go through all the way to do so.

Update The DownloadHelper plugin is exactly what I am looking for. The author does not address the CJK file name issue, here is the modified version to bypass that problem.

Make it work

Desktop, Gentoo, Palm February 12th, 2007

The KPilot 3.5.5 once worked fine for my Tungsten T, and it still served for the Treo application installation and backup. Unfortunately, the KPilot could not synchronize the TODO or calendar, the kpilotDaemonn just crashed without a trace, in fact that is my fault, the konqi is not installed in my system.

KPilot developers have released 3.5.6, and claimed that it has solved lots of long-lasting bug, including my patch as well. However, the KPilot 3.5.6 depends on >=pilot-link-12.0, while pilot-link is buggy for the python and java binding, which is reverse-dependency of JPilot. Anyway, all of them are masked.

Tim told us “Make it work”, let’s roll the sleeves.

In Gentoo’s bugzilla, #89823 is attached an unofficial ebuild for pilot-link, just copy it to pilot-link-0.12.2. Since we don’t really need the python or java binding, just disable the use flag in package.use and leave the patch where is.

Next, build kpilot-3.5.6, it would not compile for GCC 4.1.1. Em, interesting. The bug is straight-forward anyway, the compiler is just picky in doing const cast. With this patch, it works.

UPDATE Just contacted with kpilot developer, pilot-link has changed the interface in the version bump, so kpilot 3.5.6 is supposed to work fine with pilot-link-0.12.[01], this patch is for pilot-link-0.12.2 only.

Let’s put the pieces together:
pilot-link-0.12.2 ebulild, kpilot-3.5.6 ebuild, kpilot-3.5.6-const.patch

Now, KPilot 3.5.6 works fine, but put duplicated appointment when HotSync with Treo 650. That is quite annoying, I would like to use Undup as the work around, then dig into the code later.

One is better than two

Palm February 9th, 2007

After 2 weeks eBay hunting, I won a unlocked Treo 650 GSM smartphone eventually, I no longer need to carry my shabby Tungsten T and Nokia phone, one is better than two.

This gadget is powered by PalmOS v5.4, Treo Software 1.7b, Firmware 1.51. Palm Inc has recently released one ROM update for the unlocked phone, SW 1.20 for bug fix. I decided to keep up with the service pack. The stability of Treo 650 has always been an issue in the sphere.

I chose the ROM from Hi PDA forum, the localization and candies for the newbies have been ripped off to optimize the DB Cache. Download, unpack, copy to the SD Card, hard-reset the device, plugin the card, pray, pray…, after several reboot, the device is updated and the phone is still usable, unlocked.

Treo 650 phone info


When Palm meets Linux

Desktop, Gentoo, Palm October 15th, 2006

Palm is an open platform for handheld computing, especailly PIM. However, the Palm Inc. / Access do not provide any official support for Linux. Thanks to the open source community to bridge the gap between Linux desktop and Palm handheld.

When Palm meets Linux
Dell Inspiron 700m, Palm Tungsten T, Syba USB Bluetooth Adapter, and Palm Sync cable(not shown in the picture).


Synchronization

Palm supports various synchronization accesses, serial, USB, IrDA, Bluetooth, Modem, Lan, Wireless. We would address three most commonly used ways.

USB Synchronization
This is the most common and reliable way to synchronize the device with the desktop.
1. Besides the standard USB support, build USB Serial(usbserial) and USB Handspring driver(visor) drivers into modules.

<M> USB Serial Converter support
<M>   USB Handspring Visor / Palm m50x / Sony Clie Driver

2. Update the udev rule in /etc/udev/rules.d/10-palm.rules:

# Palm Tungsten T
BUS=="usb",SYSFS{product}=="Palm Handheld",NAME="pilot"

If you use Sony’s CLIE or Handspring’s Visor, you may take a look at cat /proc/bus/usb/devices to figure out how to identify the device. After you push the button of HotSync cradle, or click the BIG button in HotSync application, the device appears as /dev/pilot in Linux desktop.

IrDA Synchronization
Here is a detailed HOWTO about IrDA Synchronization.

Bluetooth Synchronization
Check this HOWTO.

Integration with KDE

TBD

Developement

TBD

Existed problems

  • KPilot does not convert the string from UTF-8 to zh_CN.gbk back and forth in synchronization (FIXED)
  • Mail plugin works only for legacy Palm mail

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