BT747 iPhone app?

aspenboy's picture

Don't know if this request belongs here, but with the new iPhone 3.0 it seems like it might be possible to access bluetooth GPS loggers. If so, I would love to have an iPhone app to download tracks to and also be able to access realtime GPS data from my iTrek Z1 logger. I have a first gen iPhone without GPS, but also I know that using even the iPhone 3G as a GPS data logger is not ideal, because:
- can't run logging in the background
- hurts battery life

It would be nice to occasionally have access to some GPS data from the logger over bluetooth but also know that the logger is collecting data and you don't have to keep the app running if you want to check your email or surf the web.

Anyway, I thought this might be useful for others as well. Thanks for listening.

This is what I see in Cydia

This is what I see in Cydia on my iPod Touch v3.1.2

In order to see the Java section you have to go into Manage (in Cydia),
select Settings (upper left), and select Hacker or Developer.
This will unhide the Java Section. The following packages are available:

Classpath 0.96.1-3 open source implementation of Java
iPhone/Java 1.0.2474-2 example applications in Java
JamVM 1.5.1b2-3 is a console package only.
Java SQLite 20080130-3 JNI bindings and JDBC driver for SQLite
Jikes 1.22-3 native faster alternative to Java's javac
JocStrap 1.0.2549-8
UICaboodle 1.0.2475-2 iPhone-specific JocStrap extensions
Rhino 1.6R7-2 Java implementation of JavaScript


What roqyBT concerns, this package runs flawlessly in the background and is alive immediately coming back out of sleep mode. It runs with all applications like TomTom and the interesting Atlas Offline Maps browser which get it's maps from the Global Map Download Tool. So up for the next step: BT747 for iPhone/iPod.

mdeweerd's picture

Hi Thanks for the


Thanks for the feedback.

Apparently 'Jocstrap' allows to bridge to Objective C's API so that the GUI can be used.  So it looks that for having a GUI on the iPhone, this will have to be developed specifically.

I add some links for future reference or reference for readers:

  • Article regarding 'Hello world' App for iPhone Java with GUI in iPhone:  Short but effective discussion.  It has a link to the HelloWorld source code: .
    I do not know (yet) if there are other java examples for the iPhone.
  • Another sample appllication is 'JavaSysInfo'.  That is discussed here: .
  • The next page goes into a step by step approach about compiling a java app on the phone - but I guess that compiling could be done on the computer itself too:

One of the first things to do would be to get BT747 running in command line mode to perform some conversion.  Then to get the command line interface (CLI) version connecting to a device and downloading from it.  Once these two functions work the critical stuff is ok and work on a GUI or more command line options are usefull operations.To run the command line, the core of what has to be done is this: java bt747.j2se_view.BT747MainI suppose however that in this case you need to provide/set the classpath (which includes the program's jar).On the Windows desktop, the class path looks like the next line where the '%...%' are replaced with the respective paths.CLASSPATH=%MYDIST%\BT747_j2se.jar;%RXTXPATH%\RXTXcomm.jar;%MYDIST%\libBT747.jar;%MYLIB%\swing-layout-1.0.3.jar;%MYLIB%\jopt-simple-2.4.1.jar;%MYLIB%\jchart2d-3.1.0.jar;%CLASSPATH%Because the CLI does not use the GUI, that can be reduced to the non-gui paths only.  The GUI would have to be built using Joc anyway.The serial library is in 'RXTXcomm.jar' but there is no native library of that for the iPhone.  So to connect, a specific serial implementation is required (probably using Joc to access the Objective c function that in turn use RoqyGps).  So we'll leave out RXTXcomm too.  Java should not complain unless we try to make a connection.  Hence the reduced classpath for the initial test looks like the following (replacing ';' with ':' for the iPhone platform and without the full paths):CLASSPATH=BT747_j2se.jar:libBT747.jar:jopt-simple-2.4.1.jar:$CLASSPATHSo you need to:

  1. get these three files onto the iPhone (BT747_j2se.jar, libBT747.jar and jopt-simple-2.4.1.jar),
  2. Get a sample 'bin' file to the iPhone;
  3. Set or provide the classpath appropriately (env. variable or '-cp' option to 'java'), and ,
  4. Do some simple commands like this:
    Get help:
    java bt747.j2se_view.BT747Main --help Convert 'mylogfile.bin' to create an HTML file 'GPSDATA.html':
    java bt747.j2se_view.BT747Main -b mylogfile.bin --outtype HTML

Any issue along the way will need to be examined and solved.Once that works, somebody will have to do the class implementation to connect and communicate over bluetooth.  Testing will follow a similar scheme (using the CLI).

Hi Mario, thank you for your

Hi Mario, thank you for your wide reaction. This is what I've done:

A directory in Windows XP is containing the following files:

mylogfile.bin          (empty for the moment)

and two .bat files containing:

set CLASSPATH=BT747_j2se.jar;libBT747.jar;jopt-simple-2.4.1.jar
java bt747.j2se_view.BT747Main -b Convert mylogfile.bin


set CLASSPATH=BT747_j2se.jar;libBT747.jar;jopt-simple-2.4.1.jar
java bt747.j2se_view.BT747Main -b mylogfile.bin --outtype KML

Those two .bat files apparently run OK with the obvious warnings
of missing data in the empty .bin file


The same exercise is done on the iPod Touch but then replacing
the ; for : and starting the bat files with #!/bin/sh

This generates the following error trace in both cases:

java.lang.NoClassDefFoundError: bt747/j2se_view/BT747Main
   <<No stacktrace available>>
Caused by: java.lang.ClassNotFoundException: bt747.j2se_view.BT747Main not found in java.lang.ClassLoader$1{urls=[file:/private/var/tmp/mdeweerd/./], parent=null}
   at java.lang.ClassLoader.loadClass(
   at java.lang.ClassLoader$1.loadClass(
   at java.lang.ClassLoader.loadClass(

So I could have made an error in the definition of the CLASSPATH.
Not very familiar with the Unix/Java environment I tried several options
with leading ./ for the file names and even written the path in full lenght,
all with the same result. The same script file executing the tiniest
'HelloJava' sample program did perform ok however.

mdeweerd's picture

The first challenge is to get

The first challenge is to get the classpath right.

As far as I understand, the shell is bash/sh like so setting the env variables is not done using 'set', but by assigning and then exporting.



This will set CLASSPATH to 'classpathsetting', make it available to other processes called from here (export ...), and check the value for CLASSPATH. It is likely that the 'java' command has a '-cp' option that lets you set the classpath as well.  If the VM ois the 'JAMVM', then you can see some of its options here: '-verbose' is another interesting option.Make sure to put the java options before the class specification itself, like this:

java -cp 'classpathsetting' -verbose bt747.j2se_view.BT747Main -b mylogfile.bin --outtype KML

export CLASSPATH is bringing

export CLASSPATH is bringing us further, but some AWT toolkit is missing:

BT747 Cmd V1.68.32 build trial.trial.20091228151721913 GPL V3 LICENSE
java.awt.AWTError: Cannot load AWT toolkit:
   at java.awt.Toolkit.getDefaultToolkit(
   at java.awt.EventQueue.invokeLater(
   at bt747.j2se_view.BT747cmd.main(Unknown Source)
   at bt747.j2se_view.BT747Main.main(Unknown Source)
Caused by: java.lang.UnsatisfiedLinkError: Native library `gtkpeer' not found (as file `libgtkpeer') in gnu.classpath.boot.library.path and java.library.path
   at java.lang.Runtime.loadLibrary(
   at java.lang.System.loadLibrary(
   at java.lang.VMClass.forName(Native Method)
   at java.lang.Class.forName(
   at java.awt.Toolkit.getDefaultToolkit(
   ...3 more

mdeweerd's picture

Good - I'll see if I can

Good - I'll see if I can avoid that 'awt' call.

In the mean time, can you try a simpler command - just '-help' as option.  In that case the awt should not be called.  That will just allow us to confirm that the option analyzer is working which is likely the case anyway because the 'awt' is only called if that works (a minimum).

So I'll have to find the alternative for 'InvokeLater' in the gnu classpath that is not using the GUI part.  That should not be too complex.


Mario, The -h option is


The -h option is giving the expected output, so that's ok. I also have the java -version output for you because I read something of having at least 1.6. This output shows java version 1.5:

java version "1.5.0"
JamVM version 1.5.1
Copyright (C) 2003-2008 Robert Lougher <>

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2,
or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.

Build information:

Execution Engine: direct-threaded interpreter with stack-caching
Compiled with: gcc 4.2.1 (Based on Apple Inc. build 5555)

Boot Library Path: /usr/lib/classpath
Boot Class Path: /usr/share/jamvm/

mdeweerd's picture

Hi I made a new build -


I made a new build - 2.X.1764.  I see that you tried 1.68.32.  '2.X' is the development branch, but it is quite stable/working well.

In the new build, I do it differently.  It still works on my system - hopefully it will be ok for everybody.

Can you try it?

Build 2.X.1764 shows the same

Build 2.X.1764 shows the same - good - resonse as running the exercise on Windows XP.

I will try to get a proper .bin file and run it again for real.

mdeweerd's picture

Excellent. I've written a


I've written a message to the roqy-bluetooth author to get started on that end.

The GPSDATA.kml file

The GPSDATA.kml file generated by the iPod is functional the same as created by Windows, but some Style and Icon blocks are in a different order. Furthermore it takes about a minute on my 2nd generation 8GB iPod Touch to create. About half of this time is used by loading all the modules as can be seen with the -verbose option enabled. Redirecting the -verbose output into a text file generates almost 100kb in size.

When a huge amount of .bin data is converted to .kml you can expect a spontaneous reboot after 10 min. The supposed output of 488kb in this case is correctly processed till 440kb, but the last part, both coordinates and finishing code, is missing. No idea if this has to do with a time-out or memory overload, but iOS3 doesn’t like it.

mdeweerd's picture

Despite the issues this is

Despite the issues this is excellent news.

I guess that the difference in the output file is due to the use of different versions, but it could also be due to a slight difference in the library functions (in some cases the order of data is not guaranteed).

The '-verbose' option is mainly for debugging so you can remove that safely.

I wonder if 'KMZ' is faster.  It requires an extra compression step but there is less stuff to write.

It could be that the java process does not leave any processing power to the system, in which case it is more likely a JAMVM issue.  I'll think about other alternatives to work around the 'missing library' issue and see if that could help, but in theory it should not.

It is clearly a confirmation that at least most the essential java functions work.  The next step is getting the bluetooth connection to work - for that some help from roqyBluetooth is needed - at least on how to use its API.

The performance figures

The performance figures mentioned before of one minute is based upon an 8MB bin file containing a few coordinates. After processing it has generated either a 15kB kml file or a 2kB kmz file.

A 'smarter' bin file of 64kB containing the same amount of coordinates is processed in 30 seconds. With so few coordinates there is no processing time difference noticeable between generating the larger kml file or the extra work of the smaller kmz file.

mdeweerd's picture

Good to know - I guess that

Good to know - I guess that the slowness comes from the error recovery mechanism that I probably can improve in efficiency when the log is essentially empty.

Thanks for having run these trials!

mdeweerd's picture

Hi I have launched a poll


I have launched a poll regarding porting BT747 to a paying VM platform.

Please vote here: .

not sure if this is relevant,

not sure if this is relevant, but I just tried the "btstack" application from Cydia, and it found my gps device, and their demo GPS app worked fine.  So as far as bluetooth access goes ... that part could be condidered done.  ( sorry if i stepped in and didn't understand all the details )  oh, i have an iphone 4 ... which obviously has GPS, but I think the logger's gps is better and might save battery.  ( not sure bluetooth uses as much? more? )

mdeweerd's picture

Bluetooth emits 1, 2.5 or

Bluetooth emits 1, 2.5 or 100mW depending on whether it is class 1, 2 or 3 and this corresponds to 1, 10 or 100 meter range.  That is just the power emitted - not the power needed to be able to emit that (if the driver is matched to the antenna load, then there is in principle as much power loss in the driver as there is power transformed by the antenna).

Generally Bluetooth it will be class 1 or 2, with up to 2-5 mW in power consumption.

A GPS chip uses about/at least 20mA I believe @3.3V, so that is 66mW.  With a 1000mAh battery @3.3 V (3300mWh), the logger is reported to work just over 30 hours.  That leads us to a power consumption of 100mW which is just above the 66mW, so both power calculation approaches are pretty much in line.

Bluetooth is just a fraction of 66mW (less than 10% or less than 5% in the case of 100mW for the GPS).  So bluetooth clearly drains the phone battery much less than the GPS.

Regarding BTStack.  I had a quick look and if my interpretation of the schematic is correct, BTStack presents a network socket to access bluetooth.  This is something that could be done in Java (make a bridge in java to let BT747 access bluetooth that way).

I am not sure what is possible GUI wise with Cydia's java.

I think the technical building blocks are available - what is needed to build a Cydia oriented implementation is a motivated "coder".

mdeweerd's picture

  Here is another


Here is another suggestion:

Java can run on Mono:


Mono can run on the iPhone:


That could be a way to go to (and I poste a similar note for Android)

/* Style Definitions */

/* Style Definitions */
{mso-style-name:"Table Normal";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-bidi-font-family:"Times New Roman";
I was thinking to myself: this really explained things well and gave me a whole new way of looking at things. I do know this would not have been possible without reading this truly remarkable post. I sincerely appreciate it and wish all the best! do my essay

I have a 747ProS that I've

I have a 747ProS that I've set to record track points every 1 sec or 5M. When I upload the data with BT747the track on the map has several sections where the distance between trackpoints is greater than 100M. I think this may be because the motion sensor does not properly restart logging after a rest. How do I turn off the motion sensor?