Update extended advert error

Hi,

I create two extended adverts, one connectable and one none,  (nRF Connect 2.0.0) using the following code:

static struct bt_le_ext_adv *ext_adv[CONFIG_BT_EXT_ADV_MAX_ADV_SET];
static const struct bt_le_adv_param *connectable_adv_param =
	BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV | BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_USE_NAME,
			BT_GAP_ADV_FAST_INT_MIN_2, /* 100 ms */
			BT_GAP_ADV_FAST_INT_MAX_2, /* 150 ms */
			NULL);
			
static const struct bt_le_adv_param *non_connectable_adv_param =
	BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV | BT_LE_ADV_OPT_USE_NAME,
			0x140, /* 200 ms */
			0x190, /* 250 ms */
			NULL);

static ble_network_manufacturer_data_t m_network_manufacturer_data = {
	.LismoreID_0 = LI_COMPANY_1,
	.LismoreID_1 = LI_COMPANY_2,
	.DeviceType = DT_IC1GW,
	.ChannelID = 0,
	.AddressID = 0,
	.EventID = 0,
	.UserID = 0,
    .PreviousUserID = 0,
	.Flags = 0,
	.CurrentPriority = 0,
	.CalibratedRSSI = 0,
	.MinimumRSSI = 0,
	.NetworkCRC = 0,
};


static const struct bt_data ext_ad[] = {
	BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
	BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_INTERCALL_P_VAL),
	BT_DATA(BT_DATA_MANUFACTURER_DATA, &m_network_manufacturer_data, sizeof(ble_network_manufacturer_data_t)),
};


static int duel_adv_create(void)
{
	int err;

	err = bt_set_name(DEVICE_NAME);
	if (err) {
		LOG_INF("Failed to set device name (err %d)", err);
		return err;
	}


	err = advertising_set_create(&ext_adv[NON_CONNECTABLE_ADV_IDX], non_connectable_adv_param,
				     ext_ad, ARRAY_SIZE(ext_ad));
	if (err) {
		LOG_INF("Failed to create non-connectable advertising set (err %d)", err);
		return err;
	}

	err = advertising_set_create(&ext_adv[CONNECTABLE_ADV_IDX], connectable_adv_param,
				     ext_ad, ARRAY_SIZE(ext_ad));

	if (err) {
		LOG_INF("Failed to create connectable advertising set (err %d)", err);
		return err;
	}

	LOG_INF("Created adverts");

	return err;
}


static int advertising_set_create(struct bt_le_ext_adv **adv,
				  const struct bt_le_adv_param *param,
				  const struct bt_data *ad, size_t ad_len)
{
	int err;
	struct bt_le_ext_adv *adv_set;

	err = bt_le_ext_adv_create(param, &adv_cb, adv);
	if (err) {
		return err;
	}

	adv_set = *adv;

	printk("Created adv: %p\n", adv_set);

	err = bt_le_ext_adv_set_data(adv_set, ad, ad_len, NULL, 0);
	if (err) {
		LOG_INF("Failed to set advertising data (err %d)", err);
		return err;
	}

	return bt_le_ext_adv_start(adv_set, BT_LE_EXT_ADV_START_DEFAULT);
}

This works great, but then i want to amend the data in the manufacturer data array and update the adverts data, so i do the array update and then call the following function:

static int update_advert_data(void)
{
	int err;



	err = bt_le_ext_adv_set_data(&ext_adv[NON_CONNECTABLE_ADV_IDX], &ext_ad, ARRAY_SIZE(ext_ad), NULL, 0);
	if (err) {
		LOG_INF("Failed to update non connectable adv (err %d)", err);
		return err;
	}	
	err = bt_le_ext_adv_set_data(&ext_adv[CONNECTABLE_ADV_IDX], &ext_ad, ARRAY_SIZE(ext_ad), NULL, 0);
	if (err) {
		LOG_INF("Failed to update connectable adv (err %d)", err);
		return err;
	}

	return err;
}

But i get the following error:

[00:02:58.154,479] <err> bt_adv: Too big advertising data
[00:02:58.154,510] <inf> main: Failed to update non connectable adv (err -22)

How do i go about updating the data held in the adverts while they are live?

Many thanks

Parents Reply Children
  • The advertisement works fine when initially started, everything is great

    I want to update the adverts manufacturing data value, the size is never changed, its the second call to the bt_le_ext_adv_set_data function that causes the error, not the first call.  If it was a size problem, then the first call would also fail, the same array is being used in both calls

    I suspect the bt_le_ext_adv_set_data call is trying to pend the array onto the end of the array from the first call, rather than remove the array and replace it - thus increasing the size - but this is not what i want.

    All i want to do is update the values being advertised by the first call to bt_le_ext_adv_set_data - how can i do this?

  • Hi

    Even when i start and stop the adverts with the following code, i get the same error

  • Gentle bump.... Its been 11 days

    Is it possible to assign this ticket to someone who has a little more time on their hands please?

  • Hi,

    Sorry for the delay. Joakim is out of office. This case have been assigned to me.

    What did you set CONFIG_BT_EXT_ADV_MAX_ADV_SET to? Could to try to increase that value?

    If increasing the value does not work, would it be possible for you to create a small sample that reproduces this issue, that I could have a look at? I think that might be the fastest way to solve this now.

  • Hi,

    Many thanks for the reply, CONFIG_BT_EXT_ADV_MAX_ADV_SET is set to two, as all i want is two advertisements, i do not want to add another advertisement, just amend the values (not length) od the current ones:

    Using the code at the top of this ticket, setup and start the adverts - everything works perfectly, and i see the two adverts with correct data

    now change the advert data, for example

    m_network_manufacturer_data.NetworkCRC = 0x12345678

    now call update_advert_data() - this is where the error appears; rather than updating the current adverts, it seems to be trying to make them longer or adding a new one

Related