This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

to generate random address

since im working on sdk9... advertising program(hello world).i wanted to generate a random address .but i couldnot complete it sucessfully.can you please help me in providing me the code for sdk9 to generate random address. thanking you

with regards joy

  • Hi,

    We don't deliver any specific code examples on how to generate you own BLE address. The default BLE address for your chip is derived from the NRF_FICR->DEVICEADDR registers. These registers are randomly generated in our production, and they are unique for each device (2^46 different combinations, due to MSbits set to '11'). See this post for more information about that.

    You can set your own BLE address using the function sd_ble_gap_addr_set(). You can use e.g. the Random number generator on the nRF5x as a basis if you want to generate your own random address.


    The device address may be of either of the following types defined here.

    The Nordic default is the random static address , for a random static address you do not need to change it periodically. Using a random static address does not require any management by the application.

    Remember that when setting your own generated Static Device Address it should follow these requirements:

    • The two most significant bits of the address shall be equal to 1
    • At least one bit of the random part of the address shall be 0
    • At least one bit of the random part of the address shall be 1

    Note that a device shall not change its static address value once initialized until the device is power cycled. If you have dont any pairing/bonding, and If the static address of a device is changed, then the address stored in peer devices will not be valid and the ability to reconnect using the old address will be lost.


    The private address may be of either of the following two sub-types:

    • Non-resolvable private address
    • Resolvable private address

    For private address you need to use the function sd_ble_gap_privacy_set() to set the address.


    See BLUETOOTH SPECIFICATION Version 5.0 | Vol 6, Part B for more information about this topic.

Related