Bluetooth: 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. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
f3d1b22487
commit
310320c4d1
3 changed files with 3 additions and 3 deletions
|
@ -280,7 +280,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;
|
||||
|
|
|
@ -3194,6 +3194,7 @@ int bt_mesh_cfg_srv_init(struct bt_mesh_model *model, bool primary)
|
|||
}
|
||||
|
||||
k_delayed_work_init(&cfg->hb_pub.timer, hb_publish);
|
||||
cfg->hb_pub.net_idx = BT_MESH_KEY_UNUSED;
|
||||
cfg->hb_sub.expiry = 0;
|
||||
|
||||
cfg->model = model;
|
||||
|
|
|
@ -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;
|
||||
|
@ -117,6 +115,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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue