nrf connect sdk example periodic advertising stop changing mac address

HI guys I am working on nrf connect sdk v2.0.0, I am trying to modify periodic_adv example to stop changing mac address every time an advertising restart.

#include <bluetooth/bluetooth.h>

static uint8_t mfg_data[] = { 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x10,
							  0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x10,
							  0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x10,
							  0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x10};

static const struct bt_data ad[] = {
	BT_DATA(BT_DATA_MANUFACTURER_DATA, mfg_data, 40),
};

void main(void)
{
	struct bt_le_ext_adv *adv;
	int err;

	printk("Starting Periodic Advertising Demo\n");

	/* Initialize the Bluetooth Subsystem */
	err = bt_enable(NULL);
	if (err) {
		printk("Bluetooth init failed (err %d)\n", err);
		return;
	}

	/* Create a non-connectable non-scannable advertising set */
	err = bt_le_ext_adv_create(BT_LE_EXT_ADV_NCONN_NAME, NULL, &adv); //  BT_LE_EXT_ADV_NCONN_NAME  BT_LE_EXT_ADV_SCAN_NAME
	if (err) {
		printk("Failed to create advertising set (err %d)\n", err);
		return;
	}

	/* Set periodic advertising parameters */
	err = bt_le_per_adv_set_param(adv, BT_LE_PER_ADV_DEFAULT);
	if (err) {
		printk("Failed to set periodic advertising parameters"
		       " (err %d)\n", err);
		return;
	}

	/* Enable Periodic Advertising */
	err = bt_le_per_adv_start(adv);
	if (err) {
		printk("Failed to enable periodic advertising (err %d)\n", err);
		return;
	}

	while (true) {
		printk("Start Extended Advertising...");
		err = bt_le_ext_adv_start(adv, BT_LE_EXT_ADV_START_DEFAULT);
		if (err) {
			printk("Failed to start extended advertising "
			       "(err %d)\n", err);
			return;
		}
		printk("done.\n");

		

		k_sleep(K_SECONDS(3));

		printk("Stop Extended Advertising...");
		err = bt_le_ext_adv_stop(adv);
		if (err) {
			printk("Failed to stop extended advertising "
			       "(err %d)\n", err);
			return;
		}
		printk("done.\n");

		k_sleep(K_SECONDS(1));
	}
}

Parents
  • I am also experiencing the same issue. Seems like every call to "bt_le_ext_adv_start" starts advertising with a different device id.

    At boot the sample prints:

    [00:00:00.009,918] <inf> bt_hci_core: Identity: FB:8A:B5:79:6B:BF (random)

    but then it uses completely different addresses.

    nRF Connect app doesn't say if the address is random or static. Here is an example of an address it used: 12:58:A1:42:52:AE .

    Can you please advise if this is a requirement of Extended Advertisement or if this is something that can be controlled in the CONFIG, etc?

     

Reply
  • I am also experiencing the same issue. Seems like every call to "bt_le_ext_adv_start" starts advertising with a different device id.

    At boot the sample prints:

    [00:00:00.009,918] <inf> bt_hci_core: Identity: FB:8A:B5:79:6B:BF (random)

    but then it uses completely different addresses.

    nRF Connect app doesn't say if the address is random or static. Here is an example of an address it used: 12:58:A1:42:52:AE .

    Can you please advise if this is a requirement of Extended Advertisement or if this is something that can be controlled in the CONFIG, etc?

     

Children
No Data
Related