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

Possible to know TX complete of single advertisement within timeout period?

Hey guys,

I’m trying to send a single non-connectable beacon every few minutes in the lowest power way possible. nRF51822, SD S110 8.0, SDK 9-2. Different scenario from previous post.

I’ve done this by setting the interval to 1sec, and timeout to 1sec. Then on the event BLE_GAP_EVT_TIMEOUT with source of BLE_GAP_TIMEOUT_SRC_ADVERTISING, I do a hard shutdown of the nRF51822 into OFF mode.

I know three advertisements will be sent during this one second period (one on each channel), but is there a way to know exactly when the advertisement TX completes such that I can enter OFF mode sooner than 1sec?

Thanks! Brian

#define APP_CFG_NON_CONN_ADV_TIMEOUT    1   
#define NON_CONNECTABLE_ADV_INTERVAL    MSEC_TO_UNITS(1000, UNIT_0_625_MS)


err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);

static void ble_evt_dispatch(ble_evt_t * p_ble_evt) {

  if((p_ble_evt->header.evt_id == BLE_GAP_EVT_TIMEOUT) &&
     (p_ble_evt->evt.gap_evt.params.timeout.src == BLE_GAP_TIMEOUT_SRC_ADVERTISING))
    {
       while(1) sd_power_system_off();
Parents
  • You can use the radio notification functionality found in nRF51_SDK_9.0.0_2e23562\components\ble\ble_radio_notification.

    This will allow you to have a callback every time the radio goes from active to disabled and vice versa. I think the first active-disabled loop will come after an entire advertisement event (I.E. three packets) has been completed.

    void m_on_radio_notification_evt(bool radio_active)
    {
        static bool has_been_active = false;
    
        if(radio_active)
            has_been_active = true;
    
        else if(!radio_active && has_been_active)
        {
            // ADV event completed
        }
    }
    
    
    ....
    void init(void)
    {
        ble_radio_notification_init(NRF_APP_PRIORITY_HIGH,
                                    NRF_RADIO_NOTIFICATION_DISTANCE_800US,
                                    m_on_radio_notification_evt);
    ...
    }
    
Reply
  • You can use the radio notification functionality found in nRF51_SDK_9.0.0_2e23562\components\ble\ble_radio_notification.

    This will allow you to have a callback every time the radio goes from active to disabled and vice versa. I think the first active-disabled loop will come after an entire advertisement event (I.E. three packets) has been completed.

    void m_on_radio_notification_evt(bool radio_active)
    {
        static bool has_been_active = false;
    
        if(radio_active)
            has_been_active = true;
    
        else if(!radio_active && has_been_active)
        {
            // ADV event completed
        }
    }
    
    
    ....
    void init(void)
    {
        ble_radio_notification_init(NRF_APP_PRIORITY_HIGH,
                                    NRF_RADIO_NOTIFICATION_DISTANCE_800US,
                                    m_on_radio_notification_evt);
    ...
    }
    
Children
Related