BLE: timing of call back function: notification acknowledged

Hi

In nordic connect sdk (2.6.0) a notfication on a peripheral device is send by bt_gatt_notify_cb. The second parameter of this function (bt_gatt_notify_params) is a struct which may be used. It contains a callback funtion which is called after the notification has been sent over the air "AND" acknowledged by the central. When is this function called? 
A: After the acknowledgement by the central right away
B: at the end of connection event for all notfications at once?
C: at the end of connection event once for every notfications?

Thanks

  • Hi Klaus, 

    When sending a notification there will be no acknowledgement from the central. It's is different from "indication". When you send an indication the peer device is expected to send an ACK for confirmation. 

    The callback you receive is when the server (peripheral in your case) finish sending the notification. Answer C is closest to when the function is called. But you can have multiple notification sending in one connection event so the call back may cover multiple notification. 

    Note that at ATT layer you don't have ACK for notification, but at Link layer, all packets are acknowledged with the SN and NESN bit for flow control. Packet will be retransmitted if it doesn't get acknowledgment from the peer device. 

  • Hi

    would you please clairify this:

    Question 1: 

    You write;

    >>When sending a notification there will be no acknowledgement from the central.

    Further below you write there will be an ACK on the Link layer. This means central received the packet correctly. 

    So what is true?

    Second question:

    Is the call back function called after the message being acked by the link layer?

    3rd question:

    In case of a retransmission, is the function called multiple times?

    4th question:

    Where in the documentation is all this described? I am having trouble to find the right spots in the documentation.

    Thanks!

  • Hi Klaus, 
    As I mentioned all BLE packet when in connection are ACKed at the link layer. Link layer is very low in the BLE stack right above the PHY layer: 


    A new LL packet only sent if the previous is ACKed. 

    But on the ATT layer there is no acknowledgment for notification, this mean the sender has no way to know if the receive has received the notification packet at the ATT layer on the destination (the link layer can ack but the ATT may not receive/process the packet for some reason). The sender may send next notification even though the first notification has not been processed. This is different from indication that the new indication can only be sent if the pervious indication has been ACKed on the ATT layer at the peer device. 

    klaus1234 said:

    Is the call back function called after the message being acked by the link layer?

    The callback is called when the buffer on the Host has sent the notification to the controller (LL ) not when it's ACKed on the Link layer. See here: https://github.com/nrfconnect/sdk-zephyr/blob/main/subsys/bluetooth/host/Kconfig.gatt#L41

    klaus1234 said:
    In case of a retransmission, is the function called multiple times?

    No, retransmission is handled by Link Layer and it's transparent to the layers above. 

    klaus1234 said:

    Where in the documentation is all this described? I am having trouble to find the right spots in the documentation.

    I would suggest to follow our devacademy here: 
    https://academy.nordicsemi.com/courses/bluetooth-low-energy-fundamentals/

    But for the deeper knowledge on Bluetooth Low Energy, I would suggest to find a book. For example this: https://www.oreilly.com/library/view/getting-started-with/9781491900550/

Related