mesh: Fix set friend_cred flag incorrectly
Only set friend_cred to true when friendship established and
use friend cred security material decryption successfully.
this is port of 5efe6ff8871b5ed0a68c59a44ef4156b3cfb605e
diff --git a/nimble/host/mesh/src/subnet.c b/nimble/host/mesh/src/subnet.c
index 626cb3c..a750a08 100644
--- a/nimble/host/mesh/src/subnet.c
+++ b/nimble/host/mesh/src/subnet.c
@@ -585,7 +585,6 @@
BT_DBG("");
- rx->friend_cred = 1U;
#if MYNEWT_VAL(BLE_MESH_LOW_POWER)
if (bt_mesh_lpn_established()) {
rx->sub = bt_mesh.lpn.sub;
@@ -597,6 +596,7 @@
if (cb(rx, in, out, &bt_mesh.lpn.cred[j])) {
rx->new_key = (j > 0);
+ rx->friend_cred = 1U;
return true;
}
}
@@ -630,6 +630,7 @@
if (cb(rx, in, out, &frnd->cred[j])) {
rx->new_key = (j > 0);
+ rx->friend_cred = 1U;
return true;
}
}
@@ -649,6 +650,7 @@
if (cb(rx, in, out, &rx->sub->keys[j].msg)) {
rx->new_key = (j > 0);
+ rx->friend_cred = 0U;
return true;
}
}