This code sample is named WMBluetoothWrapper. It demonstrates simple Bluetooth device discovery via the WinSock 2 API and provides a C# wrapper class for running the discovery. Both the names of the mobile devices and their addresses are retrieved and marshaled to C# data types. I provide both the Visual Studio 2010 DLL project WMBluetoothWrapper which present the WinSock 2 based discovery function as well as the C# file including the BluetoothConnection wrapper class. Using the retrieved addresses, the current wrapper can be extended to include further functions, such as, Bluetooth based connection and data exchanging functions. BackgroundAs part of my plan to write a mobile social network application (coming soon) using Windows Mobile Bluetooth capable devices, I need a way to know what Bluetooth devices are near me. I'm developing a mobile social network application in C# using the .NET compact framework 3.5 and thus, I was confronted with the need of writing the whole low level Bluetooth based functionalities in C++, compiling them into a DLL and finally writing a C# wrapper class and using P/Invoke(s) in order to run the Bluetooth functions. Before going ahead in the development of the wrapper, I've tried to find third-party libraries in C# exposing Bluetooth discovery functionalities, and I found 32feet.NET which seems to be popular from what I've read, however it seems to present some license limitations and after all it is better to have the control on a simpler and customizable wrapper. ArchitectureThe BluetoothConnection class is written in C# and it uses P/Invoke to gain access to exported functions within the WMBluetoothWrapper DLL file. The later is written in C++ and makes use of the Bluetooth functionalities provided by the Winsock 2 API in order to build the devices discovery function. Read more: Codeproject
0 comments:
Post a Comment