Hello,
We made a small replacement on the event handler of the ble_central/ble_app_uart_c application, just to do a loopback to test the UART module.
Here is how the hanlder looks now:
/**@brief Function for handling app_uart events.
*
* @details This function receives a single character from the app_uart module and appends it to
* a string. The string is sent over BLE when the last character received is a
* 'new line' '\n' (hex 0x0A) or if the string reaches the maximum data length.
*/
void uart_event_handle(app_uart_evt_t * p_event)
{
static uint8_t data_array[BLE_NUS_MAX_DATA_LEN];
static uint16_t index = 0;
uint32_t ret_val;
switch (p_event->evt_type)
{
/**@snippet [Handling data from UART] */
case APP_UART_DATA_READY:
UNUSED_VARIABLE(app_uart_get(&data_array[0]));
ret_val = app_uart_put(data_array[0]);
NRF_LOG_INFO("Received and returned byte %d with result code %d", data_array[0], ret_val);
/**
index++;
if ((data_array[index - 1] == '\n') ||
(data_array[index - 1] == '\r') ||
(index >= (m_ble_nus_max_data_len)))
{
NRF_LOG_DEBUG("Ready to send data over BLE NUS");
NRF_LOG_HEXDUMP_DEBUG(data_array, index);
do
{
ret_val = ble_nus_c_string_send(&m_ble_nus_c, data_array, index);
if ( (ret_val != NRF_ERROR_INVALID_STATE) && (ret_val != NRF_ERROR_RESOURCES) )
{
APP_ERROR_CHECK(ret_val);
}
} while (ret_val == NRF_ERROR_RESOURCES);
index = 0;
}
**/
break;
/**@snippet [Handling data from UART] */
case APP_UART_COMMUNICATION_ERROR:
NRF_LOG_ERROR("Communication error occurred while handling UART.");
APP_ERROR_HANDLER(p_event->data.error_communication);
break;
case APP_UART_FIFO_ERROR:
NRF_LOG_ERROR("Error occurred in FIFO module used by UART.");
APP_ERROR_HANDLER(p_event->data.error_code);
break;
default:
break;
}
}
We are not getting any answer on the serial port, We should receive the same bytes sent.
What are we doing wrong?
Thanks
Jay