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

Peer manager, bonding fails with error code 133

I am working on two devices, a peripheral and a central.  The peripheral is custom hardware.  The central is being run on a Rigado BMD-300 series evaluation kit.  I'm using Segger IDE and NRF5 SDK 16.

I can get the central and peripheral to pair consistently.  Discovery works and the central sees the characteristics (and changes) correctly.  Now I'm working on bonding and whitelisting.

After discovery is complete (in the discovery event handler), I am calling pm_conn_secure():

// Initiate bonding.
ret_code_t err_code = pm_conn_secure(p_evt->conn_handle, false);
NRF_LOG_DEBUG("Called pm_conn_secure, conn_handle = %d, err_code = %d", p_evt->conn_handle, err_code);
if (err_code != NRF_ERROR_BUSY)
{
  APP_ERROR_CHECK(err_code);
}

which returns NRF_SUCCESS.  Quickly thereafter, I get a PM_EVT_CONN_SEC_FAILED event in the Peer Manager event handler.  In the logs, I  see the following:

changes to <debug> app: Called pm_conn_secure, conn_handle = 0, err_code = 0

<debug> nrf_ble_gq: Processing the request queue...

<debug> nrf_ble_gq: Processing the request queue...

<info> peer_manager_handler: Connection security failed: role: Central, conn_handle: 0x0, procedure: Bonding, error: 133

<debug> app: Got PM_EVT_CONN_SEC_FAILED event

<debug> nrf_ble_gq: Processing the request queue...

<debug> nrf_ble_gq: Processing the request queue...

Questions:

1) Is there something I have to do in the peripheral to allow bonding?

2) Any ideas on what could be causing this?

  • Here is my peer_manager_init():

    static void peer_manager_init(void)
    {
        ble_gap_sec_params_t sec_param;
        ret_code_t err_code;
    
        err_code = pm_init();
        APP_ERROR_CHECK(err_code);
    
        memset(&sec_param, 0, sizeof(ble_gap_sec_params_t));
    
        // Security parameters to be used for all security procedures.
        sec_param.bond           = true;
        sec_param.mitm           = false;
        sec_param.lesc           = false;
        sec_param.keypress       = false;
        sec_param.io_caps        = BLE_GAP_IO_CAPS_NONE;
        sec_param.oob            = false;
        sec_param.min_key_size   = 7;
        sec_param.max_key_size   = 16;
        sec_param.kdist_own.enc  = 1;
        sec_param.kdist_own.id   = 1;
        sec_param.kdist_peer.enc = 1;
        sec_param.kdist_peer.id  = 1;
    
        err_code = pm_sec_params_set(&sec_param);
        APP_ERROR_CHECK(err_code);
    
        err_code = pm_register(pm_evt_handler);
        APP_ERROR_CHECK(err_code);
    }
    

  • Hi, 

    Are you sure the peripheral is supposed to support bonding? The log shows the peripheral is responding with status code 133/0x85 which corresponds to BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP (MSC: Pairing failure: Pairing aborted by the application). Maybe you can try to bond with the peripheral using our nRF connect app on Android/iOS and see if that works

  • I'm not sure why it's getting that error, it certainly supports pairing.  I can pair with nRF Connect on my phone and BlueSee on my desktop.

    No I'm not sure if the peripheral supports bonding, that's why I asked if there is anything I need to do in the peripheral to support bonding.  I copied the peer_manager_init() function from the hrs example and it is supposed to support bonding.

    nRF Connect does connect to the peripheral and correctly show the characteristics.  How do I tell if the app is bonded?

    Thanks.

  • I see. I thought maybe the peripheral was an existing device at first. Please check that you are not handling the following events in your application (should only be handled internally in Peer manager) :

    static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
    {
    ...
            case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
                // Pairing not supported
                err_code = sd_ble_gap_sec_params_reply(m_conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL);
                APP_ERROR_CHECK(err_code);
                break;
    
            case BLE_GATTS_EVT_SYS_ATTR_MISSING:
                // No system attributes have been stored.
                err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, 0);
                APP_ERROR_CHECK(err_code);
                break;
    ..

  • I had code in for BLE_GATTS_EVT_SYS_ATTR_MISSING, I have removed it and it still doesn't bond.  Same error.

    How do these events get to the peer manager, is there anything that I need to do?

    Again, how do I tell if nRF Connect is bonded?

Related