BLE Host - SM: correctly report encrypted state. Prior to this change, encryption was always reported as disabled.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/d710074c Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/d710074c Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/d710074c Branch: refs/heads/upf54 Commit: d710074c98d05cdfee2f9959926bd6a980de821f Parents: fecf72a Author: Christopher Collins <ccoll...@apache.org> Authored: Wed Jun 8 08:19:29 2016 +0800 Committer: Christopher Collins <ccoll...@apache.org> Committed: Wed Jun 8 09:36:50 2016 +0800 ---------------------------------------------------------------------- net/nimble/host/src/ble_sm.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d710074c/net/nimble/host/src/ble_sm.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/ble_sm.c b/net/nimble/host/src/ble_sm.c index 0f179d2..1189bb5 100644 --- a/net/nimble/host/src/ble_sm.c +++ b/net/nimble/host/src/ble_sm.c @@ -460,9 +460,15 @@ ble_sm_sec_state(struct ble_sm_proc *proc, { out_sec_state->pair_alg = proc->pair_alg; out_sec_state->enc_enabled = enc_enabled; - out_sec_state->authenticated = - (proc->flags & BLE_SM_PROC_F_AUTHENTICATED) ? 1 : 0; - out_sec_state->bonded = (proc->flags & BLE_SM_PROC_F_BONDED) ? 1 : 0; + + if (enc_enabled) { + out_sec_state->authenticated = + (proc->flags & BLE_SM_PROC_F_AUTHENTICATED) ? 1 : 0; + out_sec_state->bonded = (proc->flags & BLE_SM_PROC_F_BONDED) ? 1 : 0; + } else { + out_sec_state->authenticated = 0; + out_sec_state->bonded = 0; + } } static void @@ -1799,6 +1805,7 @@ ble_sm_key_exch_exec(struct ble_sm_proc *proc, struct ble_sm_result *res, /* The procedure is now complete. */ proc->flags |= BLE_SM_PROC_F_BONDED; proc->state = BLE_SM_PROC_STATE_NONE; + res->enc_state = 1; res->enc_cb = 1; } @@ -1824,6 +1831,7 @@ ble_sm_key_rxed(struct ble_sm_proc *proc, struct ble_sm_result *res) } else { proc->flags |= BLE_SM_PROC_F_BONDED; proc->state = BLE_SM_PROC_STATE_NONE; + res->enc_state = 1; res->enc_cb = 1; } }