I'm evaluating possibilities of BLE-LESC Pairing/Bonding with the ble_app_hrs peripheral on the nRF52840-DK with SDK 12.3 and SoftDevice s132.
To see what's going on in the background I used the nRF BLE sniffer (on a nRF52840-PDK).
The parameters I used on the peripheral for pm_sec_params_set are:
sec_param.bond = 0;
sec_param.io_caps = BLE_GAP_IO_CAPS_NONE;
sec_param.lesc = 1;
sec_param.oob = 0;
sec_param.min_key_size = 7;
sec_param.max_key_size = 16;
sec_param.mitm = 0;
sec_param.kdist_own.enc = sec_param.bond;
sec_param.kdist_own.id = sec_param.bond;
sec_param.kdist_peer.enc = sec_param.bond;
sec_param.kdist_peer.id = sec_param.bond;
When I now call device.createBond() in the app, the Phone sends a Authentication Request with Bonding (MITM, IO Caps: Keyboard, Display, and all keys) and the DK doesn't respond to this request. The connection breaks after a few seconds.
When changing sec_params.bond to 1 on the peripheral, a Bonding response is sent, the connection is encrypted and data can be sent.
I already implemented the DH Key Exchange for lesc by overriding BLE_GAP_EVT_LESC_DHKEY_REQUEST as done in ble_app_multirole_lesc with the uECC implementation (works), and called createBond in the App via overriding onDeviceConnected() in HRSActivity.java.
I've put the source code on GitHub for reference:
ble_app_hrs: https://github.com/dCSeven/BLE_HRS_LESC
Android_nRF_Toolbox: github.com/.../develop
Since no bonding would be preferred, the question is: What should I do different, to get pairing working?