I ended up just working through the Bluetooth_Pairing_Test after modifying it to take out the serial port and the button (both of which are on order from GHI).
So, whichever driver is in there.
I had problems with PC program exceptions running on the PC side with the Listener project, but that’s before I figured out how all this pairing was supposed to work. You have to run it as Admin, and that took care of some exceptions, but then there were others. Not sure why.
Interestingly, I get exceptions sometimes when I run the Bluetooth_Pairing_Test. I think it was involved with the BTSTATE routine. I just re-run it and the problem doesn’t appear.
I’ll figure it out and post what is happening. I got so excited when I figured it out and then I had to rush home to see Denver get clobbered in the big game.
What was happening was I would key in the PIN and pair the device the phone, but the app wasn’t really running. Then I would try again, but the device was already paired with the phone, and when the device would go into pairing mode, everything would get confused. I’d end up deleting the pairing on the phone and things went downhill from there.
When the pairing was messed up, the phone app would throw errors about not be able to connect to a network. Another rabbit hole.
So it came down to timing…
- Delete the Bluetooth profile off the phone.
- Fire up the device and let it go into pairing mode
- Pair the device on the phone with the PIN
- Right away, open the phone app, search for the device and open a socket it to it.
From that point on, everything seems to work fine, including checking to see if the device is connected before going into pairing mode. I could terminate the phone app, reboot the device and it all worked as expected.
And now it makes perfect sense why there has to be a physical button on the device to force it into pairing mode. You could already have an unpaired profile on the phone and the device won’t see it. Then it’ll pop into pairing mode and then you’re stuck again. I don’t believe you can actually get this to work without a physical button.
I skimmed that Pan-Head article, but haven’t studied it yet.
I ended up buying a Nokia 520 off contract for $59 and joining the MS Store developer program for $19 to do the experimentation.