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

Getting time ticks or adv packet count

Is there an internal counter for the number of packets transmitted since power on?

Im trying to change the advertising packet content after a timer is expired or a certain count, but i get invalid parameter error in advertising_init() and advertising_start() functions when i call them for the 3rd time. I think this can solve the problem about changing the packet but im trying to understand when to change it first.

What would be the preferred approach for getting the timer ticks since the board is powered on or get number of packets transmitted so far?

Im using ble_app_hrs example with nrf51-dk on sdk6.1.0 and sd 7.0.0.

Parents Reply Children
  • Thank you Petter, I followed through the tutotial you linked. I'm getting radio notifications, yet they don't seem to be getting affected by the advertising interval. For example, when I set the interval to 5 seconds and increase a counter each time I receive radio_off notification in radio_notification_evt_handler the counter is 30 after 15 seconds. Then I change the advertising interval to 300 ms and the counter is still 30 after 15 seconds. I'm using the highest proiority(1) I can use and shortest notification distance(NRF_RADIO_NOTIFICATION_DISTANCE_800US), according to the docs. I double checked that the advertising packets are being transmitted at the interval I'm setting. Do you think this is normal?

  • Hi,

    I attempted to replicate this, but for me it worked.

    #include "ble_radio_notification.h"
    
    #define RADIO_NOTIFICATION_IRQ_PRIORITY        1
    #define RADIO_NOTIFICATION_DISTANCE            NRF_RADIO_NOTIFICATION_DISTANCE_800US
    volatile uint32_t count = 0;
    
    void radio_notification_evt_handler(bool radio_evt)
    {
        if (radio_evt)
        {
            //radio going active
        } 
        else 
        {
            //radio inactive
            count++;
        }
    }
    

    Then watch the count variable in your IDE, for an advertising interval of 100 gave 0x54 and an interval of 1000 gave 0xC.

    Maybe your code is not in the advertising state, but is connected to something and sending two packets per second?

  • Im setting the advertising interval inside advertising_init() via adv params, same as the ble_app_hrs example. I will change it manually and try again.

Related