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

How do I pair in pc-ble-driver-py?

I'm using python code based on the heart_rate_collector.py example in pc-ble-driver-py to scan for devices and connect to a peripheral device.  That works fine.

Now I'd like to pair/authenticate with a connected device (this uses a known passkey).  Unfortunately I could not find any examples of establishing a secure connection in pc-ble-driver-py.

I looked around and the https://github.com/NordicSemiconductor/pc-nrfutil/blob/master/nordicsemi/dfu/dfu_transport_ble.py code has an example of using ble_gap_authenticate() and ble_gap_sec_params_reply() from python.  Unfortunately, the ble_gap_sec_params_reply() calling signature there has more parameters than the one in the current version of pc-ble-driver-py, so I'm not sure if that code is expected to work or how to adapt it.

P.S. My environment is Ubuntu 16.04LTS, pc-ble-driver-py v0.11.4 (installed from pip) and nRD51 DK.

  • Updated: I can apperently call ble_gap_sec_params_reply(self.conn_handle, BLEGapSecStatus.success, None).  This still doesn't work - no errors, but no call back to on_gap_evt_auth_status() either. 

    A simple working example that shows ble_gap_authenticate, ble_gap_sec_params_reply, ble_gap_encrypt and ble_gap_auth_key_reply in python would be greatly appreciated.

Related