What is FakeGPS
Microsoft has introduced a new tool named FakeGPS for Windows Mobile application developers and testers. Testing GPS application was difficult in earlier mobile SDK versions as a GPS receiver doesn’t work within closed walls, also the Emulators didn’t have any GPS simulated testing tool built in. Using FakeGPS, developers and testers can now easily simulate satellite based global positioning system data and use that for testing their GPS applications. FakeGPS comes with Microsoft Windows Mobile SDK v6.0 and DTK version 6.3.5; after the SDK installation FakeGPS.cab is copied into C:\Program Files\Windows Mobile 6.5.3 DTK\Tools\GPS folder
. FakeGPS creates a text file containing all the GPS data and simulates the functionality of a GPS receiver. In this article I will demonstrate how to use the FakeGPS tool to test your GPS application.
Creating GPS Intermediate Driver Layer Application
A Windows mobile developer needs to create a GPS intermediate driver layer that resides between physical GPS hardware and GPS software application. Typically the GPS hardware can be used by a single application at a time but using FakeGPS tool multiple application can simultaneously access GPS hardware(simulated hardware) using the intermediate driver. To demonstrate the functionality of FakeGPS I have created a mobile device type application using Visual Studio and used Microsoft supplied assembly (a dll component) named Microsoft.WindowsMobile.Samples.Location.dll for developing GPS Application. You can find the GPS Dll in the SDL sample project folder; this sample gets installed with Mobile SDK 6.0 in the default path C:\Program Files\Windows Mobile 6 SDK\Samples\PocketPC\CS\GPS. To debug Microsoft.WindowsMobile.Samples.Location.dll code I have also added the source code of this assembly in my GPSApplication solution.
Figure 1
Next I have created a Windows form to get all the GPS related data like device state, satellite details, longitude, latitude etc. displayed in the front end. The GPS device exposes 2 events to developers named “state change” and “location change”. In the state change event you can capture the device name, device state and service state information. From “location change” event you can get longitude, latitude, satellite details. The followings are the 2 events code I have written to get the GPS related data.
<Code>
private void gps_DeviceStateChange ( object sender, DeviceStateChangedEventArgs args )
{
GpsDeviceState device = args.DeviceState;
ControlUpdater cu = UpdateControl;
Invoke ( cu, txtgpsused, device.FriendlyName );
Invoke ( cu, txtgpsdevstate, device.DeviceState.ToString ( ) );
Invoke ( cu, txtgpsserstate, device.ServiceState.ToString ( ) );
}
private void gps_LocationChanged ( object sender, LocationChangedEventArgs args )
{
GpsPosition position = args.Position;
ControlUpdater cu = UpdateControl;
if ( position.LatitudeValid )
Invoke ( cu, txtgpslat, position.Latitude.ToString ( ) );
if ( position.LongitudeValid )
Invoke ( cu, txtgpslong, position.Longitude.ToString ( ) );
if ( position.HeadingValid )
Invoke ( cu, txtgpsheading, position.Heading.ToString ( ) );
if ( position.SatellitesInViewCountValid )
Invoke ( cu, txtgpssatellite, position.SatellitesInViewCount.ToString ( ) );
}
</Code>
I have executed this application on top of the Microsoft 6.4.1 Classic Emulator and used Microsoft Active Sync to synchronize the development environment with the emulator device. As this emulator doesn’t have any simulated GPS tool installed you will not be able to see any GPS related data in the output screen after the 1st execution.
Figure 2
To see the GPS receiver data in your output screen install the FakeGPS tool in the mobile emulator, which will work as a fake GPS receiver. Configure your emulator to access the FakeGPS.Cab file located in C:\Program Files\Windows Mobile 6.5.3 DTK\Tools\GPS folder of your development machine. From emulator configuration you need to share this folder.
Figure 3
Once folder sharing is done, open the emulator file browser and select storage device. You will be able to see the FakeGPS.Cab file. Double click this file to install Fakein in your emulator. Check the ‘Device’ option when the wizard asks you to confirm the location where FakeGPS is to be installed.
Figure 4
Next you need to activate the FakeGPS tool. Open the tool from the Start menu and select the “Enable” option from the dropdown, also mention the name of the text file where your FakeGPS too will write GPS data to. The default file name is fakegpsdata.txt you can also change the name.
Once all your configuration is complete, execute your application again and click on the “GPS On” sub-menu item. Now you will be able to see the GPS longitude, latitude and other data.
Conclusion
Microsoft has developed this fake GPS helper utility for developers to create and modify registry settings so that developers can create their own FakeGPS log file under the fake GPS directory. The fake GPS helper tool tightly works with the FakeGPS tool. To know more FakeGPS click here.