3 Replies Latest reply on Apr 22, 2017 12:10 PM by Madhu Lakshmipathy

    Uart_to_Ble app mtu size control

    alper.koybasi_1600091

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

        • 1. Re: Uart_to_Ble app mtu size control
          alper.koybasi_1600091

          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

          • 2. Re: Uart_to_Ble app mtu size control
            e.pratt_1639216

            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.

            • 3. Re: Uart_to_Ble app mtu size control
              Madhu Lakshmipathy

              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