Skip to content

Commit 45765b6

Browse files
committed
Bluetooth: Classic: add dynamic local name support
Implement dynamic local name update for BR/EDR connections. When CONFIG_BT_DEVICE_NAME_DYNAMIC is enabled, the device name is now properly synchronized between LE and BR/EDR transports. Includes: - Initialize BR/EDR local name with configured device name during init - Update BR/EDR local name when bt_set_name() is called - Maintain consistency between LE and BR/EDR naming Signed-off-by: Kai Cheng <[email protected]>
1 parent c5768f4 commit 45765b6

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

subsys/bluetooth/host/classic/br.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,10 @@ int bt_br_init(void)
863863
return err;
864864
}
865865

866+
#if defined(CONFIG_BT_DEVICE_NAME_DYNAMIC)
867+
strncpy(bt_dev.name, CONFIG_BT_DEVICE_NAME, CONFIG_BT_DEVICE_NAME_MAX);
868+
#endif
869+
866870
/* Set Class of device */
867871
buf = bt_hci_cmd_alloc(K_FOREVER);
868872
if (!buf) {

subsys/bluetooth/host/hci_core.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4766,6 +4766,14 @@ int bt_set_name(const char *name)
47664766
}
47674767
}
47684768

4769+
if (IS_ENABLED(CONFIG_BT_CLASSIC)) {
4770+
err = bt_br_write_local_name(bt_dev.name);
4771+
if (err) {
4772+
LOG_WRN("Unable to set local name");
4773+
return err;
4774+
}
4775+
}
4776+
47694777
return 0;
47704778
#else
47714779
return -ENOMEM;

0 commit comments

Comments
 (0)