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

How to set my nRF device to use the private resolvable address

Hello~ I'm using the nRF52832 board, s132_nrf52_6.1.0_softdevice, SDK 15.2. I'm focusing on 3 peripheral examples;

ble_app_hrs & ble_app_eddystone & ble_app_beacon

If I understood correctly, I think these examples' MAC address doesn't change.

I made this conclusion after viewing with the nRF connect mobile App.

Umm, it is possible to make these examples to change the MAC addresses as the resolvable random addresses, right?

What SoftDevice function should I call to make this happen?

Lastly, can I set a duration to make the address to change?

For example, I want to make the MAC address (which is resolvable) to change its address every 5 minutes.

  • Thank you, Vidar. One last question, please.

    #include "ble_gap.h"
    
        ble_gap_privacy_params_t ble_gap_privacy_params = {0};
        
        ble_gap_privacy_params.privacy_mode = BLE_GAP_PRIVACY_MODE_DEVICE_PRIVACY;
        ble_gap_privacy_params.private_addr_type = BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE;
        ble_gap_privacy_params.private_addr_cycle_s = BLE_GAP_DEFAULT_PRIVATE_ADDR_CYCLE_INTERVAL_S;
        ble_gap_privacy_params.p_device_irk = NULL;
        err_code = sd_ble_gap_privacy_set(&ble_gap_privacy_params);
        APP_ERROR_CHECK(err_code);

    I tried this by referring this thread. I noticed that the MAC address of the beacon changes after I turn off/on the device. When using the sd_ble_gap_privacy_set, is there a way to set the period for changing the address? just like you this this;

    privacy_params.private_addr_cycle_s = 300; // Change address every 5 minutes

  • Sure, just replace BLE_GAP_DEFAULT_PRIVATE_ADDR_CYCLE_INTERVAL_S with 300. Default interval is 15 minutes. Same code as I posted earlier but without PM:

    void gap_init(void)
    {
        uint32_t err_code;
        ble_gap_privacy_params_t privacy_params;
    
        memset(&privacy_params, 0, sizeof(ble_gap_privacy_params_t));
    
        privacy_params.privacy_mode         = BLE_GAP_PRIVACY_MODE_DEVICE_PRIVACY;
        privacy_params.private_addr_type    = BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE;
        privacy_params.private_addr_cycle_s = 300;
    
        err_code = sd_ble_gap_privacy_set(&privacy_params);
        APP_ERROR_CHECK(err_code);
    }

Related