JBlueZ on the HP iPAQ hx4700

(23 November 2005)

The following assumes you're already running Familiar Linux on your iPAQ hx4700. I obtained Familiar from http://sdgsystems.com/pub/ipaq/hx4700/starterkit/current, but you may know of other sources.

The work documented here was required due to JBlueZ's dependency on JNI; a shared library is used to interface between the JVM and the native BlueZ library. This shared library ties JBlueZ to the x86 Linux platform, for which is was designed. I wanted to use JBlueZ on my Linux-enabled iPAQ instead.

Java

Blackdown Java 1.3.1 is available for the iPAQ, if you download the arm distribution. For the sake of simplicity, I extracted this and placed it all under /usr/local/ on the iPAQ.

The toolchain

You need a compiler which can create binaries targetted for the appropriate platform. I downloaded the toolchain which is available at ftp://ftp.handhelds.org/projects/toolchain/ (namely, arm-linux-gcc-3.3.2.tar.bz2). As with Java, I extracted and placed all this into /usr/local/.

JBlueZ

JBlueZ is designed to interface with the BlueZ stack incorporated into Linux. It can be downloaded via http://jbluez.sf.net/. Place this distribution somewhere convenient -- the only truly important parts are the contents of the bin/ directory (which contains the .so file which we will be generating). I worked under /tmp/, and will use this in any following examples.

libbluetooth

For the compilation process, the libbluetooth libraries which reside on the iPAQ must be pulled onto your host machine. This is as simple as: mkdir /tmp/libbluetooth && scp root@ipaq:/lib/libbluetooth* /tmp/libbluetooth/

Modification of sources

The JBlueZ sources require a little fixing, but not much at all. In the order I tackled them then:

  1. Add to the CFLAGS line in /tmp/jbluez/src/c/Makefile the following: -barm-linux -mcpu=xscale -L/tmp/libbluetooth
  2. Make sure the target Java platform is set correctly in /tmp/jbluez/src/java/Makefile (bear in mind we're using Java 1.3.1); change line 57 to the following: (cd $(PACKAGE_SRC) ; javac -target 1.3 *java)
  3. Alter the following two lines in /tmp/jbluez/src/c/BlueZ.c: line 381, change hci_local_name(...) to hci_read_local_name(...); line 408, change hci_remote_name(...) to hci_read_remote_name(...).

Building and testing

With these modifications in place, it should be a simple case of compiling JBlueZ via make. This step should pass without failure -- the library has now been built. Now transfer the jbluez tree over to the iPAQ. The tree only takes up about 487.5KB of space.

For the sake of simplicity, and to reduce workload each time I run anything, I have the following script simply named "j" placed in /usr/local/bin/:

#!/bin/sh
export CLASSPATH=$CLASSPATH:.:/tmp/jbluez/bin/jbluez.jar
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/tmp/jbluez/bin/
killall hciattach
hciattach -S /etc/bluetooth/TIInit_3.2.26.bts ttyS1 texas 1> /dev/null 2>/dev/null

java $1

My /etc/bluetooth/hcid.conf is largely unmodified, but I suspect it might prove useful to mirror my setup entirely for anybody else trying out JBlueZ on their iPAQ. My hcid.conf is available here.

With all this in place, it should be a matter of locating a JBlueZ application and running it:

# cd /tmp/jbluez/examples/inquiry/
# j Inquiry
2 devices found.

        00:E:07:E3:26:D5
        00:11:B1:07:A2:F1
#

My JBlueZ tree

If you don't fancy all that effort, feel free to download the outcome of my troubles here.

Resources