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

Peer manager - pm_conn_secure returning invalid state

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

Parents
  • Hi

    Are you able to see what error code  the PM_EVT_CONN_SEC_FAILED event generates in the first place?

    NRF_ERROR_INVALID STATE  returns from pm_conn_secure is explained in peer_manager.h as "If the Peer Manager is not initialized." So you will have to reinitialize the peer manager if you are getting this return value. 

    Best regards,

    Simon

Reply
  • Hi

    Are you able to see what error code  the PM_EVT_CONN_SEC_FAILED event generates in the first place?

    NRF_ERROR_INVALID STATE  returns from pm_conn_secure is explained in peer_manager.h as "If the Peer Manager is not initialized." So you will have to reinitialize the peer manager if you are getting this return value. 

    Best regards,

    Simon

Children
Related