This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Stop calling NRF_SDH_BLE_OBSERVERs

Is there any way that a BLE event handler installed with NRF_SDH_BLE_OBSERVER, can stop the execution of other (following) observers?

I have various modules using their own BLE observer each but the authentication module (with higher priority) should be able to stop the execution of the following. Any way to achieve this?

Parents Reply Children
  • Hello,

    I think this might be ok as long you don't have any other low priority observers that must process the event. Only other solution that comes to mind is to add a context variable when you register your observers which will be passed as an input to your event handler.

    Something like this:

    static bool m_skip_evt_processing;
    
    /* To be called from the higher priority observer*/
    void disable_oberserver_name (void)
    {
        m_skip_evt_processing = true;
    }
    
    static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
    {
        bool * skip = (bool *) p_context;
        
        if (*skip)
        {
            return;
        }
        
        uint16_t conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
        switch (p_ble_evt->header.evt_id)
        {
    
    
    NRF_SDH_BLE_OBSERVER(m_ble_evt_observer, <low pri observer>, ble_evt_handler, m_skip_evt_processing);

    Best regards,

    Vidar

Related