As said on the topic "GAP Address types", the random static address can be changed when system boots up. I can't find any content about how to make it. Could anyone offer any tips? best regards!
As said on the topic "GAP Address types", the random static address can be changed when system boots up. I can't find any content about how to make it. Could anyone offer any tips? best regards!
Check out the function "sd_ble_gap_address_set" in ble_gap.h. Here's an example:
ble_gap_addr_t gap_addr;
gap_addr.addr_type = BLE_GAP_ADDR_TYPE_RANDOM_STATIC;
// "my_random_addr" must be random generated.
memcpy(&gap_addr.addr, my_random_addr, sizeof(gap_addr.addr));
gap_addr.addr[5] |= 0xc0; // 2 MSBit must be '11' for RANDOM_STATIC address, see v4.0, Vol 3, Part C, chapter 10.8
err_code = sd_ble_gap_address_set(gap_addr);
APP_ERROR_CHECK(err_code);
Hi,
in what type of memory will be written to the new address? what will be with this address after reset?
Best regards, Artem
This will be stored in the softdevice's RAM. This means that you will have to set the custom address, using the above sd_-call, on every boot up.
Where would be a good place to include this code if we are using the sample beacon project? I currently cannot find where in this sample project, the function sd_ble_gap_address_set() is being called. I'm quite new to nRF programming, so I would appreciate if you could give some basic instructions.
Hi Sarah, You can place this code in the init, after ble_stack_init().
Cheers, Håkon