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 Reply Children
  • 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