I am trying to implement the central side code for the usbd_ble_uart example. My current target is the nRF52840 Development Kit but the final target is the nRF52840-Dongle.
My development environment is EWARM 8.30.1 with Nordic SDK 15.2
In the peripheral example given (sdk\examples\peripheral\usbd_ble_uart\main.c) the cdc_acm_user_ev_handler() case for APP_USBD_CDC_ACM_USER_EVT_RX_DONE handles data received from the PC over the USB interface using the CDC (virtual serial port) protocol.
My problem is the example code does not send data across the BLE NUS link until either a carriage return or a new line character is seen or until the buffer is full. I want to remove the check for new line or carriage return and add a timeout.
The problem is this code only gets called if a character is received from the USB port - any checks for timeout would not be performed until a new character was received. If several characters were received and then a 50 ms pause happened before the next character, the buffered data would be delayed for that 50 ms pause.
What is the proper/expected way to handle this problem? This isn't an unusual issue so my guess is the USB CDC library has some mechanism designed in to handle it that I haven't found. I do not want to use single byte buffers since I don't know if the underlying library layers will queue the multiple byte writes up into a single BLE transmission.