This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf52832 ble_uart project - sending all data received on uart over BLE

Hi

I have problem because i dont get all data which are in FIFO uart  on my smartphone via BLE. Nrf as i can see in example sends data where data[index-1] == 0x0d || data[index-1] == 0x0a.

Becase not all message which nrf52832 get via uart ending with 0x0d or 0x0a i dont receive on my smartphone.

I want that every byte nrf52832 get on uart it sends over ble. I have tried with smaller buffer and changing/adding conditions in 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
switch (p_event->evt_type)
{
case APP_UART_DATA_READY:
UNUSED_VARIABLE(app_uart_get(&data_array[index]));
index++;
if ((data_array[index - 1] == '\n') ||
(data_array[index - 1] == '\r') ||
(index >= m_ble_nus_max_data_len))
{
if (index > 1)
{
NRF_LOG_DEBUG("Ready to send data over BLE NUS");
NRF_LOG_HEXDUMP_DEBUG(data_array, index);
do
{
uint16_t length = (uint16_t)index;
err_code = ble_nus_data_send(&m_nus, data_array, &length, m_conn_handle);
if ((err_code != NRF_ERROR_INVALID_STATE) &&
(err_code != NRF_ERROR_RESOURCES) &&
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

but nothing help with that. When messages are ended with 0x0d 0x0a i dont see on my smartphone 0x0a.

  • Have you maybe idea why is this when bigger baudrate(9600) it cant send character by character. BLE is more quicker than uarts baudrate.

  • Hi,
    It might be that you are overrunning the softdevice buffer. Can you check if the ble_nus_data_send() returns NRF_ERROR_RESOURCES? Use APP_ERROR_CHECK(err_code) after ble_nus_data_send().
    Though I still recommend to use the app_timer to send your data. You can set the timeout equal to the interval, and then buffer all the data. Call then ble_nus_data_send() in the app_timer callback handler. It would be too inefficient to send one byte at a time.
  • this was idea because our older product which was based on bluetooth 2.0 have sending in this way from his uart via bluetooth to receiver bluetooth character by character. Now we working on new version to be based on BLE. I will now try your way. 

  • ble_nus_data_send() returns NRF_ERROR_TIMEOUT 

1 2 3