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>
This commit is contained in:
Pavel Vasilyev 2021-01-06 09:56:56 +01:00 committed by Johan Hedberg
commit 561a8e4f0e
26 changed files with 2375 additions and 2352 deletions

View file

@ -205,7 +205,7 @@ static uint8_t _mod_pub_set(struct bt_mesh_model *model, uint16_t pub_addr,
}
if (IS_ENABLED(CONFIG_BT_SETTINGS) && store) {
bt_mesh_store_mod_pub(model);
bt_mesh_model_pub_store(model);
}
return STATUS_SUCCESS;
@ -247,7 +247,7 @@ static uint8_t _mod_pub_set(struct bt_mesh_model *model, uint16_t pub_addr,
}
if (IS_ENABLED(CONFIG_BT_SETTINGS) && store) {
bt_mesh_store_mod_pub(model);
bt_mesh_model_pub_store(model);
}
return STATUS_SUCCESS;
@ -275,7 +275,7 @@ static uint8_t mod_bind(struct bt_mesh_model *model, uint16_t key_idx)
model->keys[i] = key_idx;
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
bt_mesh_store_mod_bind(model);
bt_mesh_model_bind_store(model);
}
return STATUS_SUCCESS;
@ -303,7 +303,7 @@ static uint8_t mod_unbind(struct bt_mesh_model *model, uint16_t key_idx, bool st
model->keys[i] = BT_MESH_KEY_UNUSED;
if (IS_ENABLED(CONFIG_BT_SETTINGS) && store) {
bt_mesh_store_mod_bind(model);
bt_mesh_model_bind_store(model);
}
if (model->pub && model->pub->key == key_idx) {
@ -1008,7 +1008,7 @@ static void mod_sub_add(struct bt_mesh_model *model,
status = STATUS_SUCCESS;
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
bt_mesh_store_mod_sub(mod);
bt_mesh_model_sub_store(mod);
}
if (IS_ENABLED(CONFIG_BT_MESH_LOW_POWER)) {
@ -1078,7 +1078,7 @@ static void mod_sub_del(struct bt_mesh_model *model,
*match = BT_MESH_ADDR_UNASSIGNED;
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
bt_mesh_store_mod_sub(mod);
bt_mesh_model_sub_store(mod);
}
}
@ -1150,7 +1150,7 @@ static void mod_sub_overwrite(struct bt_mesh_model *model,
status = STATUS_SUCCESS;
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
bt_mesh_store_mod_sub(mod);
bt_mesh_model_sub_store(mod);
}
if (IS_ENABLED(CONFIG_BT_MESH_LOW_POWER)) {
@ -1205,7 +1205,7 @@ static void mod_sub_del_all(struct bt_mesh_model *model,
NULL);
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
bt_mesh_store_mod_sub(mod);
bt_mesh_model_sub_store(mod);
}
status = STATUS_SUCCESS;
@ -1431,7 +1431,7 @@ static void mod_sub_va_add(struct bt_mesh_model *model,
}
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
bt_mesh_store_mod_sub(mod);
bt_mesh_model_sub_store(mod);
}
status = STATUS_SUCCESS;
@ -1496,7 +1496,7 @@ static void mod_sub_va_del(struct bt_mesh_model *model,
*match = BT_MESH_ADDR_UNASSIGNED;
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
bt_mesh_store_mod_sub(mod);
bt_mesh_model_sub_store(mod);
}
status = STATUS_SUCCESS;
@ -1557,7 +1557,7 @@ static void mod_sub_va_overwrite(struct bt_mesh_model *model,
mod->groups[0] = sub_addr;
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
bt_mesh_store_mod_sub(mod);
bt_mesh_model_sub_store(mod);
}
if (IS_ENABLED(CONFIG_BT_MESH_LOW_POWER)) {
@ -2424,7 +2424,7 @@ static void mod_reset(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
if (clear_count) {
bt_mesh_store_mod_sub(mod);
bt_mesh_model_sub_store(mod);
}
}