zephyr/subsys/bluetooth/host/settings.h
François Delawarde 94451b22fc subsys/settings: Allow to register custom backends in settings subsystem
Major changes are:
- Expose settings backend API to enable custom backend support.
- Add a new CONFIG_SETTINGS_CUSTOM backend to allow registering a custom
backend.
- Change api of the handlers h_set() routines to allow for
backend-specific read callbacks.
- Provide a customizable settings_backend_init() routine for custom
backends.
- Move runtime settings support to be its own backend.

Signed-off-by: François Delawarde <fnde@oticon.com>
2019-04-26 11:24:31 +03:00

39 lines
1.2 KiB
C

/*
* Copyright (c) 2018 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
struct bt_settings_handler {
const char *name;
int (*set)(int argc, char **argv, size_t len, settings_read_cb read_cb,
void *cb_arg);
int (*commit)(void);
int (*export)(int (*func)(const char *name, void *val,
size_t val_len));
};
#define BT_SETTINGS_DEFINE(_name, _set, _commit, _export) \
const struct bt_settings_handler _name __aligned(4) \
__in_section(_bt_settings, static, _name) = { \
.name = STRINGIFY(_name), \
.set = _set, \
.commit = _commit, \
.export = _export, \
}
/* Max settings key length (with all components) */
#define BT_SETTINGS_KEY_MAX 36
/* Base64-encoded string buffer size of in_size bytes */
#define BT_SETTINGS_SIZE(in_size) ((((((in_size) - 1) / 3) * 4) + 4) + 1)
/* Helpers for keys containing a bdaddr */
void bt_settings_encode_key(char *path, size_t path_size, const char *subsys,
bt_addr_le_t *addr, const char *key);
int bt_settings_decode_key(char *key, bt_addr_le_t *addr);
void bt_settings_save_id(void);
int bt_settings_init(void);