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

ble_nus_data_send error

Hi, 

Recently, I've found a reset issue with my device by ble_nus_data_send error when ble is working.

But the error code is 0x3401(Please, refer the picture). What does that mean? Is there any other header with the definitions than nrf_error.h?

Before handling the error, I need to understand why that error happened and what kind of errors it is.

Thank you.

[code for ble_nus_data_send]

    if(m_conn_handle != BLE_CONN_HANDLE_INVALID)
    {
        // uint32_t err_code;
        do
        {
            err_code_test = ble_nus_data_send(&m_nusdata_array, &lengthm_conn_handle);
            if((err_code_test != NRF_ERROR_INVALID_STATE) &&
               (err_code_test != NRF_ERROR_RESOURCES) &&
               (err_code_test != NRF_ERROR_NOT_FOUND))
            {
                APP_ERROR_CHECK(err_code_test);
            }
        } while(err_code_test == NRF_ERROR_RESOURCES && block);
    }
[exception call stack captured]
Parents
  • Hi,

    As allready mentioned, the error code is BLE_ERROR_GATTS_SYS_ATTR_MISSING. You can probably fix the issue by calling this before (for instance when handling the connected event):

    err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, 0);
    APP_ERROR_CHECK(err_code);

  • Thank you for your answer.

    I have already the code in the BLE_GATTS_EVT_SYS_ATTR_MISSING case of ble evt handler.

    But You mean putting sd_ble_gatts_sys_attr_set in the  BLE_GAP_EVT_CONNECTED case of ble evt handler like the code below?

    static void ble_evt_handler(ble_evt_t constp_ble_evtvoidp_context)
    {
        uint32_t err_code;

        switch(p_ble_evt->header.evt_id)
        {
        case BLE_GAP_EVT_CONNECTED:
            m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
            err_code = nrf_ble_qwr_conn_handle_assign(&m_qwrm_conn_handle);
            APP_ERROR_CHECK(err_code);
            err_code = sd_ble_gatts_sys_attr_set(m_conn_handleNULL00);
            APP_ERROR_CHECK(err_code);
            break;

    This issue happens just sometimes with ble connecting & disconnecting with other scheduled jobs.

    Also, there is another reset with sd_ble_gap_conn_param_update returning NRF_ERROR_INVALID_STATE in the same test condition.

    I found these 2 posts below about the errors and I filtered out the errors so that the device will not be reset by app error check and it seems the issues were fixed. Does it also make sense?

    https://devzone.nordicsemi.com/f/nordic-q-a/50227/ble-uart-issue/200615#200615

    https://devzone.nordicsemi.com/f/nordic-q-a/52433/stopping-ble_conn_params-c-s-timers-while-supporting-concurrent-connections/211500#211500

  • Hi,

    eleven-x_devteam said:
    But You mean putting sd_ble_gatts_sys_attr_set in the  BLE_GAP_EVT_CONNECTED case of ble evt handler like the code below?

    Yes. This is just to set it as early as possible.

    eleven-x_devteam said:
    I found these 2 posts below about the errors and I filtered out the errors so that the device will not be reset by app error check and it seems the issues were fixed. Does it also make sense?

    I am not sure how this is relevant, but this post provided a viable solution, as long as you are happy with the ble_nus_data_send() call failing silently and you set the system attributes later. The key is that this will fail until the system attributes is set, and you can handle it in several different ways.

Reply
  • Hi,

    eleven-x_devteam said:
    But You mean putting sd_ble_gatts_sys_attr_set in the  BLE_GAP_EVT_CONNECTED case of ble evt handler like the code below?

    Yes. This is just to set it as early as possible.

    eleven-x_devteam said:
    I found these 2 posts below about the errors and I filtered out the errors so that the device will not be reset by app error check and it seems the issues were fixed. Does it also make sense?

    I am not sure how this is relevant, but this post provided a viable solution, as long as you are happy with the ble_nus_data_send() call failing silently and you set the system attributes later. The key is that this will fail until the system attributes is set, and you can handle it in several different ways.

Children
No Data
Related