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
  • Hi Mani

    The problem is that the example doesn't check if there are any BLE buffers available before calling app_uart_get(..).

    If the call to ble_nus_string_send(..) returns the NRF_ERROR_RESOURCES error it means that all the BLE buffers in the SoftDevice are full, and that you can not upload any more notifications until the BLE_GATTS_EVT_HVN_TX_COMPLETE event occurs.

    In this case you can set a flag in the code to say that the BLE buffers are full, so that you don't read any more data from the UART. Once the BLE_GATTS_EVT_HVN_TX_COMPLETE event occurs there is more room in the buffers, and you can start pulling UART data again.

    For this to work properly you should also use flow control on the UART. Otherwise you might lose bytes over the UART if the UART communication is quicker than the BLE link.

    Using a separate buffer in the application for UART data should not be necessary, since you already have internal buffers in the UART driver and in the SoftDevice.

    Best regards
    Torbjørn

  • BLE_GATTS_EVT_HVN_TX_COMPLETE occurs in which handler, how to check it?

Reply Children
No Data
Related