Bluetooth address and settings_load()

Hello all,

i have a problem and I hope that someone can help me.

I can change the bluetooth address of the device with the following code:

err = bt_addr_le_from_str(addr_str, type_str, &addr);
if (err) {
	printk("Invalid BT address (err %d)\n", err);
}

if (addr.type == BT_ADDR_LE_PUBLIC) {
	printk("Using public address\n");
	err = bt_ctlr_set_public_addr(addr.a.val);
	if (err) {
        printk("Failed to set public address (err %d)\n", err);
    } else {
        printk("Public address set successfully\n");
    }
	return;
}

and this is okay.

I have the problem when I add this part of code:
CONFIG_SETTINGS=y

and

if (IS_ENABLED(CONFIG_SETTINGS)) {
	settings_load();
	printk("Settings load \n");
}

With this part of code I can not set my bluetooth address. The bluetooth address of the the device is not the one that I have setted but is the one inside the chip (i think).

I need to add settings_load() to keep the bond device information after the power off.

How can avoid this??

Thanks in advance.

Parents Reply
  • Hello,

    Thanks for the clarification. I should have tested this first, I see now that bt_id_create() won't work when you want to set a public address with the Softdevice controller. Please try to run this code before bt_enable() in your application:

    #include <zephyr/bluetooth/controller.h>
        ...
        const uint8_t addr[] = {0x11, 0xBA, 0xEF, 0xBE, 0xAD, 0xDE};
    	bt_ctlr_set_public_addr(addr);

Children
Related