In the case where connecting to a phone that is paired with my device after my device has cleared pairing information and doesn't remember the pair, I'm observing the following behavior:
When pm_conn_secure is called the first time it returns NRF_SUCCESS and subsequently receive a PM_EVT_CONN_SEC_START and PM_EVT_CONN_SEC_FAILED event. The (android) phone seems to automatically delete the stored pair.
Subsequent calls to pm_conn_secure do not return NRF_SUCCESS and instead return NRF_ERROR_INVALID_STATE. The call produces a PM_EVT_CONN_SEC_PARAMS_REQ event to which I reply with the same ble_gap_sec_params_t I was using before. This return value isn't really explained anywhere and I'm not sure what I'm doing wrong here. Thanks for any input