diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c index 1b8b897ae2..cf2a3825ff 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c @@ -1573,7 +1573,7 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg) break; case BTC_BLE_MESH_ACT_NODE_RESET: BT_DBG("%s, BTC_BLE_MESH_ACT_NODE_RESET", __func__); - bt_mesh_reset(); + bt_mesh_node_reset(); return; case BTC_BLE_MESH_ACT_SET_OOB_PUB_KEY: act = ESP_BLE_MESH_NODE_PROV_SET_OOB_PUB_KEY_COMP_EVT; diff --git a/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c b/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c index dbd31dd297..56a906debf 100644 --- a/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c +++ b/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c @@ -2746,7 +2746,7 @@ static void node_reset(struct bt_mesh_model *model, } if (IS_ENABLED(CONFIG_BLE_MESH_NODE)) { - bt_mesh_reset(); + bt_mesh_node_reset(); } } diff --git a/components/bt/esp_ble_mesh/mesh_core/include/mesh_main.h b/components/bt/esp_ble_mesh/mesh_core/include/mesh_main.h index eb5cc5533a..f93db25c60 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/mesh_main.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/mesh_main.h @@ -498,7 +498,7 @@ int bt_mesh_deinit(struct bt_mesh_deinit_param *param); * to enable unprovisioned advertising on one or more provisioning bearers. * */ -void bt_mesh_reset(void); +void bt_mesh_node_reset(void); /** @brief Suspend the Mesh network temporarily. * diff --git a/components/bt/esp_ble_mesh/mesh_core/main.c b/components/bt/esp_ble_mesh/mesh_core/main.c index 5ba76744c2..f293a68d32 100644 --- a/components/bt/esp_ble_mesh/mesh_core/main.c +++ b/components/bt/esp_ble_mesh/mesh_core/main.c @@ -93,9 +93,9 @@ int bt_mesh_provision(const u8_t net_key[16], u16_t net_idx, return 0; } -void bt_mesh_reset(void) +void bt_mesh_node_reset(void) { - if (!bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_VALID)) { + if (!bt_mesh_is_provisioned()) { BT_WARN("%s, Not provisioned", __func__); return; } @@ -103,7 +103,7 @@ void bt_mesh_reset(void) bt_mesh.iv_index = 0U; bt_mesh.seq = 0U; - memset(bt_mesh.flags, 0, sizeof(bt_mesh.flags)); + bt_mesh_atomic_clear_bit(bt_mesh.flags, BLE_MESH_VALID); k_delayed_work_cancel(&bt_mesh.ivu_timer); @@ -136,9 +136,12 @@ void bt_mesh_reset(void) bt_mesh_comp_unprovision(); if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) { + bt_mesh_clear_seq(); bt_mesh_clear_role(); } + memset(bt_mesh.flags, 0, sizeof(bt_mesh.flags)); + if (IS_ENABLED(CONFIG_BLE_MESH_PROV)) { bt_mesh_prov_reset(); } diff --git a/components/bt/esp_ble_mesh/mesh_core/settings.c b/components/bt/esp_ble_mesh/mesh_core/settings.c index 3e62f9fb16..09f6dd0550 100644 --- a/components/bt/esp_ble_mesh/mesh_core/settings.c +++ b/components/bt/esp_ble_mesh/mesh_core/settings.c @@ -1438,8 +1438,7 @@ static void schedule_store(int flag) timeout = K_NO_WAIT; } else if (bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_RPL_PENDING) && (!(bt_mesh_atomic_get(bt_mesh.flags) & GENERIC_PENDING_BITS) || - (CONFIG_BLE_MESH_RPL_STORE_TIMEOUT < - CONFIG_BLE_MESH_STORE_TIMEOUT))) { + (CONFIG_BLE_MESH_RPL_STORE_TIMEOUT < CONFIG_BLE_MESH_STORE_TIMEOUT))) { timeout = K_SECONDS(CONFIG_BLE_MESH_RPL_STORE_TIMEOUT); } else { timeout = K_SECONDS(CONFIG_BLE_MESH_STORE_TIMEOUT); @@ -1451,7 +1450,7 @@ static void schedule_store(int flag) return; } - BT_DBG("Waiting %d seconds", timeout / MSEC_PER_SEC); + BT_INFO("Waiting %d seconds", timeout / MSEC_PER_SEC); if (timeout) { k_delayed_work_submit(&pending_store, timeout);