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!

  • I did test it quickly with the setup I had S130 , Keil , Windows, but it was working normal. I will try your setup tomorrow with S120, Ubuntu, gcc and check the results.

  • FormerMember
    0 FormerMember

    Thanks Aryan for verifying this. Updates from my side - When I changed from sending notification of payload of 1 octet to 16 octet, the radio notification handler gets called every 7.5 ms as it should. Strange. This was based on the ble-lbs example - github.com/.../SDKv8.0 I'll try to see if I can get a minimal example where I can recreate this behaviour and post it here for your reference.

    I would appreciate your help with my current problem which is similar to what I posted but not exactly the same. I'm working on an application where the most recent sample needs to be sent as soon as possible. Here the reliability of BLE's link layer is a bane rather than a boon. This is why I cannot queue up packets in the application buffer, as this will affect the latency. So what I'm doing is:

    bool tx_pending =  false;
    void RADIO_NOTIFICATION_IRQHandler(void){
          if(false == tx_pending){
                //Send a packet as notification
          }
    }
    
    void on_ble_evt(void){
          switch(evt_id){
                case BLE_EVT_TX_COMPLETE:
                      tx_pending = true;
                      break;
          }
    }
    

    Even with different connection intervals and different radio notification distances the notifications are always received at an interval double of the connection interval. Could you please see why this is. As far as I read, queueing up in the radio notification event is early enough to be sent in that connection event. Thanks a lot!

  • Hi PrithviRaj, If you can post a minimal example like you mentioned where I can reproduce this problem, it would save me a lot of time to set up the environment. Also I need to ask something you probably have checked before. You are checking the radio notification callback frequency and not the frequency with which HVX is done right?

  • I cannot reproduce this PhrithviRaj, I tested this with latest SDK9.0 and the softdevice that comes with it on PCA100028. Now i wait for your example project.

  • FormerMember
    0 FormerMember

    I've added a minimal example in the original question that does what I mentioned in my previous comment. It is based on nrf-ble-app-lbs SD 8.0 example. The pin toggling in the radio event happens every 7.5 ms, but the notification received in the master is at every 15 ms. Please see if you can figure out what is happening. Thanks!

Related