From cc19e1da9ba51a6bd00979cc554ac363ee91dabd Mon Sep 17 00:00:00 2001 From: lly Date: Wed, 19 Feb 2020 18:16:16 +0800 Subject: [PATCH] ble_mesh: Provisioner ignores msg from removed node --- components/bt/esp_ble_mesh/mesh_core/net.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/components/bt/esp_ble_mesh/mesh_core/net.c b/components/bt/esp_ble_mesh/mesh_core/net.c index a06d62e5a..778092243 100644 --- a/components/bt/esp_ble_mesh/mesh_core/net.c +++ b/components/bt/esp_ble_mesh/mesh_core/net.c @@ -1394,6 +1394,24 @@ static bool ready_to_recv(void) return false; } +static bool ignore_net_msg(u16_t src, u16_t dst) +{ + if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) && + bt_mesh_is_provisioner_en() && + BLE_MESH_ADDR_IS_UNICAST(dst) && + bt_mesh_elem_find(dst)) { + /* If the destination address of the message is the element + * address of Provisioner, but Provisioner fails to find the + * node in its provisioning database, then this message will + * be ignored. + */ + if (!bt_mesh_provisioner_get_node_with_addr(src)) { + return true; + } + } + return false; +} + void bt_mesh_net_recv(struct net_buf_simple *data, s8_t rssi, enum bt_mesh_net_if net_if) { @@ -1411,6 +1429,10 @@ void bt_mesh_net_recv(struct net_buf_simple *data, s8_t rssi, return; } + if (ignore_net_msg(rx.ctx.addr, rx.ctx.recv_dst)) { + return; + } + /* Save the state so the buffer can later be relayed */ net_buf_simple_save(&buf, &state);