Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions subsys/bluetooth/host/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,15 @@ config BT_SETTINGS_CCC_STORE_MAX
Defines the max number of Client Characteristic Configuration (CCC)
that the stack can handle

config BT_SETTINGS_BT_NAME_STORE
bool "Store the BT name as setting"
depends on BT_DEVICE_NAME_DYNAMIC
default y
help
When selected, the name that is set when calling @ref bt_set_name
will be stored persistently and automatically set as BT name at
each boot

endif # BT_SETTINGS

config BT_FILTER_ACCEPT_LIST
Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/host/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -4563,7 +4563,7 @@ int bt_set_name(const char *name)
memcpy(bt_dev.name, name, len);
bt_dev.name[len] = '\0';

if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
if (IS_ENABLED(CONFIG_BT_SETTINGS_BT_NAME_STORE)) {
err = bt_settings_store_name(bt_dev.name, len);
if (err) {
LOG_WRN("Unable to store name");
Expand Down
4 changes: 3 additions & 1 deletion subsys/bluetooth/host/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ static int set_setting(const char *name, size_t len_rd, settings_read_cb read_cb
return 0;
}

#if defined(CONFIG_BT_DEVICE_NAME_DYNAMIC)
#if defined(CONFIG_BT_SETTINGS_BT_NAME_STORE)
if (!strncmp(name, "name", len)) {
len = read_cb(cb_arg, &bt_dev.name, sizeof(bt_dev.name) - 1);
if (len < 0) {
Expand Down Expand Up @@ -414,10 +414,12 @@ int bt_settings_delete_hash(void)
return bt_settings_delete("hash", 0, NULL);
}

#if defined(CONFIG_BT_SETTINGS_BT_NAME_STORE)
int bt_settings_store_name(const void *value, size_t val_len)
{
return bt_settings_store("name", 0, NULL, value, val_len);
}
#endif

int bt_settings_delete_name(void)
{
Expand Down