This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

When cutting after bonding, I want to make it BONDED with nRF Connect.

Hello.

I am developing nrf52832 (S132 v7.0.1, SDK v17.0.0) as a peripheral.

What I want to do is to connect to Central, then bond and then disconnect.

Therefore, sd_ble_gap_disconnect is put in PM_EVT_PEER_DATA_UPDATE_SUCCEEDED which seems to be a bonding completion event.
However, when sd_ble_gap_disconnect is done, it is not BONDED in Central (nRF Connect). It seems that the timing of cutting is a little early, but is there a way to cut at the timing when both are bonded?Is there a way to delay the disconnection using a timer?

case PM_EVT_PEER_DATA_UPDATE_SUCCEEDED:
    if (p_evt->params.peer_data_update_succeeded.data_id == PM_PEER_DATA_ID_BONDING) {
        err_code = sd_ble_gap_disconnect(conn_handle, BLE_HCI_CONN_INTERVAL_UNACCEPTABLE);
        APP_ERROR_CHECK(err_code);
    }            
    break;

Best regards.

Parents
  • Hello,

    The key exchange must be completed before receiving the PM_EVT_PEER_DATA_UPDATE_SUCCEEDED {.data_id == PM_PEER_DATA_ID_BONDING} event. This is purely speculation on my part, but maybe there is something internal on the Central stack that causes it to discard the bond if the link is terminated too soon. Either way, I think it would be a good idea to delay the disconnect a bit to allow other less critical bonding data to be stored as well  (CCCD's, etc).

    E.g.

    static void disconnect(void * p_context)
    {
        uint32_t err_code = sd_ble_gap_disconnect(conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
        APP_ERROR_CHECK(err_code);
    }
    
    static void timers_init(void)
    {
        ret_code_t err_code;
    
        // Initialize timer module.
        err_code = app_timer_init();
        APP_ERROR_CHECK(err_code);
        err_code = app_timer_create(&m_disconnect_timer_id,
                                    APP_TIMER_MODE_SINGLE_SHOT,
                                    disconnect);
         APP_ERROR_CHECK(err_code);
         ....
    }
    
    ....
    case PM_EVT_PEER_DATA_UPDATE_SUCCEEDED:
        if (p_evt->params.peer_data_update_succeeded.data_id == PM_PEER_DATA_ID_BONDING) {
    
            /* Disconnect in 2000 ms */
            err_code = app_timer_start(m_disconnect_timer_id, APP_TIMER_TICKS(1000), NULL);
            APP_ERROR_CHECK(err_code);
        }            
        break;
     ...  
        
    

    Best regards,

    Vidar

  • Hello.

    By delaying the disconnection time by 1 second, nRF Connect can now be BONDED.

    It was very helpful. Thank you very much.

    Best regards.

Reply Children
No Data
Related