How to update advertising data dynamically (Zephyr)

Hi support team

If I want to implement update advertising data dynamically function, which method is recommended?

1. bt_le_adv_stop(); and bt_le_adv_start(adv, ad, ad_len, sd, sd_len);

2.bt_le_ext_adv_set_data(adv, ad, ad_len, sd, sd_len) or bt_le_adv_update_data(adv, ad, ad_len, sd, sd_len) 

What is the difference between bt_le_ext_adv_set_data and bt_le_adv_update_data?

Parents
  • Hi

    The recommended method to update advertising data dynamically is to use bt_le_ext_adv_set_data(adv, ad, ad_len, sd, sd_len) or bt_le_adv_update_data(ad, ad_len, sd, sd_len).

    The function bt_le_ext_adv_set_data() is used to set an advertising set’s advertising or scan response data. If the advertising set is currently advertising, then the advertising data will be updated in subsequent advertising events. When both BT_LE_ADV_OPT_EXT_ADV and BT_LE_ADV_OPT_SCANNABLE are enabled then advertising data is ignored. When BT_LE_ADV_OPT_SCANNABLE is not enabled then scan response data is ignored.

    On the other hand, bt_le_adv_update_data() is used to update advertisement and scan response data. The parameters include data to be used in advertisement packets and scan response packets, and the number of elements in each.

    The difference between bt_le_ext_adv_set_data() and bt_le_adv_update_data() is that the former is used to set the advertising data for an advertising set, while the latter is used to update the advertising data. Both functions can be used to dynamically update advertising data, but the choice between them depends on whether you want to set new data or update existing data.

    Best regards
    Torbjørn

Reply
  • Hi

    The recommended method to update advertising data dynamically is to use bt_le_ext_adv_set_data(adv, ad, ad_len, sd, sd_len) or bt_le_adv_update_data(ad, ad_len, sd, sd_len).

    The function bt_le_ext_adv_set_data() is used to set an advertising set’s advertising or scan response data. If the advertising set is currently advertising, then the advertising data will be updated in subsequent advertising events. When both BT_LE_ADV_OPT_EXT_ADV and BT_LE_ADV_OPT_SCANNABLE are enabled then advertising data is ignored. When BT_LE_ADV_OPT_SCANNABLE is not enabled then scan response data is ignored.

    On the other hand, bt_le_adv_update_data() is used to update advertisement and scan response data. The parameters include data to be used in advertisement packets and scan response packets, and the number of elements in each.

    The difference between bt_le_ext_adv_set_data() and bt_le_adv_update_data() is that the former is used to set the advertising data for an advertising set, while the latter is used to update the advertising data. Both functions can be used to dynamically update advertising data, but the choice between them depends on whether you want to set new data or update existing data.

    Best regards
    Torbjørn

Children
Related