Hello!
I am trying to create a connectable advertiser that can have its advertisement data updated dynamically on a nrf52832. I am creating the advertisement with this code:
constexpr bt_le_adv_param params = BT_LE_ADV_PARAM_INIT(
BT_LE_ADV_OPT_USE_NAME | BT_LE_ADV_OPT_USE_IDENTITY | BT_LE_ADV_OPT_CONNECTABLE,
BT_GAP_ADV_FAST_INT_MIN_2,
BT_GAP_ADV_FAST_INT_MAX_2,
NULL
);
int err = bt_le_ext_adv_create(¶ms, &cbs, &adv);
__ASSERT(err == 0, "Create advertiser init");
If I then start advertising with
bt_le_ext_adv_start_param start_params = {
.timeout = 0,
.num_events = 0
};
int err = bt_le_ext_adv_start(adv, &start_params);
return err;
It starts advertising and I can see the advertisements in the NRFConnect app. However, if I attempt to set the advertisement before the `bt_le_ext_adv_start` with
static AdvData data {
AdvField<uint8_t> { BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR) },
AdvField<uint16_t> { BT_DATA_MANUFACTURER_DATA, 0x1234 }
};
int err = bt_le_ext_adv_set_data(adv, data.data(), data.size(), 0, 0);
//Also attemted this just to make sure
static bt_data adv_buffer[] = {
BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
BT_DATA_BYTES(BT_DATA_MANUFACTURER_DATA, COMPANY_ID_BYTES(0x1234)),
};
int err = bt_le_ext_adv_set_data(adv, adv_buffer, ARRAY_SIZE(adv_buffer), 0, 0);
There is no error returned, but there is no advertisements. Nothing shows in the NRFConnect application.
How do I correctly set the advertisement data before starting advertising using the `bt_le_ext` methods?
Thanks,
Sam