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

Can I change nRF5 bluetooth advertising interval dynamically?

I would like to dynamically change bluetooth LE advertising interval. I am using nRF51 and nRF52, with SDK's 8 and 12. Is that possible and how to do it?

Our application has kind of "interactive demo" mode needing short interval, but it dynamically changes into the real operating mode when time passes. To save power, advertising interval should then be made longer.

Parents
  • Hi,

    The advertising module have two different modes you can use for this. ADV_MODE_FAST and ADV_MODE_SLOW, and you can specify the advertising interval you want for each mode. The advertising will start in ADV_MODE_FAST, and switch to ADV_MODE_SLOW after a specified timeout period(APP_ADV_FAST_TIMEOUT_IN_SECONDS). The ADV_MODE_SLOW also has a timeout period, and when expired it will switch to ADV_MODE_IDLE and stop advertising.

    ble_adv_modes_config_t options;
    memset(&options, 0, sizeof(options));
    
    options.ble_adv_fast_enabled  = true;
    options.ble_adv_fast_interval = APP_ADV_FAST_INTERVAL;
    options.ble_adv_fast_timeout  = APP_ADV_FAST_TIMEOUT_IN_SECONDS;
    
    options.ble_adv_slow_enabled  = true;
    options.ble_adv_slow_interval = APP_ADV_SLOW_INTERVAL;
    options.ble_adv_slow_timeout  = APP_ADV_SLOW_TIMEOUT_IN_SECONDS;
    

    With 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 in the ADV_MODE_SLOW mode, 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_slow_timeout  = 0;
    
  • Okay, thank you very much about those hints! I think I can now implement the thing :)

Reply Children
No Data
Related