
Skyhook Wireless (http://www.skyhookwireless.com) offers a WiFi based location service. The service is available for Windows and Linux desktops long with Symbian and Windows Mobile phones. Looking specifically at what is packaged with the Windows Mobile SDKs (there are three, one for Windows Mobile Standard, one for Windows Mobile Professional, and one for Windows Mobile Classic) one will find a C++ header file, the DLL containing the client side Wireless Positioning Service (WPS) functionality, and some example C++ code. Managed developers need to use P/Invoke to get access to the functionality.
In reading through the Skyhook Wireless Discussion Group I've found that there are managed developers that have interest in using the SDK but they have not had success with creating a wrapper for the functionality. I've been planning to make an attempt at creating a wrapper myself since June. Right now I am going through a very breif quiet perid at work (and not to mention that I've completed my obligations with school) so I took a couple of days to give it a try. I've run into what I believe to be be the challenge that other managed developers have encountered and I have a workaround for it. Presently I have code that can successfully query the users location (for those familiar with the SDK that means I can called WPS_location, WPS_ip_location, and get automatic callbacks from WP_periodic_location with full address information) and I hope to get it out after Boxing day (December 26th).
The first challenge that I encountered is that the Skyhook WPS SDK makes use of ANSI (8-bit) characters while the Compact Framework only supports 16 bit characters. One work around for this is to create your own string encoder to convert between the 16-bit and 8-bit character sets and pass the strings back and forth as byte-arrays. But this didn't help with the second problem I ran into. With the compact framework I would receive NotSupported exceptions when trying to pass complex structures. As long as a structure was flat (only contained primitive types such as integers, doubles, and so on) the type could be marshalled without conflicts. As soon as that structure contained another more complex type that was not a primitive type the NotSupported Exception would occue. And easy example is trying to marshal any structure that contains a string builder. Seeing what worked for me and what didn't work I came up with a workaround.
I created a proxy unmanaged DLL. This DLL has functions that only accept simple types: integers, doubles, and StringBuilders. The functions in the DLL will build the more complex structures and handle the conversion from unicode to ANSI and then make calls against the SkyhookWireless DLL. As the return values pass back through the proxy DLL they are converted from their complex types back to something easily passed back to the managed code. Having experienced that success I am creating a wrapper for the entire SDK and plan to have it uploaded to the Skyhook Wireless Discussion Group after Boxing day. As per usual there will also be an article on CodeProject.com after my work is complete. This will enable C# and VB.Net developers to make use of the Skyhook Wireless SDK.
Tags: