Skip to content

Commit 46b78bb

Browse files
PavelVPVcarlescufi
authored andcommitted
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 <[email protected]>
1 parent 6dfc9ec commit 46b78bb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

subsys/bluetooth/mesh/main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ void bt_mesh_reset(void)
189189
memset(bt_mesh.flags, 0, sizeof(bt_mesh.flags));
190190
atomic_set_bit(bt_mesh.flags, BT_MESH_INIT);
191191

192+
bt_mesh_scan_disable();
193+
192194
/* If this fails, the work handler will return early on the next
193195
* execution, as the device is not provisioned. If the device is
194196
* reprovisioned, the timer is always restarted.
@@ -231,7 +233,6 @@ void bt_mesh_reset(void)
231233

232234
(void)memset(bt_mesh.dev_key, 0, sizeof(bt_mesh.dev_key));
233235

234-
bt_mesh_scan_disable();
235236
bt_mesh_beacon_disable();
236237

237238
bt_mesh_comp_unprovision();

0 commit comments

Comments
 (0)