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

Directly modify Link Layer packet

Hello, 

I am very new to BLE and NRF and trying to understand what the best way would be to send data from one device to another

From the documentation and messing around with ble_app_blinky on my nrf52833 DK as I understand it there is a Link Layer that is responsible for advertising and establishing connection. Once the connection is established the one device sends 27-byte data payload packet and gets a response from the other at an established interval. 

With the nrf sdk how to I directly modify the 27 byte payload?

All the examples in the SDK seem to set up a GATT as a data model but I would like to simply access the 27 byte payload on one nrf52833 DK, put my own 27 bytes into it and receive it on another nrf52833 DK. As I understand this would allow for the highest throughput and eliminate any overhead from the higher layers.

Parents Reply Children
  • Hi Dmitry, thanks for your quick response, the L2CAP information is very helpful

    After reading more about L2CAP it seems that basic L2CAP frames will allow for the smallest overhead while still supporting connection to a BLE device. Carefully setting up the L2CAP MTU will avoid data fragmentation. 

    For example lets say I have a data packet of 32 bytes. I can set up Link Layer payload to be 36 octets

    //From att_mtu_throughput example
    err_code = nrf_ble_gatt_data_length_set(&m_gatt, BLE_CONN_HANDLE_INVALID, 36

    then use basic L2CAP which will have a 4 octet header (Length = 32, Channel ID = 0x0001 - 0x007F) and my 32 bytes of data.

    ESB seems very close to what I need, unfortunately it only supports up to 8 devices. I am looking for up to 12.

    My end goal is to have multiple devices that sample 32 bytes of data at 100Hz to stream that data to a single central device. I though I could set the connection interval to 10ms and directly set up the Link Layer MTU to be 32 bytes and just put the data in. However it seems there is no direct access to the Link Layer packet. So as I understand it L2CAP will give me the smallest overhead. For example I can set the connection interval to 20ms, set the Link Layer MTU to be 68 bytes then set up L2CAP on each device with Length 64 and different channel IDs. Finally on each device I put together 2 32 byte data samples and they get sent. Is my thinking correct that this will maximize throughput from multiple devices to a single one?

    Is there an L2CAP example using the sdk? I only found ones using GATT. 

    Thanks a ton

  • Hi,

    there is an object transfer service example that uses L2CAP channels. I don't have any experience with them, sorry.

    You missed another thing: minimal event length for BLE is 2.5ms, thus you cannot have 50 events for 12 different devices per second, you're limited with 400 events/sec. Samples will be grouped by two packets in a connection interval, so it's better to send 128 bytes at once. I don't think you can win anything with L2CAP channels.

Related