How to send data continuously with NUS?

Dear Nordic fellows,

I have a nRF52832 and I want to use Nordic UART Service to send data in peripheral mode. What is the proper way to use this service?. I'm using nRF5_SDK17.1.0

The ble_app_uart example performs a do while loop with condition err_code == NRF_ERROR_RESOURCES. But doing it this way I can not perform a continuous data transmission.

do
{
    uint16_t length = (uint16_t)index;
    err_code = ble_nus_data_send(&m_nus, data_array, &length, m_conn_handle);
    if ((err_code != NRF_ERROR_INVALID_STATE) &&
        (err_code != NRF_ERROR_RESOURCES) &&
        (err_code != NRF_ERROR_NOT_FOUND))
    {
        APP_ERROR_CHECK(err_code);
    }
} while (err_code == NRF_ERROR_RESOURCES);

What I'm trying to do is call the ble_nus_data_send() function and if I get an NRF_ERROR_RESOURCES error, I save the data_array in a FIFO buffer.
When the BLE_GATTS_EVT_HVN_TX_COMPLETE event is received, I retrieve the data from the FIFO and call the ble_nus_data_send() function again.

Thanks in advance,

Fernando.

Parents
  • Hello Fernando,

    What I'm trying to do is call the ble_nus_data_send() function and if I get an NRF_ERROR_RESOURCES error, I save the data_array in a FIFO buffer.
    When the BLE_GATTS_EVT_HVN_TX_COMPLETE event is received, I retrieve the data from the FIFO and call the ble_nus_data_send() function again.

    I believe this direction is completely fine. Are you having some trouble with it?

    I also don't see any immediate problem with your initial approach and code. What is wrong with that one?

    My hands are a little full right now, but if there is a chance I will also try to cook up an experiment with the code you provided to see what is wrong. 

    Best regards,

    Hieu

Reply
  • Hello Fernando,

    What I'm trying to do is call the ble_nus_data_send() function and if I get an NRF_ERROR_RESOURCES error, I save the data_array in a FIFO buffer.
    When the BLE_GATTS_EVT_HVN_TX_COMPLETE event is received, I retrieve the data from the FIFO and call the ble_nus_data_send() function again.

    I believe this direction is completely fine. Are you having some trouble with it?

    I also don't see any immediate problem with your initial approach and code. What is wrong with that one?

    My hands are a little full right now, but if there is a chance I will also try to cook up an experiment with the code you provided to see what is wrong. 

    Best regards,

    Hieu

Children
No Data
Related