Bluetooth: Mesh: Stop scanner before resetting mesh
When we receive Node Reset message, we schedule work in the system workqueue to call bt_mesh_reset(). In bt_mesh_reset() we call bt_conn_disconnect() to disconnect proxy client. bt_conn_disconnect() will put a buffer to a pool and call k_sem_take to let BT HCI TX thread process this buffer. Because we stop scanner after disconnecting the proxy, we can still receive a message at this point. Since BT RX thread has higher priority than the system workqueue, if we receive a message while in bt_mesh_reset(), it will be processed when we call bt_conn_disconnect(). Stop scanner before resetting the mesh to avoid processing of a received mesh message while in the process of resetting mesh. Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commit is contained in:
parent
6dfc9ecc03
commit
46b78bb1d5
1 changed files with 2 additions and 1 deletions
|
@ -189,6 +189,8 @@ void bt_mesh_reset(void)
|
||||||
memset(bt_mesh.flags, 0, sizeof(bt_mesh.flags));
|
memset(bt_mesh.flags, 0, sizeof(bt_mesh.flags));
|
||||||
atomic_set_bit(bt_mesh.flags, BT_MESH_INIT);
|
atomic_set_bit(bt_mesh.flags, BT_MESH_INIT);
|
||||||
|
|
||||||
|
bt_mesh_scan_disable();
|
||||||
|
|
||||||
/* If this fails, the work handler will return early on the next
|
/* If this fails, the work handler will return early on the next
|
||||||
* execution, as the device is not provisioned. If the device is
|
* execution, as the device is not provisioned. If the device is
|
||||||
* reprovisioned, the timer is always restarted.
|
* reprovisioned, the timer is always restarted.
|
||||||
|
@ -231,7 +233,6 @@ void bt_mesh_reset(void)
|
||||||
|
|
||||||
(void)memset(bt_mesh.dev_key, 0, sizeof(bt_mesh.dev_key));
|
(void)memset(bt_mesh.dev_key, 0, sizeof(bt_mesh.dev_key));
|
||||||
|
|
||||||
bt_mesh_scan_disable();
|
|
||||||
bt_mesh_beacon_disable();
|
bt_mesh_beacon_disable();
|
||||||
|
|
||||||
bt_mesh_comp_unprovision();
|
bt_mesh_comp_unprovision();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue