/* Function for handling the data from the Nordic UART Service. 
This function will process the data received from the Nordic UART BLE Service and send it to the UART module. */
static void nus_data_handler(ble_nus_t *p_nus, uint8_t *p_data, uint16_t length)
/* Function for handling the data from the Nordic UART Service. 
This function will process the data received from the Nordic UART BLE Service and send it to the UART module. */
static void nus_data_handler(ble_nus_t *p_nus, uint8_t *p_data, uint16_t length)
{
	for (uint32_t i = 0; i < length; i++)
	{
		uint8_t data = p_data[i];
		if (data == '\n') {
			static const char thank_you[] = "Thank you!\n";
			uint32_t err_code = ble_nus_string_send(p_nus, (uint8_t*)thank_you, strlen(thank_you) + 1);
			if (err_code != NRF_ERROR_INVALID_STATE)
			{
				APP_ERROR_CHECK(err_code);
			}
		}
		while(app_uart_put(data) != NRF_SUCCESS);
	}
}