if(--uartIdleCount == 0)
/*uartTxDataLength remains unchanged */;
I want to do with a different structure.I do not want to use Timeout. How can I do it
I would assume the mtu size check is to make sure all of the data is sent in the same packet?
And rewriting the code to not use a timeout should be easy enough, but not using timeouts allows the unit to lockup the uart if it doesn't work properly for sending valid data, correct format, too much data, too long between data, etc.
Basically the implementation is to send Data from UART RX over the BLE only when the UART RX receives considerable data (greater thanb MTU-3). It breaks such large data into packets of MTU-3 and sends it as individual notifications.
If the UART RX data is short (less than MTU-3), the code will wait UART_IDLE_TIMEOUT (1000 runs) for more data to arrive. Even after 1000 runs, if the UART RX does not exceed MTU-3, it will just go ahead and send whatever be the short packet it has. Till the 1000 runs is reached, it will keep looking for more data. In every run if more data has not arrived, it will just set uartTxDataLength as 0, so that no data is sent.
If you do not want a timeout kind of implementation, please set UART_IDLE_TIMEOUT as (1) in app_uart.h
- Madhu Sudhan