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?

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

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

  • Good to hear you got NRPA working. Regarding public address I am not sure I understand the issue now. Can you elaborate a bit? Exactly what to do you do, and exactly how does it fail?

  • I try,

    bt_le_adv_param.id=0 / bt_le_adv_param.options=BT_LE_PER_ADV_OPT_NONE
    BDADDR=non-resolvable-private address

    bt_le_adv_param.id=0 / bt_le_adv_param.options=BT_LE_ADV_OPT_USE_IDENTITY
    BDADDR=random static address (FICR.DEVICEADDR)

    call bt_ctlr_set_public_addr() before bt_enable()
    bt_le_adv_param.id=0 / bt_le_adv_param.options=BT_LE_PER_ADV_OPT_NONE
    BDADDR=non-resolvable-private address

    call bt_ctlr_set_public_addr() before bt_enable()
    bt_le_adv_param.id=0 / bt_le_adv_param.options=BT_LE_ADV_OPT_USE_IDENTITY
    BDADDR=random static address (FICR.DEVICEADDR)

  • I am still confused. What is the expected result? And what is the actual result? Please elaborate.

  • My Code (simply)

    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);
    }
    
    static struct bt_le_adv_param adv_param = {
    	.id				= BT_ID_DEFAULT,
    	.options		= BT_LE_PER_ADV_OPT_NONE,
    	.interval_min	= 0x00a0,
    	.interval_max	= 0x00a0,
    };
    
    main()
    ...
    	set_public_addr();
    	bt_enable(NULL);
    	bt_le_ext_adv_create(&adv_param, &adv_cb, &ext_adv0);
    	bt_le_ext_adv_set_data(ext_adv0, bdata, 1, NULL, 0);
    	bt_le_ext_adv_start(adv, &adv_start_param);
    ...

    If adv_param.options = BT_LE_PER_ADV_OPT_NONE
    Result
    001845.151 37 ___ 15:0B:7D:17:CF:B9 -45 10FF112233445566778899AABBCCDDEEFF
    (non resolvable private address)

    If adv_param.options = BT_LE_ADV_OPT_USE_IDENTITY
    Result
    001962.104 37 ___ xx:xx:xx:xx:xx:xx -40 10FF112233445566778899AABBCCDDEEFF
    (xx is FICR.DEVICEADDR (Random Static Address))


    what i want
    BA:DE:BA:11:CA:FE 10FF112233445566778899AABBCCDDEEFF
    (public address)

Related