Bond deletion after pairing information removed from Android phone, how should the correct peer be selected for deletion?

Setup: SEGGER and running S112  & nRF5_SDK_17.1.0

Don't want to delete all bonds, only the specific one. 

Bonded with Android and Apple smart phone

Delete pairing information from Android phone

 

Start advertising again and attempt to pair again to Android Phone

 

[00:00:02.023,803] <info> app: Fast advertising.

[00:00:02.023,864] <info> peer_manager_handler: Connection security failed: role: Peripheral, conn_handle: 0x0, procedure: Bonding, error: 4352

[00:00:02.023,864] <warning> peer_manager_handler: Disconnecting conn_handle 0.

[00:00:02.023,864] <info> app:  CONN_SEC_FAILED is called for 0 FFFF

[00:00:02.023,864] <info> app: Disconnected

 

 

        case PM_EVT_CONN_SEC_FAILED:

            {

                 pm_peer_id_t peer_id;

                 err_code = pm_peer_id_get(p_evt->conn_handle, &peer_id);

                 err_code = pm_peer_delete(peer_id);

 

                 NRF_LOG_INFO(" CONN_SEC_FAILED is called for %X %X", p_evt->conn_handle, peer_id);

  • Hi KittyHawk, 

    Could you let me know the issue you are facing ? Have you tried to test what you wrote and what's the result ? 

    As far as I know in pm_evt_handler() you can get the peer id directly using p_evt->peer_id . You can call pm_peer_delete() for that peer_id 

  • Unfortunately pm_peer_id_get() is returning PM_PEER_ID_INVALID or 0xFFFF as above

    [00:00:01.346,862] <info> app: Fast advertising.

    [00:00:01.346,923] <info> peer_manager_handler: Connection security failed: role: Peripheral, conn_handle: 0x0, procedure: Bonding, error: 4352

    [00:00:01.346,923] <warning> peer_manager_handler: Disconnecting conn_handle 0.

    [00:00:01.346,923] <info> app: Invalid peer_id

    [00:00:01.346,923] <info> app:  CONN_SEC_FAILED is called for 0 FFFF

     

    err_code = pm_peer_id_get(p_evt->conn_handle, &peer_id);

    if (peer_id != PM_PEER_ID_INVALID)
    {
        err_code = pm_peer_delete(peer_id);
    }
    else

        NRF_LOG_INFO("Invalid peer_id");
    }

    NRF_LOG_INFO(" CONN_SEC_FAILED is called for %X %X", p_evt->conn_handle, peer_id);

  • Hi, 

    Why you have to call pm_peer_id_get() ? 

    I mentioned, peer_id is available as p_evt->peer_id. 

  • Tried that, and you get the same result bad result as calling pm_peer_id_get, see below

    static void pm_evt_handler(pm_evt_t const * p_evt)
    {
    ret_code_t err_code;
    pm_handler_on_pm_evt(p_evt);
    pm_handler_disconnect_on_sec_failure(p_evt);
    pm_handler_flash_clean(p_evt);

    NRF_LOG_INFO("Called with %X %X", p_evt->evt_id, p_evt->peer_id);

    [00:00:01.331,115] <info> app: Fast advertising.
    [00:00:01.331,115] <info> peer_manager_handler: Connection security failed: role: Peripheral, conn_handle: 0x0, procedure: Bonding, error: 4352
    [00:00:01.331,115] <warning> peer_manager_handler: Disconnecting conn_handle 0.
    [00:00:01.331,115] <info> app: Called with 4 FFFF
    [00:00:01.331,115] <info> app: Invalid peer_id
    [00:00:01.331,115] <info> app: CONN_SEC_FAILED is called for 0 FFFF

  • Bit more info it looks as if the peer_id hasn't be set, by the time of the bonding fails

    [00:00:01.701,354] <info> app: Fast advertising.
    [00:00:01.701,416] <info> peer_manager_im: conn_handle 0 Peer_id FFFF
    [00:00:01.701,416] <info> peer_manager_im: conn_handle 1 Peer_id 0
    [00:00:01.701,416] <info> peer_manager_im: conn_handle 2 Peer_id 0
    [00:00:01.701,416] <info> peer_manager_im: conn_handle 3 Peer_id 0
    [00:00:01.701,416] <info> peer_manager_im: conn_handle 4 Peer_id 0
    [00:00:01.701,416] <info> peer_manager_im: conn_handle 5 Peer_id 0
    [00:00:01.701,416] <info> peer_manager_im: conn_handle 6 Peer_id 0
    [00:00:01.701,416] <info> peer_manager_im: conn_handle 7 Peer_id 0
    [00:00:01.701,416] <info> peer_manager_im: conn_handle 8 Peer_id 0
    0
    [00:00:01.701,416] <info> peer_manager_handler: Connection security failed: role: Peripheral, conn_handle: 0x0, procedure: Bonding, error: 4352
    [00:00:01.701,416] <warning> peer_manager_handler: Disconnecting conn_handle 0.
    [00:00:01.701,416] <info> app: Called with evt_id 4 peer_id FFFF
    [00:00:01.701,416] <info> peer_manager_im: conn_handle 0 Peer_id FFFF
    [00:00:01.701,416] <info> peer_manager_im: conn_handle 1 Peer_id 0
    [00:00:01.701,416] <info> peer_manager_im: conn_handle 2 Peer_id 0
    [00:00:01.701,416] <info> peer_manager_im: conn_handle 3 Peer_id 0
    [00:00:01.701,416] <info> peer_manager_im: conn_handle 4 Peer_id 0
    [00:00:01.701,416] <info> peer_manager_im: conn_handle 5 Peer_id 0
    [00:00:01.701,416] <info> peer_manager_im: conn_handle 6 Peer_id 0
    [00:00:01.701,416] <info> peer_manager_im: conn_handle 7 Peer_id 0
    [00:00:01.701,416] <info> peer_manager_im: conn_handle 8 Peer_id 0
    [00:00:01.701,416] <info> peer_manager_im: conn_handle 9 Peer_id 0

    pm_peer_id_t im_peer_id_get_by_conn_handle(uint16_t conn_handle)
    {
        int loop;

        for (loop=0; loop < 10; loop++)
        {
            NRF_LOG_INFO("conn_handle %X Peer_id %X", loop, m_connections[loop].peer_id);
        }

        if ((conn_handle >= IM_MAX_CONN_HANDLES) || !ble_conn_state_valid(conn_handle))
        {
            return PM_PEER_ID_INVALID;
        }

        return m_connections[conn_handle].peer_id;
    }

Related