Include the Library Files
The library files are found in the lib directory of the SDK. Add all files into the lib path of your project.
Include the Header File
The header file is found in the include directory of the SDK. Place the wpsapi.h file on the include path of your application. You will include the header file in your code where you will implement the location calls.
User Registration
Auto-register
Before you can make location calls, your device must have a unique identifier that has been registered with the Skyhook servers. The easiest way to do this is to take advantage of our auto-registration call. Please see our documentation for more information on user registration
Auto-registration should be called every time your application launches. If it has succeeded in the past, it will not create a new user. User registration in your application would look like this:
// This object will contain your username and realm
// which you received when signing up with Skyhook Wireless as a developer
WPS_SimpleAuthentication authentication;
authentication.username = "yourUsername";
authentication.realm = "yourRealm";
WPS_ReturnCode rc;
while ((rc = WPS_register_user(&authentication, NULL)) != WPS_OK
&& ! interrupted)
{
if (rc == WPS_ERROR_UNAUTHORIZED
|| rc == WPS_ERROR_PROXY_UNAUTHORIZED)
{
fprintf(stderr, "*** WPS_register_user failed (%d)!\n\n", rc);
break;
}
fprintf(stderr, "*** WPS_register_user failed (%d)!\nRetrying...\n", rc);
// May want to introduce some delay in retry attempts here
}
if (rc == WPS_OK)
// Registration has succeeded.
WPS Location Call
WPS_Location Object
The WPS_Location object will contain the location information from the request. It contains the following variables.
double latitude - The latitude value in decimal format
double longitude - The longitude value in decimal format
short nap - The number of APs used to calculate the position
double hpe - The degree of accuracy in meters
double speed - The speed of the client device
double bearing - The direction the client is moving
WPS_StreetAddress* street_address - The street address of the location if requested
One-Time Location Request
The one-time location request provides a method to make a single request for location. The request will populate a WPS_Location object that includes the clients' latitude and longitude, as well as other positioning information. You must free the location pointer after you are done using it by calling the WPS_free_location(WPS_Location *) function.
A one-time location request call from your application would look like this:
// This object will contain your username and realm
// which you received when signing up with Skyhook Wireless as a developer
WPS_SimpleAuthentication authentication;
authentication.username = "yourUsername";
authentication.realm = "yourRealm";
WPS_ReturnCode rc;
// populated with the location results
WPS_Location* location;
rc = WPS_location(&authentication,
WPS_NO_STREET_ADDRESS_LOOKUP,
&location);
if (rc == WPS_OK)
{
// Use the location object - your code here
// Free the location object
WPS_free_location(location);
}
For a more detailed code sample, you may view the wpsapitest.cpp sample included in the sample directory of the SDK download.
For more detailed documentation, view the web based documentation in the /documentation/html directory of the SDK download.
Troubleshooting
For any questions, please visit the developer forum at: