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

BLE bonding/pairing with pc-ble-driver-py

Hi,

Does the pc_ble_driver_py contain any API for paring or bonding bluetooth devices? And if so, do you have any examples or documentation which explain how to use them?

I see that the ble_adaptor class has authenticate() and encrypt() functions which I assume are relevant to pairing, but I don't know how to implement them. The included heart rate collector example does not use these functions, and I can't find any documentation which explains them. My problem sounds similar to this issue below, but that is from over 2 years ago. Is there any new information you can give me?
Thanks,

https://devzone.nordicsemi.com/f/nordic-q-a/17497/pc-ble-driver-py-pairing-bonding

James

Parents
  • Hi,

    You should have a look at the API documentation of the softdevice functions mentioned in the implementation of Authenticate and Encrypt methods, and check how they are used in the SDK examples:

    Best regards,
    Jørgen

  • Hi Jørgen, thanks for getting back to me.

    I've had a look at the documentation you linked to and I'm still having issues with my program. To setup bonding my code is currently: 

    self.sec_params = BLEGapSecParams(bond=True,
                                      mitm=False,
                                      lesc=False,
                                      keypress=False,
                                      io_caps=BLEGapIOCaps.none,
                                      oob=False,
                                      min_key_size=7,
                                      max_key_size=16,
                                      kdist_own=self.kdist_own,
                                      kdist_peer=self.kdist_peer)
    
    self.adapter.driver.ble_gap_authenticate(self.conn_handle, self.sec_params)
    self.evt_sync.wait(evt="sec_params")
    self.adapter.driver.ble_gap_sec_params_reply(self.conn_handle,
                                                 BLEGapSecStatus.success,
                                                 None)
    
    

    But this fails with the message "pc_ble_driver_py.exceptions.NordicSemiException: Failed to ble_gap_sec_params_reply. Error code: 8"

    I have also tried running:

    collector.adapter.authenticate(conn_handle, bond=True)
    

    But this failed with the same error. Is there something I'm missing that's causing this?

    Thanks,

    James

Reply
  • Hi Jørgen, thanks for getting back to me.

    I've had a look at the documentation you linked to and I'm still having issues with my program. To setup bonding my code is currently: 

    self.sec_params = BLEGapSecParams(bond=True,
                                      mitm=False,
                                      lesc=False,
                                      keypress=False,
                                      io_caps=BLEGapIOCaps.none,
                                      oob=False,
                                      min_key_size=7,
                                      max_key_size=16,
                                      kdist_own=self.kdist_own,
                                      kdist_peer=self.kdist_peer)
    
    self.adapter.driver.ble_gap_authenticate(self.conn_handle, self.sec_params)
    self.evt_sync.wait(evt="sec_params")
    self.adapter.driver.ble_gap_sec_params_reply(self.conn_handle,
                                                 BLEGapSecStatus.success,
                                                 None)
    
    

    But this fails with the message "pc_ble_driver_py.exceptions.NordicSemiException: Failed to ble_gap_sec_params_reply. Error code: 8"

    I have also tried running:

    collector.adapter.authenticate(conn_handle, bond=True)
    

    But this failed with the same error. Is there something I'm missing that's causing this?

    Thanks,

    James

Children
No Data
Related