I’ve uploaded a new release of the Bluetooth library which adds the key feature of hosting services over bluetooth. This now allows two-way communications between devices and to demonstrate how this works I’ve included a sample Bluetooth Chat application. This registers a custom bluetooth profile and listens for incoming connections, and creates outgoing connections using this service identifier to other devices. In this way it only communicates with other devices exposing this service and wont interfere with any other applications using Bluetooth.
Thanks go out to Wei-Meng Lee for giving permission to base the sample on his previous IrDA chat application available with this MSDN article. The Bluetooth version works in a very similar way, with the exception of doing a device discovery when it first loads. An enhancement yet to be added is the ability to periodically discover in a background thread. From the app screen select the target device which must also be running the software and Bluetooth must be Discoverable. Then type your message and click send and it will appear onscreen on the other device. In the below example I had a brief conversation with Santa who was half-way up a chimney at the time – such is the versatility of Bluetooth 🙂
The ZIP file below includes the Bluetooth library project and compiled output, and the BTChat sample project. As I get time to do more work on the library I’ll post some other examples, and include versions for other platforms e.g. Smartphone and XP.
- Hosting services doesn’t yet work on XP (some of the structures are slightly different so this requires a little more work)
- BluetoothClient.RemoteDeviceName doesn’t work so you can’t retrieve the device name from an open connection (Device names work correctly during discovery on both Windows CE and XP)
- BluetoothSerialPort (For emulating a COM port) is not fully tested and probably doesn’t work – SerialPortProfile connections work great using sockets (BluetoothClient).
- SDF v1.2
- Windows CE Device or Windows XP computer using the Microsoft Bluetooth stack (Sorry but Widcomm is not supported).
If you have any comments or questions please drop me an email. For now all that remains is for me to wish you a Very Merry Christmas!