Monday, 17 December 2007

Location based Java Micro Edition

My first encounter with location based services was in 2000 when working for a telco back when the internet bubble had not burst and life was good! Several months later the telco shelved the technology due to lack of enthousiasm of customers to pay for knowing where they were. And that is probably still the case today. Unless you are offering something fantastic (like on-board car navigation for example) nobody is going to pay for location based content.
Nonetheless the last year has seen a revival of location based chatter on the web and i don't seem to be able to escape from it. Last year we field tested location based java micro edition software on regular phones and bluetooth gps receivers. Then this year three seperate companies asked us help them with their location based software. All three were having difficulties with the technology so it's safe to say it's not as easy as some might portray.
First off, there is very little on the web in the way of working, open examples that you can take apart and examine. Countless sites have a code fragment that works for them, on their hardware. And then there were a bunch of authors who wrote about something they made in the Sun WTK emulator but never tested on a real phone. These 'look at me, my boss gave me time to read the tutorials and now i'm a guru' authors always annoy me because they always say things that are wildly wrong. For example at a local Java conference in the Netherlands there was someone lecturing on location based services who made the bold claim that 'Your mobile will determine which location based services are available and use them, so if you do not have a GPS receiver it will use the telecom networks positioning information. And yes you can actually use that right now!' not knowing that at the time there were no network operators that had that service switched on.

Anyway dragging myself back to the topic; part of the enthousiasm on the web has been due to the fact that a number of device manufacturers are starting to implement the location based API (JSR-179). It's been around for a while, but there used to be only two phones (guarded in finland by dragons) that had any sort of implementation. And needless to say they both had a different implementation all together. But Nokia and Sony Ericsson have been introducing enough models with a JSR-179 implementation to make it fairly widespread in the high-end segment of the phone market (in Europe anyway). This is a good development, but there are still a few problems with the Location API JSR-179 implementations:
  1. There are few phones that actually have an inbuilt method for location determination. The Nokia N95 must be the most popular, but most phones just do not have GPS hardware.
  2. The hardware that does have inbuilt GPS chips and antenna's tends to be exactly the hardware that is running an operating system that is hard to run java on. For example all the windows mobile devices that are popular for (among other things) in-car navigation. And what about all the Garmin, Becker and TomTom hardware that people are buying in busloads. Ever tried to run Java on one of those?
  3. A JSR-179 implementation dictates CLDC 1.1. So if you are developing for a number of devices here is another fragmentation issue. If you want your software to install on a CLDC 1.0 device (and there a tons of them) you cannot use JSR-179. So now you have two code-bases.
  4. The JSR-179 implementations are still new and therefore buggy. For example an implementation we tried automatically tried to search for GPS bluetooth devices the first time we tried it, but had no facility to change which GPS bluetooth device was selected. Great if you buy a new GPS receiver!

Generally speaking there are three strategies for getting location information in Java Micro Edition:

  1. Use the location API
  2. Use the bluetooth API (JSR-82) and bluetooth serial port protocol to read from a GPS bluetooth receiver.
  3. Use the serial port protocol to read from a COM port on the device.

Each strategy requires completely different code. I've tried em all, and they can all be done, but not on all hardware.

It's late... I'll get back to this soon.