Peripheral UART - BLE packet size and rate

Hi

I have some questions about BLE throughput, using the BLE Peripheral UART example, out of the box, so to speak, for the nRF5340 DK.

Using this application, I can send up top 40 bytes of data in each message.

Without any flow control, it seems I can send a new packet every 25 ms.

I have tried to do two things, with various CONFIG_BT_ settings that I can find out about, but have not yet succeeded.

Task One

Try and increase the amount of data I can send in one call to bt_nus_send() from 40 bytes to, say, 240

The buffer struct is defined as:

#define UART_BUF_SIZE CONFIG_BT_NUS_UART_BUFFER_SIZE
struct uart_data_t {										// Buffer struct used for rx/tx BLE data
	void *fifo_reserved;
	uint8_t data[UART_BUF_SIZE];
	uint16_t len;
};

Task Two

Increase the rate of BLE packet transmissions, so that I can send more packets per second.

 I have read through various forum posts etc., and have lost track of all the different combinations and values I have tried for the following, and others:

CONFIG_BT_L2CAP_TX_BUF_COUNT
CONFIG_BT_L2CAP_TX_MTU
CONFIG_BT_BUF_ACL_TX_SIZE
CONFIG_BT_BUF_ACL_TX_COUNT
CONFIG_BT_PERIPHERAL_PREF_MIN_INT
CONFIG_BT_PERIPHERAL_PREF_MAX_INT
 

Is there a simple step by step way of achieving these two tasks?

Thanks

 

 

 

 

Parents Reply Children
  • Hi

    I would like to refresh the information I have about this issue.
    I have been working on trying to increase the BLE throughput between my nRF5340 DK and an Android/iOS app.

    Requirement
    To connect the nRF5430 DK board to an App, via BLE, and for the Nordic device to be able to transmit approximately 100 bytes every 10 ms to the App.

    Starting point
    Nordic’s Peripheral BLE UART example, built using the latest SDK (v2.602).
    nRF5340 DK board: PCA10095 / 2.0.2 / 2023.33.
    App: Nordic’s nRF Toolbox..
    App device: iPAD and Android tablets, both with BLE 5.0

    Initial changes
    I started with the Peripheral BLE UART example, and modified the application so that it would continuously try to send a BLE message – i.e. from within a forever loop in the BLE thread, it continuously calls bt_nus_send().
    The message sending is enabled/disabled using buttons 3 and 4.

    Subsequent changes
    I used various message lengths, and prj.conf settings, in an effort to increase the data throughput.

    Observations

    Setup 1

    At first, I did not modify the prj.conf settings in the Peripheral BLE UART example, and the message was small (26 bytes).

    prj.conf settings

    CONFIG_BT_NUS_UART_BUFFER_SIZE=247
    CONFIG_BT_BUF_ACL_TX_COUNT=10
    CONFIG_BT_BUF_ACL_TX_SIZE=251
    CONFIG_BT_L2CAP_TX_BUF_COUNT=10
    CONFIG_BT_L2CAP_TX_MTU=247
    CONFIG_BT_CTLR_PHY_2M=y

    Result: I was seeing a throughput of approximately 1900 messages / minute: 832 bytes / s.

    Set up 2
    I then modified the settings based on Nordic’s BLE Throughput example. I am sure a lot of these settings have no effect / are irrelevant:

    prj.conf settings

    CONFIG_BT_NUS_UART_BUFFER_SIZE=247
    CONFIG_BT_ATT_PREPARE_COUNT=2
    CONFIG_BT_BUF_ACL_RX_SIZE=251
    CONFIG_BT_BUF_ACL_TX_COUNT=10
    CONFIG_BT_BUF_ACL_TX_SIZE=251
    CONFIG_BT_CONN_TX_MAX=10
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
    CONFIG_BT_CTLR_PHY_2M=y
    CONFIG_BT_CTLR_RX_BUFFERS=2
    CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n
    CONFIG_BT_GATT_CLIENT=y
    CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
    CONFIG_BT_L2CAP_TX_BUF_COUNT=10
    CONFIG_BT_L2CAP_TX_MTU=247
    CONFIG_BT_USER_DATA_LEN_UPDATE=y
    CONFIG_BT_USER_PHY_UPDATE=y

    Result: There was no increase in throughput

    Set up 3
    Lots of settings, trying everything!

    prj.conf settings

    CONFIG_BT_BUF_ACL_RX_SIZE=502
    CONFIG_BT_BUF_ACL_TX_COUNT=10
    CONFIG_BT_BUF_ACL_TX_SIZE=251
    CONFIG_BT_BUF_ACL_TX_SIZE=502
    CONFIG_BT_CONN_TX_MAX=10
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
    CONFIG_BT_CTLR_RX_BUFFERS=2
    CONFIG_BT_CTLR_SDC_MAX_CONN_EVENT_LEN_DEFAULT=4000000
    CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n
    CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
    CONFIG_BT_L2CAP_TX_BUF_COUNT=10
    CONFIG_BT_L2CAP_TX_MTU=252
    CONFIG_BT_L2CAP_TX_MTU=498
    CONFIG_BT_MAX_CONN=1
    CONFIG_BT_MAX_PAIRED=1
    CONFIG_BT_NUS_UART_BUFFER_SIZE=247
    CONFIG_BT_PERIPHERAL_PREF_LATENCY=1
    CONFIG_BT_PERIPHERAL_PREF_MIN_INT=6
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_USER_DATA_LEN_UPDATE=y
    CONFIG_BT_USER_PHY_UPDATE=y
    CONFIG_BT=y
    CONFIG_NEWLIB_LIBC=y

    Result: There was no increase in throughput

    Packet Length
    For Setups 2 and 3, I then increased the message size from 26 bytes to 233 bytes

    Result: This doubled the overall throughput

    Modifying the App
    Finally, I used another App (Adafruit's Bluefruit LE Connect app), and modified the Android source code for this, adding one line to request a high priority connection

    gatt.requestConnectionPriority(CONNECTION_PRIORITY_HIGH);

    Result: This doubled the throughput again, for Set ups 2 and 3

    Summary of findings
    The table below shows the approximate number of bytes per second that were sent from the nRF5340 DK to the App

    I can upload the modified example if that helps / if you tell me how to do this.

    I am guessing there is something fundamentally wrong with my approach, or that I am missing something obvious.

    Any help on this would be appreciated. Thanks.

Related