how to custom public mac address?

   
SDK: nRF Connect SDK Toolchain v2.9.0-nRF54H20-rc1   + DK board(0.9.1)
call bt_id_create error.
	/* STEP 4.2 - Change the random static address */
    bt_addr_le_t addr;
    err = bt_addr_le_from_str("AA:BB:CC:DD:BB:AA", "public", &addr);
    if (err) {
        printk("Invalid BT address (err %d)\n", err);
    }
	printk("AA:BB:CC:DD:BB:AA 1\n");

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

	err = bt_enable(NULL);
	if (err) {
		printk("Bluetooth init failed (err %d)\n", err);
		return 0;
	}

	printk("Bluetooth initialized\n");
 
log:
[2025-01-26 15:42:13.604]# RECV ASCII>
*** Booting My Application v2.8.99-24e6f3802b37 ***
*** Using nRF Connect SDK v2.9.0-nRF54H20-rc1-4df6ce63408b ***
*** Using Zephyr OS v3.7.99-f5efb381b8af ***
Starting Bluetooth Peripheral LBS example
AA:BB:CC:DD:BB:AA 1
E: Only random static identity address supported
Creating new ID failed (err -22)
I: 8 Sectors of 4096 bytes
I: alloc wra: 0, f90
I: data wra: 0, 10
[2025-01-26 15:42:13.727]# RECV ASCII>
I: HW Platform: Nordic Semiconductor (0x0002)
I: HW Variant: nRF54Hx (0x0004)
I: Firmware: Standard Bluetooth controller (0x00) Version 94.16521 Build 3607747417
I: No ID address. App must call settings_load()
Bluetooth initialized
I: Identity: F0:02:69:E2:FA:AD (random)
I: HCI: version 6.0 (0x0e) revision 0x4063, manufacturer 0x0059
I: LMP: version 6.0 (0x0e) subver 0x4063
Advertising successfully started
int main(void)
{
	int blink_status = 0;
	int err;




	printk("Starting Bluetooth Peripheral LBS example\n");

	// err = dk_leds_init();
	// if (err) {
	// 	printk("LEDs init failed (err %d)\n", err);
	// 	return 0;
	// }

	// err = init_button();
	// if (err) {
	// 	printk("Button init failed (err %d)\n", err);
	// 	return 0;
	// }

	if (IS_ENABLED(CONFIG_BT_LBS_SECURITY_ENABLED)) {
		err = bt_conn_auth_cb_register(&conn_auth_callbacks);
		if (err) {
			printk("Failed to register authorization callbacks.\n");
			return 0;
		}

		err = bt_conn_auth_info_cb_register(&conn_auth_info_callbacks);
		if (err) {
			printk("Failed to register authorization info callbacks.\n");
			return 0;
		}
	}


	/* STEP 4.2 - Change the random static address */
    bt_addr_le_t addr;
    err = bt_addr_le_from_str("AA:BB:CC:DD:BB:AA", "random", &addr);
    if (err) {
        printk("Invalid BT address (err %d)\n", err);
    }
	printk("AA:BB:CC:DD:BB:AA test2\n");

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

	// bt_addr_le_t addr={.type=BT_ADDR_LE_PUBLIC
	// 	,.a.val[0]=1,.a.val[1]=2,.a.val[2]=3,.a.val[3]=4,.a.val[4]=5,.a.val[5]=6,
	// };
	// bt_addr_le_create_static(&addr);

	err = bt_enable(NULL);
	if (err) {
		printk("Bluetooth init failed (err %d)\n", err);
		return 0;
	}



	printk("Bluetooth initialized\n");

	if (IS_ENABLED(CONFIG_SETTINGS)) {
		settings_load();
	}







	// err = bt_lbs_init(&lbs_callbacs);
	// if (err) {
	// 	printk("Failed to init LBS (err:%d)\n", err);
	// 	return 0;
	// }



	err = bt_le_adv_start(adv_param, ad, ARRAY_SIZE(ad),
			      NULL, 0);
	if (err) {
		printk("Advertising failed to start (err %d)\n", err);
		return 0;
	}

	printk("Advertising successfully started\n");



	for (;;) {
		my_lbs_send_sensor_notify();
		//dk_set_led(RUN_STATUS_LED, (++blink_status) % 2);
		k_sleep(K_MSEC(RUN_LED_BLINK_INTERVAL));
	}
}
log:
[*** Booting My Application v2.8.99-24e6f3802b37 ***
*** Using nRF Connect SDK v2.9.0-nRF54H20-rc1-4df6ce63408b ***
*** Using Zephyr OS v3.7.99-f5efb381b8af ***
Starting Bluetooth Peripheral LBS example
AA:BB:CC:DD:BB:AA test2
E: Only random static identity address supported
Creating new ID failed (err -22)
I: 8 Sectors of 4096 bytes
I: alloc wra: 0, fc0
I: data wra: 0, 0
[2025-01-26 16:35:57.019]# RECV ASCII>
I: HW Platform: Nordic Semiconductor (0x0002)
I: HW Variant: nRF54Hx (0x0004)
I: Firmware: Standard Bluetooth controller (0x00) Version 94.16521 Build 3607747417
I: No ID address. App must call settings_load()
Bluetooth initialized
I: Identity: F0:02:69:E2:FA:AD (random)
I: HCI: version 6.0 (0x0e) revision 0x4063, manufacturer 0x0059
I: LMP: version 6.0 (0x0e) subver 0x4063
Advertising successfully started
Related