From b9c43cec19809b2fc5b580dfbfbd398b043e7dd3 Mon Sep 17 00:00:00 2001 From: lly Date: Mon, 2 Sep 2019 15:07:20 +0800 Subject: [PATCH] ble_mesh: fix starting iv update when not on primary subnet --- components/bt/esp_ble_mesh/mesh_core/net.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/components/bt/esp_ble_mesh/mesh_core/net.c b/components/bt/esp_ble_mesh/mesh_core/net.c index 4e3cac55c7..667be152ff 100644 --- a/components/bt/esp_ble_mesh/mesh_core/net.c +++ b/components/bt/esp_ble_mesh/mesh_core/net.c @@ -722,6 +722,16 @@ u32_t bt_mesh_next_seq(void) bt_mesh_store_seq(); } + if (!bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_IVU_IN_PROGRESS) && + bt_mesh.seq > IV_UPDATE_SEQ_LIMIT && + bt_mesh_subnet_get(BLE_MESH_KEY_PRIMARY)) { +#if CONFIG_BLE_MESH_NODE + bt_mesh_beacon_ivu_initiator(true); +#endif + bt_mesh_net_iv_update(bt_mesh.iv_index + 1, true); + bt_mesh_net_sec_update(NULL); + } + return seq; } @@ -780,15 +790,6 @@ int bt_mesh_net_resend(struct bt_mesh_subnet *sub, struct net_buf *buf, bt_mesh_adv_send(buf, cb, cb_data); } - if (!bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_IVU_IN_PROGRESS) && - bt_mesh.seq > IV_UPDATE_SEQ_LIMIT) { -#if CONFIG_BLE_MESH_NODE - bt_mesh_beacon_ivu_initiator(true); -#endif - bt_mesh_net_iv_update(bt_mesh.iv_index + 1, true); - bt_mesh_net_sec_update(NULL); - } - return 0; }