How to change the BLE mac address of NRF5430 at Real Time with NCS SDK?

  I follow below thread and refer to sample code and  the BLE mac address can be changed after system just boot up.

   devzone.nordicsemi.com/.../325131

   But after boot up, I want to change  the BLE mac address again, it doesn't work and the ble MAC address keep unchanged, it is expected?  Is it possible to change the desired BLE mac address at real time without HW reset?

Below is my Sudo code:

nrf5340 boot up,  

bt_enable(NULL);

bt_addr_t addr = {{0xFE, 0xCA, 0xA0, 0xAC, 0xDC, 0xBA}};
ble_set_mac(&addr);

settings_load();

ble_advertise();  //it works with ble addr = {{0xFE, 0xCA, 0xA0, 0xAC, 0xDC, 0xBA}}

ble_Stop_advertise();

bt_addr_t addr = {{0xFE, 0xCA, 0xA0, 0xAC, 0xDC, 0xBB}};
ble_set_mac(&addr);

settings_load();

ble_advertise(); //it doesn't work, ble address cant be changed.

found the ble's mac address is still  = {{0xFE, 0xCA, 0xA0, 0xAC, 0xDC, 0xBA}};

Parents Reply
  • one more issue....

    I use below to change the ble mac address:

    bt_addr_le_t addr;
    err = bt_addr_le_from_str("FF:EE:DD:CC:BB:AA", "random", &addr);
    if (err) {
    printk("Invalid BT address (err %d)\n", err);
    }

    err = bt_id_create(&addr, NULL);
    if (err < 0) {
    printk("Creating new ID failed (err %d)\n", err);
    }

    It works, the BLE mac address can be change succesfully. I checked by nrf Connect App -> Scanner.

    But after HW reset NRF5430 device, the BLE address is changed be to another BLE mac address, seems it is NRF5430's default/factory mac address.

    my question is how to keep my modified BLE Mac address after HW reset/power-up cycle?

Children
Related