I'm using ble_nus_string_send() to send 15 bytes over BLE UART.
As expected it sends 15 bytes, however on occasion 14 bytes are sent instead of 15 bytes.
Would there be a particular reason for this to occur?
void uart_event_handle(app_uart_evt_t * p_event){
#define LEN15 15
static uint8_t data_array[LEN15];
static uint8_t index = 0;
uint32_t err_code;
switch (p_event->evt_type)
{
case APP_UART_DATA_READY:
app_uart_get(&data_array[index]);
index++;
if ( index >= (LEN15) )
{
err_code = ble_nus_string_send(m_nus, data_array, index);
if (err_code != NRF_ERROR_INVALID_STATE)
{
APP_ERROR_CHECK(err_code);
}
index = 0;
}
break;
case APP_UART_COMMUNICATION_ERROR:
//APP_ERROR_HANDLER(p_event->data.error_communication); // this resets nRF51
if(m_handler)
{
m_handler();
}
break;
case APP_UART_FIFO_ERROR:
APP_ERROR_HANDLER(p_event->data.error_code);
break;
default:
break;
}
}