You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/05/17 20:52:02 UTC

[39/50] [abbrv] incubator-mynewt-core git commit: BLE Host - Add bonded flag to SM proc.

BLE Host - Add bonded flag to SM proc.

This is needed so that the host/app/someone can determine if the
persisted client characteristic configuration should be restored upon
receiving an encryption-change HCI event.


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/28327e94
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/28327e94
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/28327e94

Branch: refs/heads/master
Commit: 28327e946faebd02fee3913e175c01df2cbd7bac
Parents: aeb46ab
Author: Christopher Collins <cc...@apache.org>
Authored: Mon May 16 13:06:04 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon May 16 19:47:00 2016 -0700

----------------------------------------------------------------------
 net/nimble/host/include/host/ble_gap.h | 1 +
 net/nimble/host/src/ble_l2cap_sm.c     | 7 +++++++
 2 files changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/28327e94/net/nimble/host/include/host/ble_gap.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_gap.h b/net/nimble/host/include/host/ble_gap.h
index ef9a478..d3fc26d 100644
--- a/net/nimble/host/include/host/ble_gap.h
+++ b/net/nimble/host/include/host/ble_gap.h
@@ -105,6 +105,7 @@ struct ble_gap_sec_state {
     uint8_t pair_alg;
     unsigned enc_enabled:1;
     unsigned authenticated:1;
+    unsigned bonded:1;
 };
 
 struct ble_gap_conn_desc {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/28327e94/net/nimble/host/src/ble_l2cap_sm.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap_sm.c b/net/nimble/host/src/ble_l2cap_sm.c
index a8fe98f..9703519 100644
--- a/net/nimble/host/src/ble_l2cap_sm.c
+++ b/net/nimble/host/src/ble_l2cap_sm.c
@@ -65,6 +65,7 @@
 #define BLE_L2CAP_SM_PROC_F_RX_CONFIRM          0x04
 #define BLE_L2CAP_SM_PROC_F_AUTHENTICATED       0x08
 #define BLE_L2CAP_SM_PROC_F_KEY_EXCHANGE        0x10
+#define BLE_L2CAP_SM_PROC_F_BONDED              0x20
 
 #define BLE_L2CAP_SM_KE_F_ENC_INFO              0x01
 #define BLE_L2CAP_SM_KE_F_MASTER_IDEN           0x02
@@ -393,6 +394,7 @@ ble_l2cap_sm_sec_state(struct ble_l2cap_sm_proc *proc,
     out_sec_state->enc_enabled = enc_enabled;
     out_sec_state->authenticated =
             (proc->flags & BLE_L2CAP_SM_PROC_F_AUTHENTICATED) ? 1 : 0;
+    out_sec_state->bonded = (proc->flags & BLE_L2CAP_SM_PROC_F_BONDED) ? 1 : 0;
 }
 
 static void
@@ -1331,6 +1333,10 @@ ble_l2cap_sm_rx_key_exchange(uint16_t conn_handle, uint8_t op,
         rc = BLE_HS_ENOENT;
     }
 
+    if (rc == 0 && sm_end) {
+        proc->flags |= BLE_L2CAP_SM_PROC_F_BONDED;
+    }
+
     ble_hs_unlock();
 
     /* a successful ending of the link */
@@ -1665,6 +1671,7 @@ ble_l2cap_sm_rx_lt_key_req(struct hci_le_lt_key_req *evt)
         if (proc != NULL) {
             proc->conn_handle = evt->connection_handle;
             proc->state = BLE_L2CAP_SM_PROC_STATE_LTK;
+            proc->flags |= BLE_L2CAP_SM_PROC_F_BONDED;
             ble_l2cap_sm_insert(proc);
         }
     } else if (proc->state == BLE_L2CAP_SM_PROC_STATE_LTK) {