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

radio notifications and relationship with BLE_GATTS_EVT_WRITE and BLE_GATTS_EVT_HVN_TX_COMPLETE

I have enabled radio notifications (through sd_nvic_ functions). When sd_ble_gatts_hvx() (notification) is called once, I've noticed two radio active-nactive windows occur before BLE_GATTS_EVT_HVN_TX_COMPLETE occurs. It seems like it takes 2 windows to notify, why? Is the packet sent during the active-nactive window occurring directly before BLE_GATTS_EVT_HVN_TX_COMPLETE?

When a BLE_GATTS_EVT_WRITE event occurs, was the new data presented by the BLE event handler (assigned with NRF_SDH_BLE_OBSERVER) received during the active-nactive window occurring directly before BLE_GATTS_EVT_WRITE?

The sd is configured as a peripheral.

  • Hi Archangel,

    BLE_GATTS_EVT_HVN_TX_COMPLETE occurs when a notification is Acked on link layer. So this usually requires 2 connection event. First one is for the peripheral to send the packet and the next one is when the packet ACKed by the central. This is why you see 2 windows before you receive the event.

    In most cases (when you have only one connection, peripheral only, no timeslot activity) the BLE_GATTS_EVT_WRITE occurs right after the data arrives (the radio active window).

    Please have a look at chapter 11 in the S132 softdevice specification for more information regarding radio notification.

  • Just for clarification, regardless of if you are using notifications or indications, at some level there is an acknowledgement? It seems that I am getting BLE_GATTS_EVT_HVN_TX_COMPLETE right as the second radio window is about to start now (nactive) which doesn't seem to jive with your explanation but it could be the result of some race condition.

    Sending code

    tx enqueue

    active: 54141

    inactive: 54798

    active: 84342

    BLE_GATTS_EVT_HVN_TX_COMPLETE

    inactive: 85071

  • You are correct, any BLE packet will be retransmitted until it's ACKed on link layer. You can read more about the flow control here.

    I don't see anything contradict with my explantion, after the radio is active, it receives the next packet from central , and that packet ACKs the last notification packet, and then you have the BLE_GATTS_EVT_HVN_TX_COMPLETE event of how many packets sent in the last connection event.

    This BLE_GATTS_EVT_HVN_TX_COMPLETE event can come before the connection event finish.

  • What I may be confused about is that it appears that the BLE_GATTS_EVT_HVN_TX_COMPLETE actually happens before the radio goes active a second time (because NRF_RADIO_NOTIFICATION_DISTANCE_800US) and I was under the assumption no processing occurs when the radio is actually active. If the ack was received during the second radio window it would not have to occur after the second inactive event?

  • I don't have the timing for BLE_GATTS_EVT_HVN_TX_COMPLETE from your log so I don't know if it's before or after the radio is active.

    But be aware that the notification can be ACKed in one connection event if there are more than one packet is transmitted from the central, for example the second packet from central can ACK the first packet from the slave, in one connection event.

Related