Hello there!
We are using nRF51822 SoC with nRF5 SDK v12.3.0.
Our nRF51822 SoC that acts as a BLE peripheral pairs and bonds with the smartphone running Android or iOS. Sometimes, we hit the PM_EVT_CONN_SEC_FAILED case in the Peer Manager event handler callback function:
case PM_EVT_CONN_SEC_FAILED:
{
uint32_t ret;
ret = pm_conn_secure(m_conn_handle, false);
if (ret != NRF_ERROR_INVALID_STATE)
{
APP_ERROR_CHECK(ret);
}
/* Often, when securing fails, it shouldn't be restarted, for security reasons.
* Other times, it can be restarted directly.
* Sometimes it can be restarted, but only after changing some Security Parameters.
* Sometimes, it cannot be restarted until the link is disconnected and reconnected.
* Sometimes it is impossible, to secure the link, or the peer device does not support it.
* How to handle this error is highly application dependent. */
} break;
When that happens once, we are entering the infinite loop of the following events:
- We hit PM_EVT_CONN_SEC_FAILED case
- BLE disconnects
- BLE re-connects
- We hit PM_EVT_CONN_SEC_FAILED case
As you can see from the code snippet I shared with you, we are trying to re-establish a secure connection when PM_EVT_CONN_SEC_FAILED event happens (with the pm_conn_secure() function) but to no avail. We also tried to delete the peers with the pm_peers_delete() function but neither that action prevented the issue.
Can you give us any advice about how to properly handle this event? It's not a problem for us to break the connection and unpair from the mobile phone when that happens, everything is acceptable, just to prevent a continuous loop of disconnects and re-connects. Is there anything we should do on the mobile side to prevent this?
Thanks in advance.
Sincerely,
Bojan.