This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

BLE UART Slow Transfer to Android

Hi all,

I am using PCA10040 with nRF5_SDK_13.0.0 and using the ble_perpheral -> ble_app_uart example.

I am trying to stream data from UART to an android phone and the data is coming from an external MCU with its TX/RX pin connected to the RX/TX pin on the NRF52DK. Every 40ms, I am sending a line of characters up to 49 bytes (max), terminating with a new line character.

Even though all the data is transmitted successfully, there seems to be a lag. I am transmitting 25 strings per second. So after 10 seconds, I would have transmitted the 250th string. On the NRF logger, the first string is received at 09:42:56.450 and the 250th string (suppose to be received 10 seconds later) is received at 09:43:07.684. There is a slight delay and this builds up over time. The 1500th string (should be received 1 minute after the first packed received) is only received at 09:44:17.516. 

Another observation I have is that on the nRF Toolbox UART app, after I click on the DISCONNECT button, it is still buffering data that is lagging behind. And it actually waits for a long time for the buffing to complete before it really disconnects.

Is it possible to achieve real time data transmitting and receiving without any lag? My hardware is continuously transmitting for hours and I can't possibly have the lag building up over time. I suspect it would probably have a buffer overrun error after sometime.

A Nordic Support Engineer suggested 2 options: (1) push less data or (2) increase bandwidth.

For (1), I tried to send less data (5 bytes per packet) at 25 packets per second but the delay and lag is still there.

For (2), I was told to send larger longer packets to reduce overheads and increase the ATT MTU and enabling DLE. Actually I don't know what this means. 

I read on another thread that "the minimum connection interval on say, an iPhone, is 20ms. Also, you can send up to 6 packets of 20 bytes within a connection interval. So that's 120 bytes every 20ms."

In this case for(1), it was 5 bytes per packet and 25 packets per second, I should not be running into this problem. Ultimately, I need to achieve the ability to send up to 49 bytes (max) every 40ms.

Anyone can further advise? Thanks a lot!

  • Hi Kian79,

    Tips from last thread:

    You can increase the bandwidth by:

    - Send fewer, larger packets, reducing overhead.

    -Use the high speed 2 Mbps mode introduced in Bluetooth 5

    To increase the ATT MTU you can look at the "ble_app_uart" example and take a look in the gatt_init(), you can see how this is handled for the peripheral side with the function (nrf_ble_gatt_att_mtu_periph_set()). Another tips can be to look at the ATT_MTU Throughput Example and use parts of it as reference.  You could also check out this blog describing the different parameters of the example.

    Anyway, If you could provide a sniffer log that would also be helpful to see what's happening over the air.

  • Thanks Martin.

    I solved the problem by min and max connection interval to 7.5 and ATT MUT to 150.

    #define MIN_CONN_INTERVAL               MSEC_TO_UNITS(7.5, UNIT_1_25_MS) 

    #define MAX_CONN_INTERVAL               MSEC_TO_UNITS(7.5, UNIT_1_25_MS) 

    err_code = nrf_ble_gatt_att_mtu_periph_set(&m_gatt, 150);

Related