Skip to content

Commit 1a0b00a

Browse files
author
Gang He
committed
[int][opt][zbt] Add support to delete all bluetooth settings
Project: Bluetooth redmine: #5146, REDMINE-id ext-redmine: bug|feat#id [Description in detail] Affected branch: [master] Change-Id: I7367628cd88c974a07969df15c541f7541eedb4a
1 parent 2b770a0 commit 1a0b00a

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

zephyr_bt/settings/src/settings_sifli.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ LOG_MODULE_REGISTER(settings_sifli, LOG_LEVEL_INF);
4646

4747

4848
// Key Name Constants
49+
#define BT_ALL_KEY "bt/all" // Base path for device keys
4950
#define BT_KEYS_BASE_KEY "bt/keys" // Base path for device keys
5051
#define BT_SC_BASE_KEY "bt/sc" // Base path for security configs
5152
#define BT_NAME_KEY "bt/name" // Device name key
@@ -1058,8 +1059,24 @@ static int nvds_csi_save(struct settings_store *cs, const char *name,
10581059
// Handle clear operation (value is NULL and val_len is 0)
10591060
bool clear_operation = (value == NULL && val_len == 0);
10601061

1062+
// Handle bt/all - clear all Bluetooth configurations
1063+
if (strcmp(name, BT_ALL_KEY) == 0)
1064+
{
1065+
if (!clear_operation)
1066+
{
1067+
LOG_ERR("Only clear operation supported for %s", name);
1068+
return -EINVAL;
1069+
}
1070+
LOG_DBG("Clearing all Bluetooth configurations...");
1071+
1072+
// Clear all Bluetooth settings
1073+
memset(&nvds_backend.bt_cache, 0, sizeof(nvds_backend.bt_cache));
1074+
nvds_backend.bundle_dirty = true;
1075+
LOG_DBG("Cleared all Bluetooth configurations");
1076+
r = 0;
1077+
}
10611078
// Handle bt/keys/<addr> entries
1062-
if (strstr(name, BT_KEYS_BASE_KEY) == name)
1079+
else if (strstr(name, BT_KEYS_BASE_KEY) == name)
10631080
{
10641081
bt_addr_le_t addr;
10651082
r = parse_bt_addr_from_key(name, BT_KEYS_BASE_KEY, &addr);

0 commit comments

Comments
 (0)