locked
Retrieve GPS location RRS feed

  • Question

  • Hi all,

    I am developing for a Windows Mobile 6.5, a C/C++ application that has to retrieve the GPS location of the device. I tested it on a HTC HD2 and I actually have 2 questions:

    1) Does one need on that device to actually start the GPS, like for instance one would do for Bluetooth which needs to be enabled before using it?, or this step is not necessary, as by default the GPS is always enabled and "working" (so no enable/disable GPS option)?

    2) In MSDNL there are 2 infos that confuses me:
    On one hand on: http://msdn.microsoft.com/en-us/library/bb202049.aspx is written
    "You can call GPSGetPosition without a handle retrieved using GPSOpenDevice. In this case, the GPS Intermediate Driver returns location information it has that meets the maximum age constraint you provided in your GPSGetPosition call."
    On the other hand on: http://msdn.microsoft.com/en-us/library/bb202050.aspx is written
    "GPSGetPosition does not query the GPS device directly to determine the current position. Instead, it will read the last position that the GPS device indicated to the GPS Intermediate Driver. The GPS device will indicate a position to the GPS Intermediate Driver in the background, independently of calls to GPSGetPosition."
    Questions:
    a) What is the difference between when one does first a GPSOpenDevice and uses the obtained handle in the GPSGetPosition and when one does a GPSGetPosition with a NULL handle? In both cases the GPS device seems to NOT be interrogated and the info (that meets the maximum age) found in the GPS Intermediate Driver would be returned. So what is then the difference?
    b) Is there a way to "force" a direct query of the GPS device?

    TIA,
    MeCoco
    Thursday, May 19, 2011 8:52 AM

Answers

  • Calling GPSOpenDevice() starts the GPS hardware. When every application that has called GPSOpenDevice() calls GPSCloseDevice(), the GPS hardware is shut down.

    If you call GPSGetPosition, it takes the last known position from the Intermediate driver and gives it to you. If the GPS hardware is running (i.e. some app has called GPSOpenDevice()) that position should be fairly current. You can specify how current you require the position information to be with the dwMaximumAge parameter. If the age of the position information is older than what you specify and the GPS hardware is not turned on by GPSOpenDevice(), then GPSGetPosition will return a failure code.

    The intermediate driver is a method used to ensure more than one application can use the GPS at once.

    Calling GPSOpenDevice also gives you the option of specifying a HANDLE that is signaled when the device's position has changed. That way you know when to call GPSGetPosition().

    -PaulH



    • Proposed as answer by Jesse Jiang Tuesday, May 24, 2011 5:56 AM
    • Marked as answer by Jesse Jiang Monday, May 30, 2011 8:23 AM
    Thursday, May 19, 2011 2:54 PM

All replies

  • Calling GPSOpenDevice() starts the GPS hardware. When every application that has called GPSOpenDevice() calls GPSCloseDevice(), the GPS hardware is shut down.

    If you call GPSGetPosition, it takes the last known position from the Intermediate driver and gives it to you. If the GPS hardware is running (i.e. some app has called GPSOpenDevice()) that position should be fairly current. You can specify how current you require the position information to be with the dwMaximumAge parameter. If the age of the position information is older than what you specify and the GPS hardware is not turned on by GPSOpenDevice(), then GPSGetPosition will return a failure code.

    The intermediate driver is a method used to ensure more than one application can use the GPS at once.

    Calling GPSOpenDevice also gives you the option of specifying a HANDLE that is signaled when the device's position has changed. That way you know when to call GPSGetPosition().

    -PaulH



    • Proposed as answer by Jesse Jiang Tuesday, May 24, 2011 5:56 AM
    • Marked as answer by Jesse Jiang Monday, May 30, 2011 8:23 AM
    Thursday, May 19, 2011 2:54 PM
  • Hi PaulH,

     

    Thx a lot for the explanation. It helps!

    Thx,

    MeCoco

    Wednesday, June 29, 2011 9:42 AM