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

How do I access the "More Data Bit" in data header of a notification received as Central.

We have an NRF52 set up as Central, connecting to a peripheral (not our own) that's sending notifications with Data>20 bytes

I'm trying to differentiate between it sending two seperate sets of bytes 20 then 10, or a single set of 30 bytes, as an example.

I was hoping to use params.offset, but this is only available for writes and reads, not for receiving notifications. (from a quick look through devzone, it does appear to be available when sending a notification as a peripheral though?).

Before digging further into this only to possibly find out that the peripheral is not even sending an offset, I sniffed the communication, as attached.

The interesting difference I see is the "More Data" bit in the Data header

Data Header: 0x1b16
        .... ..10 = LLID: Start of an L2CAP message or a complete L2CAP message with no fragmentation (0x2)
        .... .1.. = Next Expected Sequence Number: 1
        .... 0... = Sequence Number: 0 [OK]
        ...1 .... = More Data: True
        000. .... = RFU: 0

vs

Data Header: 0x110a
        .... ..10 = LLID: Start of an L2CAP message or a complete L2CAP message with no fragmentation (0x2)
        .... .0.. = Next Expected Sequence Number: 0
        .... 1... = Sequence Number: 1 [OK]
        ...0 .... = More Data: False
        000. .... = RFU: 0

how can I access that info (or any derivation of that info), so that if there is more to come, I buffer the first notification, and wait for the rest of the data in the next notification before further processing it?

p_ble_evt->evt.gattc_evt.params.hvx only contains data, handle, len and type - none of which reflects the More Data info.

Thanks already!

No.     Time     Source                PHY        Protocol Length     Delta time (µs end to start) SN         NESN       More Data  Event counter Info
    363 12.471   Slave_0x1376ef35      LE 1M      ATT      27         151                           0          1          True       151           Rcvd Handle Value Notification, Handle: 0x0017 (Unknown: Unknown)

Frame 363: 53 bytes on wire (424 bits), 53 bytes captured (424 bits) on interface 0
Nordic BLE Sniffer
Bluetooth Low Energy Link Layer
    Access Address: 0x1376ef35
    [Master Address: XX:XX:XX:XX:XX:XX (XX:XX:XX:XX:XX:XX)]
    [Slave Address: XX:XX:XX:XX:XX:XX (XX:XX:XX:XX:XX:XX)]
    Data Header: 0x1b16
        .... ..10 = LLID: Start of an L2CAP message or a complete L2CAP message with no fragmentation (0x2)
        .... .1.. = Next Expected Sequence Number: 1
        .... 0... = Sequence Number: 0 [OK]
        ...1 .... = More Data: True
        000. .... = RFU: 0
        Length: 27
    [L2CAP Index: 33]
    CRC: 0x1606b1
Bluetooth L2CAP Protocol
    Length: 23
    CID: Attribute Protocol (0x0004)
Bluetooth Attribute Protocol
    Opcode: Handle Value Notification (0x1b)
        0... .... = Authentication Signature: False
        .0.. .... = Command: False
        ..01 1011 = Method: Handle Value Notification (0x1b)
    Handle: 0x0017 (Unknown)
        [UUID: 720330f41db74fd7ae5a87e5bd942880]
    Value: 3132333435363738393031323334353637383930

No.     Time     Source                PHY        Protocol Length     Delta time (µs end to start) SN         NESN       More Data  Event counter Info
    365 12.473   Slave_0x1376ef35      LE 1M      ATT      17         151                           1          0          False      151           Rcvd Handle Value Notification, Handle: 0x0017 (Unknown: Unknown)

Frame 365: 43 bytes on wire (344 bits), 43 bytes captured (344 bits) on interface 0
Nordic BLE Sniffer
Bluetooth Low Energy Link Layer
    Access Address: 0x1376ef35
    [Master Address: XX:XX:XX:XX:XX:XX (XX:XX:XX:XX:XX:XX)]
    [Slave Address: XX:XX:XX:XX:XX:XX (XX:XX:XX:XX:XX:XX)]
    Data Header: 0x110a
        .... ..10 = LLID: Start of an L2CAP message or a complete L2CAP message with no fragmentation (0x2)
        .... .0.. = Next Expected Sequence Number: 0
        .... 1... = Sequence Number: 1 [OK]
        ...0 .... = More Data: False
        000. .... = RFU: 0
        Length: 17
    [L2CAP Index: 34]
    CRC: 0x627f49
Bluetooth L2CAP Protocol
    Length: 13
    CID: Attribute Protocol (0x0004)
Bluetooth Attribute Protocol
    Opcode: Handle Value Notification (0x1b)
        0... .... = Authentication Signature: False
        .0.. .... = Command: False
        ..01 1011 = Method: Handle Value Notification (0x1b)
    Handle: 0x0017 (Unknown)
        [UUID: 720330f41db74fd7ae5a87e5bd942880]
    Value: 3132333435363738390d

[EDIT:] I know I could wait for the 0x0d at the end if I'm expecting that, but that's not guaranteed to be sent, so I can't rely on it.

Related