I am using SEGGER Embedded Studio and an nRF52-SDK circuit board to run example ble_central\ble_app_hrs_c from nRF5_SDK_17.0.2. I have a peripheral that reports motions. The problem is that I can only connect the peripheral once to the HRS central.
First time the HRS C says:
<info> app: Connected.
<info> app: GATT ATT MTU on connection 0x0 changed to 247.
<info> app: Data length for connection 0x0 updated to 27.
<info> app: BLE_GAP_EVT_LESC_DHKEY_REQUEST
<info> app: Battery Level Read as 100 %.
<info> nrf_ble_lesc: Calling sd_ble_gap_lesc_dhkey_reply on conn_handle: 0
<info> peer_manager_handler: Connection secured: role: Central, conn_handle: 0, procedure: Bonding
<info> app: BLE_GAP_EVT_AUTH_STATUS: status=0x0 bond=0x1 lv4: 0 kdist_own:0x3 kdist_peer:0x2
<info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Bonding data, action: Update
<info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Peer rank, action: Update
<info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Central address resolution, action: Update
And when I move the sensorn it HRS C receives and forwards data:
<info> app: Heart Rate = 367.
<info> app: Heart Rate = 395.
<info> app: Heart Rate = 642.
The printouts come from case BLE_HRS_C_EVT_HRM_NOTIFICATION in function hrs_c_evt_handler().
So far all well, but if I disconnect the sensor and re-connects it I get the following error messages:
<info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Peer rank, action: Update, no change
<info> app: Connected.
<info> app: GATT ATT MTU on connection 0x0 changed to 247.
<info> peer_manager_handler: Connection security failed: role: Central, conn_handle: 0x0, procedure: Encryption, error: 4102
<info> app: Data length for connection 0x0 updated to 27.
<info> peer_manager_handler: Connection security failed: role: Central, conn_handle: 0x0, procedure: Encryption, error: 4102
<info> app: Battery Level Read as 100 %.
<info> app: Disconnected, reason 0x13.
Then I have to use the PC-program nRF Connect/Programmer to erase nRF52-SDK and re-load the firmware to make it work again.
What is wrong?