This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Anyone able to pair using the pc-ble-driver

I thought this should be very simple but it has not turned out that way. I have started with the pc-ble-driver heart rate monitor (peripheral) example. I was able to take the example, build it in Visual Studio and run it on a PC. The monitor connected and sent measurements to a personal health gateway client. However, it does it 'in the clear' (no pairing/encryption).

So I changed the setting on the heart rate characteristic client configuration descriptor from

BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.write_perm); to

BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&cccd_md.write_perm);

which should cause an insufficient authentication error when the gateway central tries to write to this descriptor. And it does. The client responds to this error as it should by initiating the pairing sequence.

So in the ble_evt_dispatch() method I added a new case statement to catch that event

case BLE_GAP_EVT_SEC_PARAMS_REQUEST:

I print out the capabilities and list of requested keys sent by the gateway and they all make sense. Now according to the documentation, I am supposed to create a structure that contains my capabilities and the list of keys I wish to request from the client and send that using the 

sd_ble_gap_sec_params_reply()

method. The documentation does clearly state that there are two items one cannot request (as they are unsupported) so I make certain that those items are set to 0 (false). But when I make the call, the method returns NRF_ERROR_NOT_SUPPORTED. This modification is such a small modification from the original example it has me greatly concerned. It is the only 'sd_*' call I make that was not in the original example.

  • Has anyone succeeded in adding pairing to a peripheral using this driver?
  • I did ask whether it was okay to send the reply in the callback and I was informed that it was okay so I am assuming that is not the cause of the issue.
  • I have changed some other parameters in the input struct and gotten other error responses that make no sense.

If anyone has been able to handle pairing on the peripheral side in a pc-ble-driver application I would greatly appreciate your help! I can only think it has to be some trivial piece of information missing given how small the modification is from the start example. It has blocked me for a few weeks and I cannot move forward if I cannot do something a basic as pairing.

Related