mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
ble_mesh: Reset transport info when node is removed
This commit is contained in:
parent
41cef4b1bb
commit
6d61f6667a
@ -21,6 +21,7 @@
|
||||
#include "access.h"
|
||||
#include "settings.h"
|
||||
#include "friend.h"
|
||||
#include "transport.h"
|
||||
#include "mesh_common.h"
|
||||
#include "proxy_client.h"
|
||||
#include "provisioner_prov.h"
|
||||
@ -380,7 +381,6 @@ int bt_mesh_provisioner_provision(const bt_mesh_addr_t *addr, const u8_t uuid[16
|
||||
static int provisioner_remove_node(u16_t index, bool erase)
|
||||
{
|
||||
struct bt_mesh_node *node = NULL;
|
||||
struct bt_mesh_rpl *rpl = NULL;
|
||||
bool is_prov = false;
|
||||
int i;
|
||||
|
||||
@ -398,17 +398,12 @@ static int provisioner_remove_node(u16_t index, bool erase)
|
||||
/* Reset corresponding network cache when reset the node */
|
||||
bt_mesh_msg_cache_clear(node->unicast_addr, node->element_num);
|
||||
|
||||
/* Reset corresponding rpl when removing the node */
|
||||
for (i = 0; i < ARRAY_SIZE(bt_mesh.rpl); i++) {
|
||||
rpl = &bt_mesh.rpl[i];
|
||||
if (rpl->src >= node->unicast_addr &&
|
||||
rpl->src < node->unicast_addr + node->element_num) {
|
||||
memset(rpl, 0, sizeof(struct bt_mesh_rpl));
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
||||
bt_mesh_clear_rpl_single(node->unicast_addr);
|
||||
}
|
||||
}
|
||||
/* Reset corresponding transport info when removing the node */
|
||||
for (i = 0; i < node->element_num; i++) {
|
||||
bt_mesh_rx_reset_single(node->unicast_addr + i);
|
||||
}
|
||||
for (i = 0; i < node->element_num; i++) {
|
||||
bt_mesh_tx_reset_single(node->unicast_addr + i);
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) {
|
||||
|
@ -1584,6 +1584,50 @@ void bt_mesh_tx_reset(void)
|
||||
}
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_PROVISIONER
|
||||
void bt_mesh_rx_reset_single(u16_t src)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(src)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(seg_rx); i++) {
|
||||
struct seg_rx *rx = &seg_rx[i];
|
||||
if (src == rx->src) {
|
||||
seg_rx_reset(rx, true);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(bt_mesh.rpl); i++) {
|
||||
struct bt_mesh_rpl *rpl = &bt_mesh.rpl[i];
|
||||
if (src == rpl->src) {
|
||||
memset(rpl, 0, sizeof(struct bt_mesh_rpl));
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
||||
bt_mesh_clear_rpl_single(src);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bt_mesh_tx_reset_single(u16_t dst)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(dst)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(seg_tx); i++) {
|
||||
struct seg_tx *tx = &seg_tx[i];
|
||||
if (dst == tx->dst) {
|
||||
seg_tx_reset(tx);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_PROVISIONER */
|
||||
|
||||
void bt_mesh_trans_init(void)
|
||||
{
|
||||
int i;
|
||||
|
@ -88,6 +88,8 @@ bool bt_mesh_tx_in_progress(void);
|
||||
|
||||
void bt_mesh_rx_reset(void);
|
||||
void bt_mesh_tx_reset(void);
|
||||
void bt_mesh_rx_reset_single(u16_t src);
|
||||
void bt_mesh_tx_reset_single(u16_t dst);
|
||||
|
||||
int bt_mesh_ctl_send(struct bt_mesh_net_tx *tx, u8_t ctl_op, void *data,
|
||||
size_t data_len, u64_t *seq_auth,
|
||||
|
Loading…
Reference in New Issue
Block a user