Wednesday, 4 February 2009

Priming the Openmoko U-Blox GPS Chip

I just wrote a little companion application to the YGPS Satellites app, or indeed any other application that uses the GPS chip on Openmoko. This new app speeds up the time-to-fix by communicating with the UBlox Online Assist server to download ephemeris data via the internet rather than waiting for the same information to be available via the GPS feeds. For me it speeds up the time-to-fix to a few seconds in some cases, less than a minute in most, while without it it can take up to 10 minutes to get a fix (has something to do with my desk being indoors, only facing a window).

The technical details for the U-Blox Online Assist feature can be found in detail on the Openmoko GPS pages.

To use the application you will have to get a free account with UBlox, because the requests require a user name and password. To obtain an account, send an empty email to I received my account password soon later by (apparently) automated email.

The app itself is headless, i.e. has no user-interface as such and is not installed to be launched by a user on its own. It consists of a BroadcastReceiver that waits for messages from other applications (such as my updated YGPSSats.apk) and then tries to interact with the UBlox server and primes the chip. It communicates back to the user with a few toasts. A preferences dialog allows the user to enter his Ublox Account details.

An updated version of my YGPSSats.apk checks whether the YGPSUblogs.apk is installed and then gives two additional menu options, one for setting the account details and an approximate location, the other for priming the chip. The updated YGPSSats also conveys (onStop()) the last known location to the ublox app, so that the next time the location details are as accurate as possible. (If you travelled far without the app on, set the location manually via settings).

The most likely error the app encounters is not having internet access, but sometimes there seems to be garbled responses. If you get an error and you believe you have internet access, simply try again. There seems to be no harm in priming a chip that already has a lock-on.


You will need the new version of my YGPSSats.apk, which contains the interface code to the ublox app. Users on phones other than Openmoko Freerunner will not see the new menu options. See below for installation hints if you are on the Koolu-RC3 image.

The you will need the YGPSUBlox.apk itself. This app will not show up in the launcher, but once it is installed you will get new menu options on the YGPS Satellites app.

Current limitations and work-arounds

Entering text into preferences dialog

The current Android version on Openmoko might not allow you to enter text into a preferences dialog. If this is the case run:
 adb pull /data/data/ prefs.xml

Then edit the prefs.xml file to add the following two lines:
<string name="ublox_password">your password here</string>
<string name="ublox_username">your email account name here</string>

The upload the prefs.xml file to your device with
adb push prefs.xml /data/data/

When first starting you should also supply your approximate location and an accuracy estimate. The YGPS Satellites application automatically
saves your last location to these fields, so once you have a fix when running YGPS Satellites, the next time you start up (and have not moved to far
from your last location, this information should be good enough. If you start up your GPS at a distant point, you should either set the new location
or just wait for a natural GPS fix.

Installation on Koolu Beta-3

The new Koolu-beta 3 image has the YGPS app installed in the systems folder, meaning that it cannot be uninstalled or upgraded by a user.
To change this mount the rootfs in read/write-mode and remove the app from the system folder

adb shell
mount -o remount,rw rootfs /
cd /system/app
rm YGPSSats.apk

The application should then be automatically removed and can thus be reinstalled


TreviƱo said...

Cool! Very useful!

However, all this needs the network usage (maybe GPRS too when Sean McNeil will release the support for it), but what about the support for U-Blox AGPS, saving and restoring almanac and ephemeris from previous GPS sessions (without any network usage)?

You should find an implementation of this in the FSO's ogpsd.

Thanks for your work, BTW!

Ludwig said...

I am looking at the offline assist at the moment. Thanks for the hint.