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

Is there a way to turn off the automatic behavior of restarting advertising on disconnect?

Hello, we understand that the Nordic framework, by default, restarts advertising on disconnect.  I learned that here, thank you:

https://devzone.nordicsemi.com/f/nordic-q-a/60901/cant-re-start-advertising-after-disconnect

We have an application in which we would like manual control of this.  Can we easily disable this automatic behavior, and optionally (according to our logic) decide whether to restart, or not, advertising on disconnect?  There are situations where we want our software to disconnect and not advertise.

We are using SDK 16.0.

Thank you.

Parents
  • Can we easily disable this automatic behavior, and optionally (according to our logic) decide whether to restart, or not, advertising on disconnect?

     Yes. You can disable this by setting ble_adv_modes_config_t::ble_adv_on_disconnect_disabled to true.

    Like shown here:

    /**@brief Function for initializing the Advertising functionality.
     */
    static void advertising_init(void)
    {
        uint32_t               err_code;
        ble_advertising_init_t init;
    
        memset(&init, 0, sizeof(init));
    
        init.advdata.name_type          = BLE_ADVDATA_FULL_NAME;
        init.advdata.include_appearance = false;
        init.advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
    
        init.srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        init.srdata.uuids_complete.p_uuids  = m_adv_uuids;
    
        init.config.ble_adv_fast_enabled  = true;
        init.config.ble_adv_on_disconnect_disabled = true;
        init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
        init.config.ble_adv_fast_timeout  = APP_ADV_DURATION;
        init.evt_handler = on_adv_evt;
    
        err_code = ble_advertising_init(&m_advertising, &init);
        APP_ERROR_CHECK(err_code);
    
        ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
    }

Reply Children
No Data
Related