Struggling with pairing/connecting headset on handheld (winCE)

Topics: Bluetooth - Microsoft
Nov 17, 2016 at 11:08 AM
Hello all,

I'm struggling with pairing a Bluetooth headset and setting appropriate services. For an application (where the users are not supposed to have access to the OS) I'm trying to do is:
  • Find Bluetooth devices
  • pair with selected headset
  • call SetServiceState for services HandsFree and AudioSink
So far, enumerating and pairing of device seems to work, but SetServiceState has no effects, even after restart of handheld device.
First thing I've encountered, the method SetServiceState tries to write some registry entries, for that OpenSubKey is called on HKLM. But as the key that is supposed to be opened is not (yet) existing, the value of enabled=1 is not set.
So to fix that I copied the code from SetServiceState and changed the implementation using CreateSubKey instead of OpenSubKey and did some other modifications.
Now the registry entries looks quite good, but the headset is not properly connected, so even after reboot of handheld device and restart of headset, the audio is not directed to the headset.

I tried to use the OS Bluetooth Settings tool. Doing that the headset is paired and connected successfully (although a restart of the headset seems to be required).

I appreciative any sort of help. What I'm trying to do, is it actually possible?? What is the OS tool doing different, do I miss another API call after SetServiceState?