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

[advertising stop]

Hi all,

Someone can give me a information about the difference between function uint32_t err_code = sd_ble_gap_adv_stop(); and stop the advertising with using the timeout that put the state machine to ADV_MODE_SLOW and after in IDLE_MODE when arrive the GAP_EVT_TIMEOUT ( i use a gls example).

Because i don't understand how when the a BLE_ADV_EVT_IDLE is send the advertising stopped. how Does work it?

If i use a sd_ble_gap_adv_stop, is there a way to stopped the EVT_TIMEOUT? Thanks, Anna

Parents
  • Hi,

    The function sd_ble_gap_adv_stop() is used to stop the advertising directly from your application code.

    In the gls example you can choose to use ADV_MODE_FAST, ADV_MODE_SLOW or to use both. You can enable the different modes in the advertising_init() function with:

    options.ble_adv_fast_enabled  = true;
    options.ble_adv_slow_enabled =  true; 
    

    And you can set the timeout for the different modes with:

    options.ble_adv_fast_timeout  = 30;
    options.ble_adv_slow_timeout  = 180;
    

    When the timeout happens, you will get the event BLE_GAP_EVT_TIMEOUT. If you are in ADV_MODE_FAST mode, it will switch to ADV_MODE_SLOW, and if you are in ADV_MODE_SLOW it will switch to BLE_ADV_MODE_IDLE and the SoftDevice will stop advertising. The function sd_ble_gap_adv_stop() is not used.

    With the limited discoverable mode(BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE) it is not allowed to advertise longer than the timeout period. But if you don't want the advertising to stop, you can switch to general discoverable mode(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE), and set the timeout to 0 to do unlimited advertising:

    advdata.flags                 = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    options.ble_adv_fast_timeout  = 0;
    
  • Q1: i think that the softdevice stops the timer when connection occurs.Correct?

    A1: Correct.

    Q2: And is there an api function to avoid that the timer will expire?

    A2: No.

    If you use sd_ble_gap_adv_stop() the timer and advertising is stopped, and you dont get BLE_GAP_TIMEOUT.

Reply Children
No Data
Related