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

pm_conn_secure fails 0x3002

Hello,

I'm trying to migrate to Peer Manager, but I have a problem. This code returns error BLE_ERROR_INVALID_CONN_HANDLE constantly.

static void on_ble_evt(ble_evt_t * p_ble_evt)
{
...
    case BLE_GAP_EVT_CONNECTED:                 					
         err_code = pm_conn_secure(p_gap_evt->conn_handle, false);
         APP_ERROR_CHECK(err_code);
    break;

Device has the Central role. Where is my mistake?

Best Regards,

Pavel

my_proj.zip

  • Peer Manager has a uses the Connection State module. Could it be that you have not initalized it, or added ble_conn_state_on_ble_evt() to event dispatcher?

  • Hi Petter, No, I added, but I can provide you some additional information.

    ble_conn_state_role(p_gap_evt->conn_handle) called before pm_conn_secure() returns BLE_GAP_ROLE_INVALID.

  • That is what I suspected. You have added ble_conn_state_on_ble_evt()? Before on_ble_evt()?

  • Are you right. I added it after on_ble_evt, not before. Now, I have added it before and I get BLE_GAP_ROLE_CENTRAL. That's great! But pm_conn_secure() returns internal error 0x0003. The reason of that is im_peer_id_get_by_conn_handle(conn_handle) returns PM_PEER_ID_INVALID.

  • So im_peer_id_get_by_conn_handle() returns PM_PEER_ID_INVALID which makes link_secure_central_new_peer() return NRF_ERROR_INTERNAL. I'm not entirely sure what is causing this. You have pm_on_ble_evt() in ble_evt_dispatch() yes? Maybe you could edit your question and upload your complete project so I could test it here? What SDK and SoftDevice version are you using?

1 2