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

How to disable disconnection of Peripheral device from the central?

I am using ble_app_uart in one nRF52 EVK board(peripheral) and ble_app_uart_c in another nRF52 EVK(central) and sending data of Device under test through UART. When the data is more( continuous stream of data) the peripheral is getting disconnected from the central. I don't want the disconnection event. Instead it can skip the excess of incoming data. i.e., it can avoid excess data without disconnection. How to do this ? What are the function I have to comment, to achieve this.

  • Hi,

    What is happening is that you are most likely running out of available buffers, as described in the answer in your previous question here. You then get an error code when you are trying to send the data. This error code is passed into the error-handler (APP_ERROR_CHECK(err_code)), where the default behavior is to do a reset. You will then disconnect. If you want to just ignore this error-message, and discard the data, you should not check for that particular error-message.

    Assuming that it's the ble_nus_string_send() function that is generating this error, and that you are using SDK 13, you could ignore the error-code like this by adding a check for NRF_ERROR_RESOURCES :

    err_code = ble_nus_string_send(&m_nus, data_array, index);
    if ((err_code != NRF_ERROR_INVALID_STATE) || (err_code != NRF_ERROR_RESOURCES))
    {
        APP_ERROR_CHECK(err_code);
    }
    

    Note: If you are using SDK 12, check for BLE_ERROR_NO_TX_PACKETS instead of NRF_ERROR_RESOURCES.

Related