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

    The error 0x1006 (PM_CONN_SEC_ERROR_PIN_OR_KEY_MISSING) indicates that the phone hasn't deleted the stored pair, so if you do this before the first connection I think this should work fine.

    This post deals with a similar issue, so maybe you can find some hints there if this still doesn't work.

    Best regards,

    Simon

  • Thanks for your help so far.  This is indeed the case (phone has not deleted the stored pair, but nrf device has).  I'm wondering how to get peer manager to secure the connection (where the phone user approves pairing request again) in the same connection, because the current flow is to disconnect and let the next connection send pairing request.  I'd like to use peer manager properly in the same connection to enhance user experience but the way to use peer manager in this case isn't clear.

Reply
  • Thanks for your help so far.  This is indeed the case (phone has not deleted the stored pair, but nrf device has).  I'm wondering how to get peer manager to secure the connection (where the phone user approves pairing request again) in the same connection, because the current flow is to disconnect and let the next connection send pairing request.  I'd like to use peer manager properly in the same connection to enhance user experience but the way to use peer manager in this case isn't clear.

Children
No Data
Related