ble_mesh: stack: Transport rx reset settings update

When reset the rx info of transport layer, the
rpl list will always cleared, and rpl stored
in the nvs will only be erased when erase flag
is true and BLE_MESH_SETTINGS is enabled.
Compared with the previous solution, it should
be more clear.
This commit is contained in:
lly 2020-05-27 09:31:33 +08:00
parent e202225bd1
commit d4651bbb30
8 changed files with 29 additions and 36 deletions

View file

@ -1176,14 +1176,14 @@ typedef union {
/**
* @brief ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT
*/
struct ble_mesh_provisioner_delete_node_with_uuid_comp_data_comp_param {
struct ble_mesh_provisioner_delete_node_with_uuid_comp_param {
int err_code; /*!< Indicate the result of deleting node with uuid by the Provisioner */
uint8_t uuid[16]; /*!< Node device uuid */
} provisioner_delete_node_with_uuid_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT */
/**
* @brief ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT
*/
struct ble_mesh_provisioner_delete_node_with_addr_comp_data_comp_param {
struct ble_mesh_provisioner_delete_node_with_addr_comp_param {
int err_code; /*!< Indicate the result of deleting node with unicast address by the Provisioner */
uint16_t unicast_addr; /*!< Node unicast address */
} provisioner_delete_node_with_addr_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT */

View file

@ -35,6 +35,11 @@ void bt_mesh_model_foreach(void (*func)(struct bt_mesh_model *mod,
{
int i, j;
if (dev_comp == NULL) {
BT_ERR("Invalid device composition");
return;
}
for (i = 0; i < dev_comp->elem_count; i++) {
struct bt_mesh_elem *elem = &dev_comp->elem[i];

View file

@ -218,7 +218,7 @@ static void clear_friendship(bool force, bool disable)
return;
}
bt_mesh_rx_reset();
bt_mesh_rx_reset(true);
k_delayed_work_cancel(&lpn->timer);

View file

@ -107,7 +107,7 @@ void bt_mesh_node_reset(void)
bt_mesh_cfg_reset();
bt_mesh_rx_reset();
bt_mesh_rx_reset(true);
bt_mesh_tx_reset();
if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER)) {

View file

@ -1117,6 +1117,11 @@ int bt_mesh_provisioner_init_prov_info(void)
/* If unicast address of primary element of Provisioner has not been set
* before, then the following initialization procedure will be used.
*/
if (prov == NULL) {
BT_ERR("No provisioning context provided");
return -EINVAL;
}
if (!BLE_MESH_ADDR_IS_UNICAST(prov->prov_unicast_addr) ||
!BLE_MESH_ADDR_IS_UNICAST(prov->prov_start_address)) {
BT_ERR("Invalid address, own 0x%04x, start 0x%04x",

View file

@ -1355,13 +1355,13 @@ int settings_core_commit(void)
#if defined(CONFIG_BLE_MESH_NODE)
if (bt_mesh_is_node()) {
BT_INFO("sub[0].net_idx 0x%03x", bt_mesh.sub[0].net_idx);
if (bt_mesh.sub[0].net_idx == BLE_MESH_KEY_UNUSED) {
/* Nothing to do since we're not yet provisioned */
return 0;
}
BT_INFO("Settings commit, sub[0].net_idx 0x%03x", bt_mesh.sub[0].net_idx);
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) {
bt_mesh_proxy_server_prov_disable(true);
}
@ -1388,7 +1388,7 @@ int settings_core_commit(void)
return 0;
}
BT_INFO("p_sub[0]->net_idx 0x%03x", bt_mesh.p_sub[0]->net_idx);
BT_INFO("Settings commit, p_sub[0]->net_idx 0x%03x", bt_mesh.p_sub[0]->net_idx);
for (i = 0; i < ARRAY_SIZE(bt_mesh.p_sub); i++) {
sub = bt_mesh.p_sub[i];
@ -1405,11 +1405,13 @@ int settings_core_commit(void)
}
#endif /* CONFIG_BLE_MESH_PROVISIONER */
if (bt_mesh.ivu_duration < BLE_MESH_IVU_MIN_HOURS) {
k_delayed_work_submit(&bt_mesh.ivu_timer, BLE_MESH_IVU_TIMEOUT);
}
if (bt_mesh_is_node() || bt_mesh_is_provisioner()) {
if (bt_mesh.ivu_duration < BLE_MESH_IVU_MIN_HOURS) {
k_delayed_work_submit(&bt_mesh.ivu_timer, BLE_MESH_IVU_TIMEOUT);
}
bt_mesh_model_foreach(commit_model, NULL);
bt_mesh_model_foreach(commit_model, NULL);
}
#if defined(CONFIG_BLE_MESH_NODE)
if (bt_mesh_is_node()) {
@ -1602,8 +1604,6 @@ static void clear_rpl(void)
BT_DBG("%s", __func__);
bt_mesh_rpl_clear();
buf = bt_mesh_get_core_settings_item("mesh/rpl");
if (!buf) {
bt_mesh_erase_core_settings("mesh/rpl");

View file

@ -1768,7 +1768,7 @@ int bt_mesh_trans_recv(struct net_buf_simple *buf, struct bt_mesh_net_rx *rx)
return err;
}
void bt_mesh_rx_reset(void)
void bt_mesh_rx_reset(bool erase)
{
int i;
@ -1778,10 +1778,10 @@ void bt_mesh_rx_reset(void)
seg_rx_reset(&seg_rx[i], true);
}
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
(void)memset(bt_mesh.rpl, 0, sizeof(bt_mesh.rpl));
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS) && erase) {
bt_mesh_clear_rpl();
} else {
(void)memset(bt_mesh.rpl, 0, sizeof(bt_mesh.rpl));
}
}
@ -1863,16 +1863,7 @@ void bt_mesh_trans_deinit(bool erase)
{
int i;
for (i = 0; i < ARRAY_SIZE(seg_rx); i++) {
seg_rx_reset(&seg_rx[i], true);
}
if (erase && IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
bt_mesh_clear_rpl();
} else {
bt_mesh_rpl_clear();
}
bt_mesh_rx_reset(erase);
bt_mesh_tx_reset();
for (i = 0; i < ARRAY_SIZE(seg_tx); i++) {
@ -1887,12 +1878,6 @@ void bt_mesh_trans_deinit(bool erase)
bt_mesh_rx_seg_mutex_free();
}
void bt_mesh_rpl_clear(void)
{
BT_DBG("%s", __func__);
(void)memset(bt_mesh.rpl, 0, sizeof(bt_mesh.rpl));
}
void bt_mesh_heartbeat_send(void)
{
struct bt_mesh_cfg_srv *cfg = bt_mesh_cfg_get();

View file

@ -97,7 +97,7 @@ struct bt_mesh_app_key *bt_mesh_app_key_find(u16_t app_idx);
bool bt_mesh_tx_in_progress(void);
void bt_mesh_rx_reset(void);
void bt_mesh_rx_reset(bool erase);
void bt_mesh_tx_reset(void);
void bt_mesh_rx_reset_single(u16_t src);
void bt_mesh_tx_reset_single(u16_t dst);
@ -114,8 +114,6 @@ int bt_mesh_trans_recv(struct net_buf_simple *buf, struct bt_mesh_net_rx *rx);
void bt_mesh_trans_init(void);
void bt_mesh_trans_deinit(bool erase);
void bt_mesh_rpl_clear(void);
void bt_mesh_heartbeat_send(void);
int bt_mesh_app_key_get(const struct bt_mesh_subnet *subnet, u16_t app_idx,