mesh: Fix initialization order during node reset

There were several things broken with the initialization order during
node reset:

- The model->flags should not be touched since the writing to
persistent storage happends through delayed work, and the flags
need to be kept until that.

- The unprovision() function should only be called at the very end of
the reset procedure, since it calls model-specific init functions
which may clear things which the earlier reset routines depend on.
This commit is contained in:
Michał Narajowski
2018-07-09 14:23:15 +02:00
parent 6c9cd2bd66
commit 902a6c5021
3 changed files with 3 additions and 3 deletions
-1
View File
@@ -290,7 +290,6 @@ static void mod_init(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
mod->keys[i] = BT_MESH_KEY_UNUSED;
}
mod->flags = 0;
mod->elem_idx = elem - dev_comp->elem;
if (vnd) {
mod->mod_idx = mod - elem->vnd_models;
+1
View File
@@ -3268,6 +3268,7 @@ int bt_mesh_cfg_srv_init(struct bt_mesh_model *model, bool primary)
k_delayed_work_init(&cfg->hb_pub.timer, hb_publish);
k_delayed_work_add_arg(&cfg->hb_pub.timer, cfg);
cfg->hb_pub.net_idx = BT_MESH_KEY_UNUSED;
cfg->hb_sub.expiry = 0;
cfg->model = model;
+2 -2
View File
@@ -79,8 +79,6 @@ void bt_mesh_reset(void)
return;
}
bt_mesh_comp_unprovision();
bt_mesh.iv_index = 0;
bt_mesh.seq = 0;
bt_mesh.iv_update = 0;
@@ -121,6 +119,8 @@ void bt_mesh_reset(void)
bt_mesh_scan_disable();
bt_mesh_beacon_disable();
bt_mesh_comp_unprovision();
if (IS_ENABLED(CONFIG_BT_MESH_PROV)) {
bt_mesh_prov_reset();
}