How to fragment the BLE Data

In my project I am facing issues to send 6000 bytes per second through BLE to androis app

For reading the sensor it is taking 30-40 ms processing time and after that I am sending buffer to BLE 

I want to fragment the data using BT_L2CAP_TX_FRAG_COUNT and i dont know how to do it and there is no example for fragmentation 

please help on this 

Thank you in advance

Parents Reply Children
  • CONFIG_BT_BUF_ACL_RX_SIZE=502
    CONFIG_BT_ATT_PREPARE_COUNT=2
    CONFIG_BT_L2CAP_TX_BUF_COUNT=10
    CONFIG_BT_L2CAP_TX_MTU=498
    CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
    CONFIG_BT_CONN_TX_MAX=10
    CONFIG_BT_BUF_ACL_TX_COUNT=10
    CONFIG_BT_BUF_ACL_TX_SIZE=502

    I am bit confusing maximum we can send 495 buffer at a time or max 244 to BLE?
    In throughput Sample dummy buffer is declared as 498 
  • Hi Madhu Mohan,

    It seems that you are new to BLE. I think it might benefit you to go over our free online course Bluetooth Low Energy Fundamentals.

    Madhu Mohan Reddy said:

    Using bt_gatt_notify(); is best for sending 6000 bytes as multiple chunks?

    or

    Using bt_gatt_write_without_response(); is best?

    Notifying is an action that only the device in Peripheral role can do.
    Writing without Response is an action that only the device in Central role can do.

    In your use-case, it is most likely that your device is the Peripheral, and the Android device is the Central. If this is the case, you need to use bt_gatt_notify().

    Madhu Mohan Reddy said:
    CONFIG_BT_BUF_ACL_RX_SIZE=502
    CONFIG_BT_ATT_PREPARE_COUNT=2
    CONFIG_BT_L2CAP_TX_BUF_COUNT=10
    CONFIG_BT_L2CAP_TX_MTU=498
    CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
    CONFIG_BT_CONN_TX_MAX=10
    CONFIG_BT_BUF_ACL_TX_COUNT=10
    CONFIG_BT_BUF_ACL_TX_SIZE=502

    I am bit confusing maximum we can send 495 buffer at a time or max 244 to BLE?
    In throughput Sample dummy buffer is declared as 498 

    The 244 limit is to keep the GATT operation done in a single air packet. The GATT operation will be packed into a Link Layer packet, where only 244~249 bytes of GATT data can be packed.

    However, a GATT operation with longer value is still possible, and it will just be split into multiple Link Layer packets. The maximum size of the GATT operation is configured by CONFIG_BT_L2CAP_TX_MTU. It is 498 by default in the Throughput sample, and likely why the dummy array is also 498.

    Madhu Mohan Reddy said:
    My buffer size is 150, i want 40 buffers every second ?  And To read the sensor data is taking some time for spi 25 msec 

    40 transfers of 150 bytes each second should be doable. The SPI read should not be a concern. Ideally you want to read the sensor and send data in parallel, not sequentially. You might want to consider using a separate thread for each job.

    Hieu

  • when sensor data ready pin triggers low(DRDY) ,sensor data reading function call happens and in same function I am sending data to BLE.(if Buffer is full)
    if(flag == 150) send the buffer to BLE.

    How can I send the data to BLE and read the sensor parellel 

    would you give some suggestions 

    Thank you 

  • You can consider using asynchronous APIs for both sensor reading and BLE.

    Sensor readings will be queued in callback. In your main thread/function/loop, the queue can be check, and if there is data, you send it there.

    The best way is to have different threads for the job. I recommend going over our free online course on nRF Connect SDK Fundamentals, where the topic of threads is covered.

Related