Skip to content

Commit 271538c

Browse files
committed
Bluetooth: Classic: add bt local name dynamic
add BR/EDR local name dynamic Signed-off-by: Kai Cheng <[email protected]>
1 parent c5768f4 commit 271538c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

subsys/bluetooth/host/classic/br.c

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

866+
strncpy(bt_dev.name, CONFIG_BT_DEVICE_NAME, CONFIG_BT_DEVICE_NAME_MAX);
867+
866868
/* Set Class of device */
867869
buf = bt_hci_cmd_alloc(K_FOREVER);
868870
if (!buf) {

subsys/bluetooth/host/hci_core.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4752,6 +4752,10 @@ int bt_set_name(const char *name)
47524752
return -ENOMEM;
47534753
}
47544754

4755+
if (len == 0) {
4756+
return -EINVAL;
4757+
}
4758+
47554759
if (!strcmp(bt_dev.name, name)) {
47564760
return 0;
47574761
}
@@ -4766,6 +4770,14 @@ int bt_set_name(const char *name)
47664770
}
47674771
}
47684772

4773+
#if defined(CONFIG_BT_CLASSIC)
4774+
err = bt_br_write_local_name(bt_dev.name);
4775+
if (err) {
4776+
LOG_WRN("Unable to set local name");
4777+
return err;
4778+
}
4779+
#endif
4780+
47694781
return 0;
47704782
#else
47714783
return -ENOMEM;

0 commit comments

Comments
 (0)