Bluetooth Desktop Code NETCF

Bluetooth Remote Control

Mike Hall posted a link on his blog to a channel9 interview with Anil Dhawan from the Windows Mobile team discussing Bluetooth programming, which I recommend you check out. Anil gave a demo of a native code application to remote control PowerPoint on a desktop PC. This inspired me to put some finishing touches to a test application I built for the Bluetooth .NETCF library – It is by no means finished but it works (with the wind blowing in the right direction!).

There are two components, on the Smartphone an application which you first select Search from the menu and it will do a lookup of local discoverable devices, then select one and select the Connect menu option. Once connected any d-pad or number keys are captured and sent over bluetooth. As I said it was an unfinished project, key items missing are:-

  • Store desktop address in the registry so we only have to search once

  • More intuitive interface 🙂

  • Support for key mapping – map the device keys to application specific commands e.g. for media player etc

On the desktop a simple listener which listens on a custom service, incoming data is received as keycodes which are broadcast on the system using the SendKeys.Send method.

On an unrelated note, thanks to Sergey Bogdanov who has contributed an implementation of the SendKeys class to be included in the upcoming SDF v1.3 release.

With the listener application running and the Smartphone client connected you can automate (within reason) whatever app has the focus. It works great for Powerpoint browsing between slides using the d-pad on the phone. The usual disclaimer applies – this works only with the Microsoft Bluetooth stack on both device and desktop, I tested with an Orange SPV C500.

The two projects are available to download here.

By Peter Freeman Foot

Microsoft Windows Development MVP

3 replies on “Bluetooth Remote Control”

Once you’ve opened a BluetoothClient to connect over the SerialPort profile you can use the stream returned from the GetStream() method to both write to and read from the remote device you can use the Read() method of the stream to read into a byte array buffer.


Great code sample for the Bluetooth world. I had this working on my Smartphone in no time. I am planning to go forward with it to the extent I want to connect to a serial port service then send commands out. If I change your GUID to the Bluetooth serial port service GUID (includes 0x1011) then I can make the connection and send commands to the other device. But what is the best way to receive the response? I come from a C++ and Widcomm Bluetooth background, but now I am into C# for the SPV.
Regards and thanks,

Comments are closed.