CC2340R5: Handling UART data buffer

Part Number: CC2340R5

Tool/software:

Hi,

We are using UART with baud rate 9600, the host controller will send data of 1000-2000 bytes with the interval of 500ms.

The same data we have to transmit over the air with MTU of 247. 

If we are sending 1000 bytes with interval of 1sec then only we are able to see all the data properly, below 1sec we are observing packet mismatch/missing,

Below is our UART callback implementation.

#define UART_MAX_READ_SIZE	1000

uint8_t uartReadBuffer[UART_MAX_READ_SIZE];

void UARTCallback(UART2_Handle handle, void *buffer, size_t count, void *userArg, int_fast16_t status)
{
   
    uint8_t *idx = NULL;
    uint8_t *data = BLEAppUtil_malloc(count + 2); 
    idx = data;
    *idx = count;
    idx++;
    *idx = count >> 8;
    idx++;
    memcpy(idx, buffer, count);
    BLEAppUtil_invokeFunction(HandlingFunction, data);
    memset(uartReadBuffer,0,sizeof(uartReadBuffer));
    UART2_flushRx(handle);
}

void HandlingFunction(char *pData)
{
	//sending over the air
	UART2_read(uart, &uartReadBuffer, UART_MAX_READ_SIZE,0);
}

Here if host controller is sending more than 1000 bytes, we want to ignore the extra bytes, and want to handle new packet,

but what we are observing is old extra bytes are added in the next UART read along with new packet data.

Kindly suggest proper way of handling this scenario.

Regards, 

Vignesh.