Sunday, July 22, 2007

Configuring the GPS Intermediate Driver

I recently purchased the QSTARZ Bluetooth GPS Receiver Model BT-Q818 to play around with some location-aware research ideas I've had. First, the GPS receiver worked out-of-the-box after following the configuration instructions in the directions (or see this post on the Windows Mobile team blog). I tested it both on my Cingular 2125 SmartPhone and Cingular 8125 Pocket PC Phone. Second, it works amazingly well with the new Windows Live Search--I can get smooth map scrolling, hybrid maps, and real time traffic overlays on my phone automatically centered on my current location. To configure Windows Live on WM to use GPS, open Live Search->Menu->Settings and then set the GPS COM port (in my case, COM6). Then, open Map and make sure that Menu->Center on GPS is checked.

I was anxious to start my own hacking. I knew that Windows Mobile 5 shipped with the GPS Intermediate Driver framework, unfortunately I did not realize that this is an unmanaged API. However, both the Windows Mobile 5 SDK and the Windows MObile 6 SDK ship with sample code that provides a managed wrapper around that native GPS API. On my computer, these two samples can be found in:
  1. C:\Program Files\Windows Mobile 6 SDK\Samples\Smartphone\CS\GPS
  2. C:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Pocket PC SDK\Samples\Cs\Gps
Unfortunately, neither of these samples worked for me immediately. I don't have a WM6 device, so I'll focus on the WM5 sample. The sample includes the Microsoft.WindowsMobile.Samples.Location GPS wrapper API and a small test app called GpsSample. To get the sample to work, you must configure the GPS Intermediate Driver, which requires either editing the registry or, alternatively, running the "GPS Intermediate Driver Control Panel." See Configuring the GPS Intermediate Driver on msdn. Well, where can I find this control panel? As the msdn link points out, many OEMs hide the application icon. On my Cingular 8125 Pocket PC Phone, this was certainly the case. Here's what I did to unhide it:
  1. On the desktop, open Start->All Programs->Microsoft Visual Studio 2005->Visual Studio Remote Tools->Remote Registry Editor
  2. Connect to your Windows Mobile device in the Remote Registry Editor
  3. Find the path: HKEY_LOCAL_MACHINE\ControlPanel\GPS Settings
  4. Delete any "Redirect" or "Hide" keys under HKEY_LOCAL_MACHINE\ControlPanel\GPS Settings.
Then, on my Pocket PC device, I opened Settings->System and there was a GPS icon. Click on that icon and choose an unused COM port. This is the COM port that your GPS applications are going to communicate through--the GPS intermediate driver talks to the hardware directly and serves as a virtual device sending data out this COM port. I selected COM0. Then select the Hardware tab and choose the GPS hardware port. On my device, I setup GPS to communicate via COM6 (at the highest baud rate possible). Then on the third and final tab ("Access"), make sure that Manage GPS Automatically is selected. After doing this, I reran the WM5 managed GPS sample and it worked great :)

Successfully configured GPS Intermediate Driver on Pocket PC Phone

Well, what if you have a SmartPhone? According to Jason Fuller on the Windows Mobile Team blog, the SmartPhone does not have the GPS Intermediate Driver Control Panel (see his post here). You can, however, manually configure the GPS Driver by modifying the registry. Again, using the Remote Registry Editor found in the Visual Studio Remote Tools directory:
  1. [HKEY_LOCAL_MACHINE\System\CurrentControlSet\GPS Intermediate Driver] "IsEnabled"=dword:00000001
  2. [HKEY_LOCAL_MACHINE\System\CurrentControlSet\GPS Intermediate Driver\Drivers]
    "CurrentDriver"="BT GPS"
  3. [HKEY_LOCAL_MACHINE\System\CurrentControlSet\GPS Intermediate Driver\Drivers\BT GPS]
    "CommPort"="COMX:" where X = the hardware COM port (for me COM6)
    "FriendlyName"="BT GPS"
    "InterfaceType"="COMM"
See this post on xda-developers for more information about modifying the registry to configure the GPS Intermediate Driver. Alternatively, someone has created a small tool to modify the registry settings--run this from your SmartPhone. Here's the GpsSample running on my Windows Mobile 5 SmartPhone (Cingular 2125).

Successfully configured GPS Intermediate Driver on SmartPhone

Update 07/24/2007 11:58PM: Some have asked me to post further details on the registry settings I am using on the Pocket PC and SmartPhone. Here's a PDF displaying screenshots of my key/value pairs related to the GPS Intermediate Driver.

5 comments:

Anonymous said...

Hey, congratulations for having that device. i myself have that too, and its working sweet.

Anonymous said...

Hi,
I have a problem reading the ellipsoidal altitude.
Wherever I go it returns the value 47,9.
Do you know what to do???
Thanks for helping me

Greets,
Johnny

Unknown said...

Hi

i understand about GPS intermediate driver.My only concern is that what we have to do when we want to use Inbuilt GPS in windows mobile.here we have to do port settings in windows mobile 6 emulator.And we can write here out attached GPS device port number But if we want to use Inbuilt GPS of windows mobile than what?

Unknown said...

Hi

i understand about GPS intermediate driver.My only concern is that what we have to do when we want to use Inbuilt GPS in windows mobile.here we have to do port settings in windows mobile 6 emulator.And we can write here out attached GPS device port number But if we want to use Inbuilt GPS of windows mobile than what?

suhas said...

helpful doc

thank u