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

    If the advertising set has been configured for extended advertising, then the maximum data length is defined by the controller with the maximum possible of BT_GAP_ADV_MAX_EXT_ADV_DATA_LEN bytes.

    When updating the advertising data while advertising the advertising data and scan response data length must be smaller or equal to what can be fit in a single advertising packet. Otherwise the advertiser must be stopped. 

    Br, 
    Joakim

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

Reply
  • 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?

Children
No Data
Related