zephyr/subsys/bluetooth/mesh/settings.h
Pavel Vasilyev 561a8e4f0e Bluetooth: Mesh: Break up mesh settings
The mesh settings.c module is a giant piece of code responsible for
storing the mesh stack configuration. Such approach makes it difficult
to control the data to be stored, breaks the stack modules'
encapsulation by forcing them to reveal the internal kitchen, which
leads to unpleasant issues such as #19799.

This commit moves the responsibility of storing the configuration
to corresponding modules while keeping control of the moment of storing
the configuration and of starting the stack after the settingss loading
is completed.

This doesn't introduce any abstraction between the mesh settings.c and
other modules as it will add more complexity and overhead than necessary
for the actual task.

Fixes #19850

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2021-01-14 16:38:50 +02:00

43 lines
1.3 KiB
C

/*
* Copyright (c) 2018 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
/* Pending storage actions. */
enum bt_mesh_settings_flag {
BT_MESH_SETTINGS_RPL_PENDING,
BT_MESH_SETTINGS_NET_KEYS_PENDING,
BT_MESH_SETTINGS_APP_KEYS_PENDING,
BT_MESH_SETTINGS_NET_PENDING,
BT_MESH_SETTINGS_IV_PENDING,
BT_MESH_SETTINGS_SEQ_PENDING,
BT_MESH_SETTINGS_HB_PUB_PENDING,
BT_MESH_SETTINGS_CFG_PENDING,
BT_MESH_SETTINGS_MOD_PENDING,
BT_MESH_SETTINGS_VA_PENDING,
BT_MESH_SETTINGS_CDB_PENDING,
BT_MESH_SETTINGS_FLAG_COUNT,
};
#ifdef CONFIG_BT_SETTINGS
#define BT_MESH_SETTINGS_DEFINE(_hname, _subtree, _set) \
SETTINGS_STATIC_HANDLER_DEFINE(bt_mesh_##_hname, "bt/mesh/" _subtree, \
NULL, _set, NULL, NULL)
#else
/* Declaring non static settings handler helps avoid unnecessary ifdefs
* as well as unused function warning. Since the declared handler structure is
* unused, linker will discard it.
*/
#define BT_MESH_SETTINGS_DEFINE(_hname, _subtree, _set)\
const struct settings_handler settings_handler_bt_mesh_ ## _hname = {\
.h_set = _set, \
}
#endif
void bt_mesh_settings_init(void);
void bt_mesh_settings_store_schedule(enum bt_mesh_settings_flag flag);
int bt_mesh_settings_set(settings_read_cb read_cb, void *cb_arg,
void *out, size_t read_len);