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

ble_nus_data_send is returning NRF_ERROR_RESOURCES.

ble_nus_data_send is returning NRF_ERROR_RESOURCES. I would like to increase the Tx Queue size, but as it is not straight forward to increase by changing the macro BLE_GATTS_HVN_TX_QUEUE_SIZE_DEFAULT. I would like to know what are the other things i need to change along with this macro.

Also I tried waiting for the TX_RDY_EVT after receiving the nrf-error-resources. sometimes that even is not at all happening and it si get stuck there forever. Please suggest me on what can be done in such a case step by step

  • Hello,

    ble_nus_data_send is returning NRF_ERROR_RESOURCES.

    I suspect that you have already seen the reason for this error in the functions API Reference documentation, but I mention it here just in case. The NRF_ERROR_RESOURCES is caused by queueing too many notifications.
    To remedy this, you could indeed increase the queue size like you suggest - but you should also verify that you are not attempting to send far more notifications than your connection parameters will allow for.
    If you would like to increase the queue size, please see the answer by my colleague Sigurd in this ticket.

    Also I tried waiting for the TX_RDY_EVT after receiving the nrf-error-resources. sometimes that even is not at all happening and it si get stuck there forever.

    Are you saying that you never receive a BLE_GATTS_EVT_HVN_TX_COMPLETE event?
    If so, have you made sure that your event handler is registered as an observer to the BLE events?
    Is your event handler receiving other BLE events - or have you created a separate handler for this?
    If you could share how you have implemented this, that would be very helpful.

    Looking forward to resolving this issue together!

    Best regards,
    Karl

  • Thanks for the quick response. I will check the resources shared.

    From the Sigurd ticket: I see the following code snippet:

    ble_cfg_t ble_cfg;
    memset(&ble_cfg, 0, sizeof ble_cfg);
    ble_cfg.conn_cfg.conn_cfg_tag = APP_BLE_CONN_CFG_TAG;
    ble_cfg.conn_cfg.params.gatts_conn_cfg.hvn_tx_queue_size = 50;
    err_code = sd_ble_cfg_set(BLE_CONN_CFG_GATTS, &ble_cfg, ram_start);
    APP_ERROR_CHECK(err_code);

    what is the functionality of this and is this required for peripheral devices or for central or both?

    To clarify you on TX_RDY_EVT related queries:

    Yes, we are saying BLE_GATTS_EVT_HVN_TX_COMPLETE event.

    yes, we have registered as an observer.

    yes, we are receiving other events. even this BLE_GATTS_EVT_HVN_TX_COMPLETE  event happens but sometimes it stuck there indefinitely.

    I will refer the other resources and come back.

  • Punithkumar said:
    Thanks for the quick response.

    No problem at all, I am happy to help!

    Punithkumar said:
    what is the functionality of this and is this required for peripheral devices or for central or both?

    The purpose of this code is to change the hvn_tx_queue_size, as you asked about in your original ticket.
    However, you will also need to ensure that you are not queueing more notifications than you are sending - if this is the case, it will not help to increase the queue size, it will just postpone the NRF_ERROR_RESOURCES error.

    Punithkumar said:

    yes, we have registered as an observer.

    yes, we are receiving other events. even this BLE_GATTS_EVT_HVN_TX_COMPLETE  event happens but sometimes it stuck there indefinitely.

    Great! I had to ask, just to make sure. It is a common pitfall to forget.
    So, you are getting the TX_COMPLETE event, but you are getting stuck there?
    That sounds very strange. How are you handling this event in your event handler?

    Best regards,
    Karl

  • Hi,

    Currently we are handling in floowing ways:

    the send API() :

    do
    {
    err_code = ble_nus_data_send(&m_nus, ble_data_array, &tx_pkt_len, m_conn_handle);
    if(err_code == NRF_ERROR_RESOURCES)
    {
    gsErrResources = 1;
    nrf_pwr_mgmt_run();

    }

    } while (err_code == NRF_ERROR_RESOURCES && gsErrResources);

    In case of no NRF_ERROR_RESOURCES, it simply submits the buffer and return; else it sets the flag gsErrResources = 1; and wait for an event and checks if this flag has become zero, if not it tries to submit again and waits for an event  nrf_pwr_mgmt_run(). The flag gsErrResources becomes zero when the TX_COMPLETE event get raised. 

    This works, but some of the time it indefinitely get stuck here and gsErrResources = 1 always. and no TX_COMPLETE event is getting raised.

    Please suggest where could it go wrong and how can we debug this scenario.

  • The purpose of this code is to change the hvn_tx_queue_size, as you asked about in your original ticket

    Currently we are not using this code snippet in our system ble-stack-init(), adding code snippet causing the system to hit NRF_BREAKPOINT_CONDITION. why could this be happening, what is the way to over come this?

Related