Location, Location, Location… and FakeGPS


It’s no secret that I believe location based services via mobile devices will absolutely change life as we know it.   This is one of those areas where the business models needed to make LBS mainstream with every consumer out there are moving a lot slower than the technology itself.  As a developer, you don’t have to wait on the rest of the world to catch up.  If you are not using Live Search Mobile on your Windows Mobile phone, you need to check it out.  This may be the most useful Windows Mobile app ever.  Take a test drive to get your dev juices flowing. 

 

Now that you are ready to build something on your own, the FakeGPS tool in the Windows mobile SDK is a great way to get started.  My colleague, Rob Cameron, just posted an good article on the topic…check it out!

 

-Reed


Comments (3)

  1. Ripper says:

    I am using the FakeGPS utility on Device Emulator. I was able to install it successfully. I then wrote a small app to test FakeGPS but the code does not seem to be working i.e I dont get the information from the NMEA text files.. as I am supposed to.

    Here’s the code I am using: (App)

    /** START **/

    #define FLAG 1

    HRESULT hr = S_OK;

    GPS_DEVICE gpsDeviceState;

    GPS_POSITION gpsPosition;

    HANDLE h_GPS;

    memset(&gpsDeviceState, 0, sizeof(GPS_DEVICE));

    memset(&gpsPosition, 0, sizeof(GPS_POSITION));

    h_GPS = GPSOpenDevice(NULL, NULL, NULL, 0);

    if (!h_GPS)

    {

    RETAILMSG(FLAG, (TEXT("FakeGpsApp:GPSOpenDevice failed!n")));

    return E_FAIL;

    }

    RETAILMSG(FLAG, (TEXT("FakeGpsApp:GPSOpenDevice succeededn")));

    gpsDeviceState.dwVersion = GPS_VERSION_1;

    gpsDeviceState.dwSize = sizeof(GPS_DEVICE);

    if (ERROR_SUCCESS == GPSGetDeviceState(&gpsDeviceState))

    {

    RETAILMSG(FLAG, (TEXT("FakeGpsApp:GPSGetDeviceState succeededn")));

    RETAILMSG(FLAG, (TEXT("ServiceState:%d, DeviceState:%dn"), gpsDeviceState.dwServiceState, gpsDeviceState.dwDeviceState));

    RETAILMSG(FLAG, (TEXT("Prefix:%s, FriendlyName:%sn"), gpsDeviceState.szGPSDriverPrefix, gpsDeviceState.szGPSFriendlyName));

    }

    else

    {

    RETAILMSG(FLAG, (TEXT("FakeGpsApp:GPSGetDeviceState failed!n")));

    }

    gpsPosition.dwVersion = GPS_VERSION_1;

    gpsPosition.dwSize = sizeof(gpsPosition);

    if (ERROR_SUCCESS == GPSGetPosition(h_GPS, &gpsPosition, 10000, 0))

    {

    RETAILMSG(FLAG, (TEXT("FakeGpsApp:GPSGetPosition succeededn")));

    RETAILMSG(FLAG, (TEXT("ValidFields:%d, SatelliteCount:%dn"), gpsPosition.dwValidFields, gpsPosition.dwSatelliteCount));

    RETAILMSG(FLAG, (TEXT("Latitude:%d, Longitude:%dn"), gpsPosition.dblLatitude, gpsPosition.dblLongitude));

    }

    else

    {

    RETAILMSG(FLAG, (TEXT("FakeGpsApp:GPSGetPosition failed!n")));

    }

    GPSCloseDevice(h_GPS);

    return hr;

    /** END **/

    And the debug msgs that I am getting are:

    /** START **/

    Load module: FakeGPSApp.exe

    .

    .

    FakeGpsApp:GPSOpenDevice succeeded

    FakeGpsApp:GPSGetDeviceState succeeded

    ServiceState:1, DeviceState:1

    Prefix:File, FriendlyName:TestGPSFile

    FakeGpsApp:GPSGetPosition succeeded

    ValidFields:0, SatelliteCount:0

    Latitude:0, Longitude:0

    .

    .

    /** END **/

    Although GPSOpenDevice and GPSGetDeviceState are working fine, GPSGetPostion does not seem to be returning the right values. Am I doing something wrong? I am not sure if this is the right place to post this, any help is appreciated 🙂

    I am using VS2005 to build the app and running it on Windows Mobile 6 Pro emulator. And yes, after installation of FakeGPS, I did enable the FakeGPS app.

    Thanks,

    Ripper

  2. Reed Robison says:

    I just created a simpe console app in VS and pasted your code in verbatim…ran it on the WM6 Pro emulator after installing and starting the Fake GPS util and it worked as expected..

    FakeGpsApp:GPSOpenDevice succeeded

    FakeGpsApp:GPSGetDeviceState succeeded

    ServiceState:1, DeviceState:1

    Prefix:File, FriendlyName:TestGPSFile

    FakeGpsApp:GPSGetPosition succeeded

    ValidFields:262111, SatelliteCount:6

    Latitude:-2084032663, Longitude:1078448410

    Do you get any data if you swich to the dixies data file?  Let me know if you were not able to get this working…

    -Reed

  3. Ripper says:

    Hi Reed,

    Thanks for your reply. I find it strange that it worked flawlessly when you tried it. The only difference that i can see is that I tried it in a smart device windows application (win32).

    Just out of whim I gave a "sleep(1000)" before calling "GPSGetPosition" and then it worked! And when I remove the "sleep", it doesn’t. Strange.. yet to figure out why..

    Ripper