Tool/software:
Hi,
In basic_ble OAD Peripheral project we are observing different behavior in pairing depending on the UART callback implementation.
Below are the two different implementations:
Observations:
With Implementation 1 : We are not getting passkey enter popup on remote device(mobile phone), Eventually pairing is failing every time and also we are not getting BLEAPPUTIL_PAIRING_STATE_COMPLETE event.
With Implementation 2 : Pairing is successful.
We want to go with implementation 1 to handle UART exchange properly but failing at pairing, Kindly suggest solution.
SDK Version : simplelink_lowpower_f3_sdk_8_10_01_02
CCS version: CCS 12.7.1
//Global variables
uint8_t uartReadBuffer[100] = {0};
uint8_t uartPacketSize = 0;
//Implemention 1:
void HandlingFunction(char *pData)
{
uint8_t *pDataBase = NULL;
pDataBase = pData;
uint8_t len = *pData;
pData++;
UART2_write(uart, pDataBase,len+1, 0);
UART2_read(uart, &uartReadBuffer, UART_MAX_READ_SIZE,0);
}
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);
idx = data;
*idx = count;
idx++;
memcpy(idx, buffer, count);
BLEAppUtil_invokeFunction(HandlingFunction, data);
memset(uartReadBuffer,0,sizeof(uartReadBuffer));
}
//Implemention 2:
void HandlingFunction(char *pData)
{
UART2_write(uart, uartReadBuffer,uartPacketSize, 0);
memset(uartReadBuffer,0,sizeof(uartReadBuffer));
UART2_read(uart, &uartReadBuffer, UART_MAX_READ_SIZE,0);
}
void UARTCallback(UART2_Handle handle, void *buffer, size_t count, void *userArg, int_fast16_t status)
{
uartPacketSize = count;
BLEAppUtil_invokeFunction(HandlingFunction, NULL);
}
Thanks,
Vignesh.