Hello,
I want to communicate with the one master and four slave devices. For this I have merged ble_uart for the data communication and multirole exmple for the multiple connection.
I want to send the data from the master to the several peripheral devices. For this I have connected master to the computer and sending data from terminal to the peripheral module.
APP_UART_DATA_READY in uart_event_handle function is called after every byte reception.
Issues:
1. It does not terminate on the first 0x0A character instead it terminates on the second time 0x0A reception. It does not send 2nd 0x0A on the terminal As per the attached screenshot.
2. Received 0x0A character in the previous transmission is considered as terminating character in the next transmission and in next transmission only 0x0A is printed on the uart and the sent characters are missing and sent in the next tx.
For e.g. if I send 04,hello\r\n\n for the first transmission then only it enter in the ble_nus_c_string_send function but does not send the 2nd \n.
2nd \n is received in the next transmission when I send some other bytes but other bytes are not received only terminated on previous \n.
Please suggest the solution of the problem, I am stuck here.

My function is attached as
void uart_event_handle(app_uart_evt_t * p_event)
{
static uint8_t cmd_mode=0;
uint32_t ret_val;
switch (p_event->evt_type)
{
case APP_UART_DATA_READY:
//nrf_drv_timer_disable(&TIMER_UART_RX);
UNUSED_VARIABLE(app_uart_get(&UART_RX_BUF[UART_RX_STA]));
UART_RX_STA++; // Record the uart received data frame length
if((strstr(UART_RX_BUF, "@#$"))!=0 && UART_RX_STA>=2) //To enter into Command Mode
{
// Enter into the AT Command Configuration Mode
NRF_LOG_INFO("AT Command Mode");
NRF_LOG_HEXDUMP_INFO(UART_RX_BUF, UART_RX_STA);
uart_print("\r\nOK\r\n");
cmd_mode = 1;
//app_fifo_flush(data_array);
memset(UART_RX_BUF, 0, sizeof(UART_RX_BUF));
UART_RX_STA=0;
app_uart_flush();
}
else if(cmd_mode == 1)
{
if(AT_cmd_check_valid(UART_RX_BUF, UART_RX_STA)) // AT command
{
AT_cmd_handle(UART_RX_BUF, UART_RX_STA);
UART_RX_STA=0;
}
}
else if (((UART_RX_BUF[UART_RX_STA - 1] == 0x0A) || (UART_RX_STA >= (m_ble_nus_max_data_len)))&& cmd_mode==0) // data mode
{
NRF_LOG_DEBUG("Ready to send data over BLE NUS");
NRF_LOG_HEXDUMP_DEBUG(UART_RX_BUF, UART_RX_STA);
NRF_LOG_HEXDUMP_INFO(UART_RX_BUF, UART_RX_STA);
do
{
for (uint32_t i = 0; i < NRF_SDH_BLE_CENTRAL_LINK_COUNT; i++)
{
ret_val = ble_nus_c_string_send(&m_ble_nus_c[i], UART_RX_BUF, UART_RX_STA);
if ( (ret_val != NRF_ERROR_INVALID_STATE) && (ret_val != NRF_ERROR_RESOURCES) )
{
APP_ERROR_CHECK(ret_val);
}
}
} while (ret_val == NRF_ERROR_RESOURCES);
UART_RX_STA = 0;
memset(UART_RX_BUF, 0, sizeof(UART_RX_BUF));
app_uart_flush();
}
//nrf_drv_timer_enable(&TIMER_UART_RX);
break;
case APP_UART_COMMUNICATION_ERROR:
APP_ERROR_HANDLER(p_event->data.error_communication);
break;
case APP_UART_FIFO_ERROR:
APP_ERROR_HANDLER(p_event->data.error_code);
break;
default:
break;
}
}
