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

Calling sd_ble_gatts_hvx in radio notification

FormerMember
FormerMember

Hey everyone, I'm trying to send a value as a notification packet from GATT Server (slave) to GATT client (master) at 7.5 ms connection interval. I have set up the radio notification IRQ (SW IRQ) to fire before the radio becomes active at low IRQ priority. In this routine I call the sd_ble_gatts_hvx() routine. Without the sd_ble_gatts_hvx call, I get 7.5 ms interval. But with the call I get 15 ms routine.

void RADIO_NOTIFICATION_IRQHandler(void){
      //sd_ble_gatts_hvx call to send a notification
}

Is there a way send a GATT notification packet from the RADIO_NOTIFICATION_IRQHandler while still having 7.5 ms connection interval with S110 SD?

Edit: Adding that I have checked with different 'radio notification distances', from 800 us to 3260 us.

Edit 2: This behaviour is consistent even with 10 ms, 15 ms or 250 ms connection interval. I.e. the interval at which the radio notification event happens doubles when sd_ble_gatts_hvx is called in the radio notification IRQ handler.

Edit 3: Added a minimal example that has the problem mentioned in the comments.main_notify_radio_evt.c

Edit 4: Added a sniffer trace of how the notifications are sent.Sniffer_Trace.png

Edit 5: Added a small flow diagram to explain a comment. SendingGoodies.jpg (It'll be nice to add pics to comments) Setup: nrf51 DK with S110 v8.0.0 in connection with nrf51 DK S120 v2.1.0. Compiled with GCC in Linux. Thanks!

  • FormerMember
    0 FormerMember in reply to Susheel Nuguru

    I should have realized this way back. The softdevice can only give the TX_COMPLETE event after the next conn event after sending the notification packet. This is because only after receiving the next packet from the master the slave can get an ACK through the sequence number.

    So, I'll test in a configuration where the master sends the data packets to the slave. In this case the ACK is immediate, thus being able to queue up only one packet. Edit Works with a master with GATT client sending write commands to a master with GATT server.

  • Your understanding of " The softdevice can only give the TX_COMPLETE event after the next conn event after sending the notification packet. This is because only after receiving the next packet from the master the slave can get an ACK through the sequence number." is correct.

    What do you mean by "So, I'll test in a configuration where the master sends the data packets to the slave. In this case the ACK is immediate, thus being able to queue up only one packet. Edit Works with a master with GATT client sending write commands to a master with GATT server." ? Write command and notification are similar in the sense that it will be queued and the TX_COMPLETE only comes after 1 connection event.

  • FormerMember
    0 FormerMember in reply to Susheel Nuguru

    Write command and notification are similar in the sense that they are unacknowledged at the GATT layer. What is being used depends on which device (link layer master or slave) is GATT client and GATT server. For this discussion lets consider both as goodies.

    Now there are two cases of goodies being sent, whether its LL master sending them or the slave. In case the master is sending goodies to slave TX_COMPLETE is sent immediately after the event. In case the slave is sending goodies to master, the slave has to wait till after the next conn event to get the TX_COMPLETE.

    In BLE it is always the master sending the first packet and slave responding in a connection event. With this we can see that for a slave to get a LL ack from the master with the Sequence Number, it has to wait one conn event. In case of master the slave has to respond back immediately, thus getting an ack and then giving TX_COMPLETE event to the application. I've made a small diagram to explain this and is added as an attachment to the question.

  • Thanks for the figure, you are correct, if you switch the role, and use the master to send data the TX_COMPLETE will tell the number of packets actually acked on that same event.

    I wasn't expect that you have control over both side. Your approach is correct.

Related