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

Introducing FIFO buffer in uart_data_handler function..

I am working with ble_app_uart code, in that I am trying to send continuous data over BLE. But the BLE getting disconnected while sending large data.

So I planned to have an FIFO buffer which should continuously receive and stores the data(whatever the data size). Then the data should be processed and then it should be sent as frame with the length of 20 bytes. So how to introduce a new buffer and how to handle it with default app_uart_get() buffer.

Parents Reply Children
  • Hi guys

    I have reported the issue to the SDK team, and they are looking into a quick fix that would just require a small change to the uart_event_handle(..) function in main.c

    In the code snippet below, NRF_ERROR_BUSY is replaced with NRF_ERROR_RESOURCES, to make the application attempt to retry sending the packet when the BLE buffers are full:

    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);

    Please try this out and see if it solves the issue. 

    While this method is a bit rudimentary for applications that constantly push the communication to the limits, it should work fine if you only have occasional bursts of data. 

    Best regards
    Torbjørn

Related