-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bluetooth: Host: Add API to clean BT settings
Add a new function `bt_settings_cleanup` that allow users to clean potential leftover present in the Bluetooth settings. The function will look for every settings key under the 'bt/' namespace and remove the one not listed in the `bt_settings_keys` list. The settings that are linked to an ID that no longer exist will also be deleted. Signed-off-by: Théo Battrel <[email protected]>
- Loading branch information
Showing
2 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) 2023 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/** | ||
* @brief This function act as a garbage collector for the Bluetooth settings. | ||
* It will: | ||
* - Remove not used settings key under 'bt/' namespace; | ||
* - Remove possible leftover from unexpected behavior. | ||
* | ||
* The settings are removed directly from the storage, the user need to run @ref | ||
* settings_load (or @ref settings_load_subtree to only load 'bt' namespace) to | ||
* apply the changes. | ||
* | ||
* Example of possible leftover: An identity has been deleted, the corresponding | ||
* address as been removed from 'bt/id' but before removing the corresponding | ||
* key in 'bt/keys', the device has been powered off. Calling | ||
* `bt_settings_cleanup` will ensure that the key is removed. | ||
* | ||
* @warning User must not call this function if they use the 'bt/' namespace to | ||
* store settings. All settings stored under 'bt/' namespace that are not | ||
* defined by the Bluetooth stack will be deleted. | ||
* | ||
* @note This function will ignore Bluetooth Mesh settings ('bt/mesh/' | ||
* namespace). | ||
* | ||
* @return 0 on success, non-zero on failure | ||
*/ | ||
int bt_settings_cleanup(void); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters