mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
ble_mesh: stack: Store kr phase after value changed [Zephyr]
This commit is contained in:
parent
3e61d519c1
commit
18cc96d188
@ -2912,17 +2912,25 @@ static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
|||||||
phase == BLE_MESH_KR_PHASE_2) {
|
phase == BLE_MESH_KR_PHASE_2) {
|
||||||
sub->kr_phase = BLE_MESH_KR_PHASE_2;
|
sub->kr_phase = BLE_MESH_KR_PHASE_2;
|
||||||
sub->kr_flag = 1;
|
sub->kr_flag = 1;
|
||||||
|
|
||||||
|
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
||||||
|
BT_DBG("Storing kr phase persistently");
|
||||||
|
bt_mesh_store_subnet(sub);
|
||||||
|
}
|
||||||
|
|
||||||
bt_mesh_net_beacon_update(sub);
|
bt_mesh_net_beacon_update(sub);
|
||||||
} else if ((sub->kr_phase == BLE_MESH_KR_PHASE_1 ||
|
} else if ((sub->kr_phase == BLE_MESH_KR_PHASE_1 ||
|
||||||
sub->kr_phase == BLE_MESH_KR_PHASE_2) &&
|
sub->kr_phase == BLE_MESH_KR_PHASE_2) &&
|
||||||
phase == BLE_MESH_KR_PHASE_3) {
|
phase == BLE_MESH_KR_PHASE_3) {
|
||||||
|
sub->kr_phase = BLE_MESH_KR_NORMAL;
|
||||||
|
sub->kr_flag = 0;
|
||||||
bt_mesh_net_revoke_keys(sub);
|
bt_mesh_net_revoke_keys(sub);
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER) ||
|
if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER) ||
|
||||||
IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) {
|
IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) {
|
||||||
friend_cred_refresh(ctx->net_idx);
|
friend_cred_refresh(ctx->net_idx);
|
||||||
}
|
}
|
||||||
sub->kr_phase = BLE_MESH_KR_NORMAL;
|
|
||||||
sub->kr_flag = 0;
|
|
||||||
bt_mesh_net_beacon_update(sub);
|
bt_mesh_net_beacon_update(sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,6 +501,7 @@ void bt_mesh_net_revoke_keys(struct bt_mesh_subnet *sub)
|
|||||||
BT_DBG("idx 0x%04x", sub->net_idx);
|
BT_DBG("idx 0x%04x", sub->net_idx);
|
||||||
|
|
||||||
memcpy(&sub->keys[0], &sub->keys[1], sizeof(sub->keys[0]));
|
memcpy(&sub->keys[0], &sub->keys[1], sizeof(sub->keys[0]));
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
||||||
BT_DBG("Store updated NetKey persistently");
|
BT_DBG("Store updated NetKey persistently");
|
||||||
bt_mesh_store_subnet(sub);
|
bt_mesh_store_subnet(sub);
|
||||||
@ -515,6 +516,7 @@ void bt_mesh_net_revoke_keys(struct bt_mesh_subnet *sub)
|
|||||||
|
|
||||||
memcpy(&key->keys[0], &key->keys[1], sizeof(key->keys[0]));
|
memcpy(&key->keys[0], &key->keys[1], sizeof(key->keys[0]));
|
||||||
key->updated = false;
|
key->updated = false;
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
||||||
BT_DBG("Store updated AppKey persistently");
|
BT_DBG("Store updated AppKey persistently");
|
||||||
bt_mesh_store_app_key(key);
|
bt_mesh_store_app_key(key);
|
||||||
@ -535,6 +537,12 @@ bool bt_mesh_kr_update(struct bt_mesh_subnet *sub, u8_t new_kr, bool new_key)
|
|||||||
if (sub->kr_phase == BLE_MESH_KR_PHASE_1) {
|
if (sub->kr_phase == BLE_MESH_KR_PHASE_1) {
|
||||||
BT_INFO("Phase 1 -> Phase 2");
|
BT_INFO("Phase 1 -> Phase 2");
|
||||||
sub->kr_phase = BLE_MESH_KR_PHASE_2;
|
sub->kr_phase = BLE_MESH_KR_PHASE_2;
|
||||||
|
|
||||||
|
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
||||||
|
BT_DBG("Storing kr phase persistently");
|
||||||
|
bt_mesh_store_subnet(sub);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -553,12 +561,15 @@ bool bt_mesh_kr_update(struct bt_mesh_subnet *sub, u8_t new_kr, bool new_key)
|
|||||||
*/
|
*/
|
||||||
case BLE_MESH_KR_PHASE_2:
|
case BLE_MESH_KR_PHASE_2:
|
||||||
BT_INFO("KR Phase 0x%02x -> Normal", sub->kr_phase);
|
BT_INFO("KR Phase 0x%02x -> Normal", sub->kr_phase);
|
||||||
|
|
||||||
|
sub->kr_phase = BLE_MESH_KR_NORMAL;
|
||||||
bt_mesh_net_revoke_keys(sub);
|
bt_mesh_net_revoke_keys(sub);
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER) ||
|
if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER) ||
|
||||||
IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) {
|
IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) {
|
||||||
friend_cred_refresh(sub->net_idx);
|
friend_cred_refresh(sub->net_idx);
|
||||||
}
|
}
|
||||||
sub->kr_phase = BLE_MESH_KR_NORMAL;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user