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

central encryption error (ble_app_hrs_c)

Hi, I'm using nRF52832 Software Development Kit, PCA10040, S132.

I'm getting this error while trying to connect with my device in the "ble_app_hrs_c".

"Connection security failed: role: Central, conn_handle: 0x0, procedure: Encryption, error: 4102"

It can be seen in this section and recognized as a security error in the peer_manager section.

void pm_handler_pm_evt_log(pm_evt_t const * p_pm_evt)
{
    NRF_LOG_DEBUG("Event %s", m_event_str[p_pm_evt->evt_id]);

    switch (p_pm_evt->evt_id)
    {
        case PM_EVT_BONDED_PEER_CONNECTED:
            NRF_LOG_DEBUG("Previously bonded peer connected: role: %s, conn_handle: %d, peer_id: %d",
                          m_roles_str[ble_conn_state_role(p_pm_evt->conn_handle)],
                          p_pm_evt->conn_handle,
                          p_pm_evt->peer_id);
            break;

        ...

        case PM_EVT_CONN_SEC_FAILED:
            NRF_LOG_INFO("Connection security failed: role: %s, conn_handle: 0x%x, procedure: %s, error: %d",
                         m_roles_str[ble_conn_state_role(p_pm_evt->conn_handle)],
                         p_pm_evt->conn_handle,
                         m_sec_procedure_str[p_pm_evt->params.conn_sec_start.procedure],
                         p_pm_evt->params.conn_sec_failed.error);
            NRF_LOG_DEBUG("Error (decoded): %s",
                          sec_err_string_get(p_pm_evt->params.conn_sec_failed.error));
            break;
            
        ...
    }
}

What caused this error? How can I fix the error?

BR,

Lyrics

Parents
  • Hi,

    The "4102" error corresponds to PM_CONN_SEC_ERROR_PIN_OR_KEY_MISSING and it indictates that the bonding information is deleted on the peripheral, but not on the central side. Can you try deleteing the bonding information on the central as well?

    Best regards,

    Vidar

  • Thank you for your reply.

    I succeeded in connecting using delete_bonds() as you helped me.

    void scanning_start(bool * p_erase_bonds)
    {
        // Start scanning for peripherals and initiate connection
        // with devices that advertise GATT Service UUID.
        if (*p_erase_bonds == true)
        {
            // Scan is started by the PM_EVT_PEERS_DELETE_SUCCEEDED event.
            delete_bonds();
        }
        else
        {
            delete_bonds();
            //scan_start();
        }
    }

    But it seems like I have to call that function every time to connect correctly. What is the reason?

Reply
  • Thank you for your reply.

    I succeeded in connecting using delete_bonds() as you helped me.

    void scanning_start(bool * p_erase_bonds)
    {
        // Start scanning for peripherals and initiate connection
        // with devices that advertise GATT Service UUID.
        if (*p_erase_bonds == true)
        {
            // Scan is started by the PM_EVT_PEERS_DELETE_SUCCEEDED event.
            delete_bonds();
        }
        else
        {
            delete_bonds();
            //scan_start();
        }
    }

    But it seems like I have to call that function every time to connect correctly. What is the reason?

Children
Related