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
  • 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.

Children
Related