Skip to content

Commit

Permalink
Merge branch 'feature/Add_IVI_recovery_option' into 'master'
Browse files Browse the repository at this point in the history
ble_mesh: stack: Add IV index recovery option when device missed the whole IV update

See merge request espressif/esp-idf!20500
  • Loading branch information
Isl2017 committed Oct 14, 2022
2 parents beb8a7c + 50790f8 commit 7ddbaae
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
15 changes: 15 additions & 0 deletions components/bt/esp_ble_mesh/Kconfig.in
Expand Up @@ -585,6 +585,21 @@ if BLE_MESH
stored to flash. E.g. the default value of 4 means that the
state is saved every 24 hours (96 / 4).

config BLE_MESH_IVU_RECOVERY_IVI
bool "Recovery the IV index when the latest whole IV update procedure is missed"
default n
help
According to Section 3.10.5 of Mesh Specification v1.0.1.
If a node in Normal Operation receives a Secure Network beacon with an IV index
equal to the last known IV index+1 and the IV Update Flag set to 0, the node may
update its IV without going to the IV Update in Progress state, or it may initiate
an IV Index Recovery procedure (Section 3.10.6), or it may ignore the Secure
Network beacon. The node makes the choice depending on the time since last IV
update and the likelihood that the node has missed the Secure Network beacons
with the IV update Flag.
When the above situation is encountered, this option can be used to decide whether
to perform the IV index recovery procedure.

config BLE_MESH_TX_SEG_MSG_COUNT
int "Maximum number of simultaneous outgoing segmented messages"
default 1
Expand Down
8 changes: 7 additions & 1 deletion components/bt/esp_ble_mesh/mesh_core/net.c
Expand Up @@ -673,18 +673,24 @@ bool bt_mesh_net_iv_update(uint32_t iv_index, bool iv_update)
return false;
}

if (iv_index > bt_mesh.iv_index + 1) {
if ((iv_index > bt_mesh.iv_index + 1)
#if CONFIG_BLE_MESH_IVU_RECOVERY_IVI
|| (iv_index == bt_mesh.iv_index + 1 && !iv_update)
#endif
) {
BT_WARN("Performing IV Index Recovery");
(void)memset(bt_mesh.rpl, 0, sizeof(bt_mesh.rpl));
bt_mesh.iv_index = iv_index;
bt_mesh.seq = 0U;
goto do_update;
}

#if !CONFIG_BLE_MESH_IVU_RECOVERY_IVI
if (iv_index == bt_mesh.iv_index + 1 && !iv_update) {
BT_WARN("Ignoring new index in normal mode");
return false;
}
#endif

if (!iv_update) {
/* Nothing to do */
Expand Down

0 comments on commit 7ddbaae

Please sign in to comment.