How to send multi-frame Notify sequentially

For send 1KB of data, I have to send  multi-frame Notify and the Notify frame max size is 20bytes

For example, we have 3 frames notify have to send

frame 1: 0x82 00 28 data[17]

frame 2: 0x00 data[19]

frame 3: 0x01 data[4]

How to send the next frame?

Please explain it with the project of "ble_app_uart" 

  • Hi Jimmy

    Which SDK version are you using?

    In order to send multiple frames you basically just call the send function over and over, but at some point the internal buffers in the Bluetooth stack will fill up and you will need to wait before you can buffer more data. 

    Have you looked into negotiating a larger MTU size so you can send more than 20 bytes in each notification packet?
    This will increase the throughput of the stack significantly, and reduce the time and energy needed to send your 1kB data packet. 

    Best regards
    Torbjørn

  • My development environment is nRF52840 DK + nRF5_SDK_17.1.0_ddde560

    Do you mean that I create a short-timer(e.q. 7ms), and send the next notification frame? 

    and once return the error message, send the same frame in next timer interrupt.

    Thanks for reminding us we will consider change size.

  • Hi Jimmy

    There is no need to create a timer. 

    The basic principle is as follows:

    1) Push as many packets as you can until the NRF_ERROR_RESOURCES error is returned from the nus send call. 

    2) Wait for the BLE_GATTS_EVT_HVN_TX_COMPLETE event to be returned from the SoftDevice

    3) Repeat from 1)

    By following this flow you ensure that the Bluetooth buffers are filled at all times, and the throughput will be as high as possible. 

    Please note that there are various stack configurations that affect the maximum throughput, and if you configure the stack incorrectly you will not be able to reach the maximum throughput possible. The throughput is also dependent on which central device you connect to, and could change from device to device (different phones will have different limitations for instance). 

    For more information about throughput with the SoftDevice please have a look at this case

    Best regards
    Torbjørn

  • Dear ovrebekk,

    OK, it works well by your suggestion.

    Thanks for your support.

    Best regards,

    Jimi

Related