Uart_to_Ble app mtu size control

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
user_1600091
Level 2
Level 2
First like received

Hi,

   

if(uartTxDataLength >= (mtuSize - 3)) 

   

Why do we control  .What is the purpose here? I did not see any information about it.

   

Uart_to_ble.app

   

if((0 != uartTxDataLength) && (NOTIFICATON_ENABLED == txDataClientConfigDesc))
    {
        if(uartTxDataLength >= (mtuSize - 3))
        {
            uartIdleCount       = UART_IDLE_TIMEOUT;
            uartTxDataLength    = mtuSize - 3;
        }
        else
        {
            if(--uartIdleCount == 0)
            {
                /*uartTxDataLength remains unchanged */;
            }
            else
            {
                uartTxDataLength = 0;
            }
        }

0 Likes
1 Solution
Anonymous
Not applicable

Hi,

   

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

   

Regards,

   

- Madhu Sudhan

View solution in original post

0 Likes
3 Replies
user_1600091
Level 2
Level 2
First like received

In addition

   

            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

0 Likes
Anonymous
Not applicable

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.

0 Likes
Anonymous
Not applicable

Hi,

   

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

   

Regards,

   

- Madhu Sudhan

0 Likes