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

How to send large amount of data through BLE using NUS?

Hello, I am using nRF52832 DK s132 and interface with accelerometer. Now i have successfully read 3 ADC channels with time period of 244 microSecond on terminal. But i have facing problem this accelerometer data is send to my mobile apps but it is not receiving greater than 20 bytes. So for sending data via BLE i have used following function:

for(int i =0 ; i < 100; ++i) {

   NRF_LOG_INFO("%d \r\n",i)

    if((i+1)%10 == 0)

         nrf_delay_ms(20);

    do {

        err_code = ble_nus_string_send(&m_nus, p_data, length);

        NRF_LOG_INFO("%d \r\n",err_code)

        if ((err_code != NRF_ERROR_INVALID_STATE)

                && (err_code != NRF_ERROR_BUSY)) {

            APP_ERROR_CHECK(err_code);

        }

    } while (err_code == NRF_ERROR_BUSY);

}

when i am reading ADC data from apps at that time it reset and shows RAM overflow message.

I have read 12288 point ADC data for each accelerometer axis(X, Y and Z) and send via BLE to my mobile app(android). But following problem is coming:

  1. All sending ADC data is not received in mobile apps?

  2. How i can manage my 3 axis data and send to mobile apps without data loss during transmission.

  3. Is it possible to send data more than 20 bytes via BLE? How?

Thanks,

Vishal.

  • 1 and 2. Make sure there are tx buffers available. For maximum throughput you should call sd_ble_gatts_hvx until you get NRF_ERROR_RESOURCES (BLE_ERROR_NO_TX_PACKETS for older SD versions). When that happens, wait for BLE_GATTS_EVT_HVN_TX_COMPLETE before you call sd_ble_gatts_hvx again.

    1. Yes, you can use a longer att MTU, both with or without data length extension. See here(clinet) and here (server).
Related