How to use public-addr and non-resolvable-addr on nrf connect SDK

I want to use  public-addr and non-resolvable-addr for advertising on nrf connect SDK.

I was able to advertise using a random static addr.

But,
1. can not set public addr.
2. can not create non-resolvable-addr 's bt_id.

Following test code.

static bt_addr_le_t random_bdaddr = {
	.type = BT_ADDR_LE_RANDOM,
	.a = {
		.val = {0xC1, 0x11, 0x11, 0x11, 0x11, 0xC1},
	}
};

static struct bt_le_adv_param adv_param = {
	.id				= 0,
	.options		= BT_LE_ADV_OPT_USE_IDENTITY | BT_LE_ADV_OPT_EXT_ADV,
	.interval_min	= 0x20,
	.interval_max	= 0x20,
};

	bt_ctlr_set_public_addr(public_addr);
	(or sdc_hci_cmd_vs_zephyr_write_bd_addr(&public_addr);)

	bt_enable(NULL);

	int id0 = bt_id_create(&random_bdaddr, NULL);

	bt_addr_le_t nrpa_bdaddr;
	bt_addr_le_create_nrpa(&nrpa_bdaddr);
	int id1 = bt_id_create(&nrpa_bdaddr, NULL); /* this is ERROR!! */

	adv_param.id = 0; /* bt_id */
	bt_le_ext_adv_create(&adv_param, &adv_cb, &adv);
	bt_le_ext_adv_set_data(adv, bdata, 1, NULL, 0);
	bt_le_ext_adv_start(adv, &adv_start_param);

Parents
  • Hi,

    Different address types must be configured in different ways. To set a public address, the simplest is to do as illustrated here:

    static void set_public_addr(void)
    {
    	uint8_t pub_addr[BT_ADDR_SIZE] = {0xba, 0xde, 0xba, 0x11, 0xca, 0xfe};
    	bt_ctlr_set_public_addr(pub_addr);
    }

    Note that this must be done before you call bt_enable().

    I need to look a bit more into non resolvable private addresses though, as I did not get that to work. That is a very uncommon address type, though. May I ask why you want to use it?

  • I tried using bt_ctlr_set_public_addr but it didn't work. (see code above)
    Called before bt_enable().
    what am i doing wrong?

    I implement encrypted advertising transmission.
    I want to use NRPA to make it harder to track. (like bluetooth mesh does)

  • Hi,

    Which device are you using? As you referred to nRF5 SDK in some other post I assumed you were using a nRF52 series device, but perhaps that is not the case? If you are, the function from my previous post is enough to set the public address, and you can test this by copy-pasting it to the beacon sample and calling it before bt_enable().

    In what way does it fail in your case?

    Regarding the non-resolvable random address you cannot use a non-static identity address, so it is expected that the call to bt_id_create() fails. That does not cause problems with security though, as long as you never advertise with that address. To advertise with a random address, adjust the advertising flags accordingly (for instance pick BT_LE_EXT_ADV_NCONN). Along that line it also looks strange that you added the BT_LE_ADV_OPT_USE_IDENTITY option, as I assume that is not what you want?

  • OK.

    About NRPA solved. Simply not specifying BT_LE_ADV_OPT_USE_IDENTITY made it a non-resolvable-addr.

    But, As for the public address setting, it doesn't work.
    Calling bt_ctlr_set_public_addr still NRPA.

Reply Children
Related