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

Pre/Post Advertise Hook

Hi all,

My application gathers sensor data and uses the advertisement packet to broadcast the values (much the same as the nordic temp sensor example). Rather than having to have a separate timer which aligns with the advertise interval (which is what the example does), is there a pre-transmit hook i can use which will synchronise my sensor reads with the advertisement transmission?

Or, is the advertisement interval handled (via the SD) through an application timer? in which case is there a way i could identify which timer it is and somehow run a pre-transmit function?

Thanks for your help..

Parents
  • This is a great question. If you're not in the connected state then the only radio notifications you'll get are before and after the SD grabs the CPU to advertise.

    Using the function that Petter mentioned is easy. Invoke it in main():

    ble_radio_notification_init(NRF_APP_PRIORITY_HIGH, NRF_RADIO_NOTIFICATION_DISTANCE_800US, InterruptEvent);
    

    and define the pre/post event function that takes your sensor sample and adjusts the advertising payload:

    void InterruptEvent(bool radio_active)
    {
    }
    

    Dan

  • Just re-reading your reply Dan and you mention that you'll only get them before/after advertising when not connected so perhaps this will work..

    I thought to time it to know how long (roughly) a standard advertisement takes vs a scan response.. Would this be a reasonable approach to determine if we had been scanned (i.e.: we sent a scan response)..

Reply Children
No Data
Related