Advertisement handler on SYTEM_ON sleep mode.

Hello , 

i am trying to find out advertisement handler while SD advertising in SYSTEM ON mode. 

i have added a simple counter to see if it is increasing or not but it is not. 

I can connect to the device , it is advertising , i can see from the sniffer but some how it is not hitting to this on_adv_evt function.

1-) is this the correct handler function ? 

2-) if it is not , how can i hook to the softdevices advertisement handler in system on sleep mode. 

i am developing on segger embedded studio + SDK15 + nrf52832

/**@brief Function for handling advertising events.
*
* @details This function will be called for advertising events which are passed to the application.
*
* @param[in] ble_adv_evt Advertising event.
*/
volatile uint32_t count_adv = 0 ;
void on_adv_evt(ble_adv_evt_t ble_adv_evt)
{
uint32_t err_code;
count_adv++;

Parents
  • Hello,

    The function on_adv_evt() is called only when the Advertising Module transitions to a new mode. For instance, if you have enabled slow advertising with a timeout, the on_adv_evt() will be invoked when the slow advertising has timed out. However, if you advertise without a timeout, the handler will never be called.

    1-) is this the correct handler function ? 

    You can monitor the BLE event handler if you want to see the connection and disconnect events.

    2-) if it is not , how can i hook to the softdevices advertisement handler in system on sleep mode. 

    Could you say a bit more about what you are trying to acheive?

    Best regards,

    Vidar

  • Hi , 

    I am continuously advertising in system on sleep mode , and the device is connectable .... What I want is, I want to hook soft devices adv handler.so I want to call my own function after each advertisement of soft device . Because SD  wakes up the device according to defined intervals then goes to sleep . I want to call a function when SD wakes up to advertise.  How can I do that , is there any way to hook SD 's advertisement function?

    Thank you.

  • Hi,

    You can have the application wake up after every advertisement event by enabling the radio notification feature in the SoftDevice. Note that the radio notification signal will trigger after every protocol event, so the application must track whether it is a connection or advertisement event.

    Best regards,

    Vidar

Reply Children
  • Hello. Thank you for your replies . İs there any example about this , which handler is handling that signal in which .c file if you remember/know it's name ?

    Thanks again

  • Hello, 

    The SDK does not include any samples for this, so  I made a small example, please see code snippet below.

    void RADIO_NOTIFICATION_IRQHandler(void)
    {
        static uint32_t count_adv; 
    
        if (m_conn_handle == BLE_CONN_HANDLE_INVALID) 
        {
            count_adv++;
            NRF_LOG_INFO("Advertisment event counter: %d", count_adv);
        }
    }
    
    /*to be called after ble_stack_init() before adv. start */
    static void radio_notification_init(void) 
    {
        uint32_t err_code;
    
        NVIC_SetPriority(RADIO_NOTIFICATION_IRQn, APP_IRQ_PRIORITY_LOW);
        NVIC_EnableIRQ(RADIO_NOTIFICATION_IRQn);
    
        err_code = sd_radio_notification_cfg_set(NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE, 0);
        APP_ERROR_CHECK(err_code);
    
    }
    
    
    /**@brief Function for application main entry.
     */
    int main(void)
    {
        ...
        ble_stack_init();
        radio_notification_init();
        ...

    This snippet should be compatible with any of the Bluetooth samples that define the m_conn_handle variable. This variable is updated on the connect and disconnect event.

Related