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/06/08 01:37:07 UTC

[1/4] incubator-mynewt-core git commit: BLE Host - include both addresses in conn desc.

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/upf54 0ff1ef165 -> dc76ec57e


BLE Host - include both addresses in conn desc.

Previous to this change, the connection descriptor returned by the GAP
only contained the peer identity address.  Now it contains both the
peer's effective address and identity address, as well as the local
effective address.


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

Branch: refs/heads/upf54
Commit: fecf72ad3454e0b82d4fcf0153ad38c47d260f74
Parents: 0ff1ef1
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Jun 8 08:18:23 2016 +0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Jun 8 09:36:49 2016 +0800

----------------------------------------------------------------------
 apps/bletiny/src/bletiny.h                  |  5 +--
 apps/bletiny/src/cmd.c                      | 21 ++++++---
 apps/bletiny/src/main.c                     | 56 ++++--------------------
 apps/bletiny/src/misc.c                     | 21 +++++++++
 net/nimble/host/include/host/ble_gap.h      |  6 ++-
 net/nimble/host/src/ble_gap.c               | 14 +++++-
 net/nimble/host/src/test/ble_gap_test.c     | 30 ++++++-------
 net/nimble/host/src/test/ble_hs_test_util.c |  2 +
 net/nimble/host/src/test/ble_os_test.c      |  4 +-
 9 files changed, 81 insertions(+), 78 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fecf72ad/apps/bletiny/src/bletiny.h
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/bletiny.h b/apps/bletiny/src/bletiny.h
index 6ca6d77..b66a301 100644
--- a/apps/bletiny/src/bletiny.h
+++ b/apps/bletiny/src/bletiny.h
@@ -36,6 +36,7 @@ struct ble_l2cap_sig_update_params;
 union ble_store_value;
 union ble_store_key;
 struct ble_gap_adv_params;
+struct ble_gap_conn_desc;
 
 typedef int cmd_fn(int argc, char **argv);
 struct cmd_entry {
@@ -73,9 +74,6 @@ SLIST_HEAD(bletiny_svc_list, bletiny_svc);
 
 struct bletiny_conn {
     uint16_t handle;
-    uint8_t addr_type;
-    uint8_t addr[6];
-
     struct bletiny_svc_list svcs;
 };
 
@@ -206,5 +204,6 @@ void print_bytes(uint8_t *bytes, int len);
 int svc_is_empty(struct bletiny_svc *svc);
 uint16_t chr_end_handle(struct bletiny_svc *svc, struct bletiny_chr *chr);
 int chr_is_empty(struct bletiny_svc *svc, struct bletiny_chr *chr);
+void print_conn_desc(struct ble_gap_conn_desc *desc);
 
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fecf72ad/apps/bletiny/src/cmd.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/cmd.c b/apps/bletiny/src/cmd.c
index 9a3fe14..4dbdcc5 100644
--- a/apps/bletiny/src/cmd.c
+++ b/apps/bletiny/src/cmd.c
@@ -945,7 +945,13 @@ cmd_scan(int argc, char **argv)
 static int
 cmd_show_addr(int argc, char **argv)
 {
-    print_addr(g_dev_addr);
+    uint8_t *id_addr;
+    uint8_t id_addr_type;
+
+    id_addr = bls_hs_priv_get_local_identity_addr(&id_addr_type);
+
+    console_printf("id_addr_type=%d id_addr=", id_addr_type);
+    print_addr(id_addr);
     console_printf("\n");
 
     return 0;
@@ -961,9 +967,7 @@ cmd_show_chr(int argc, char **argv)
     for (i = 0; i < bletiny_num_conns; i++) {
         conn = bletiny_conns + i;
 
-        console_printf("CONNECTION: handle=%d addr=", conn->handle);
-        print_addr(conn->addr);
-        console_printf("\n");
+        console_printf("CONNECTION: handle=%d\n", conn->handle);
 
         SLIST_FOREACH(svc, &conn->svcs, next) {
             cmd_print_svc(svc);
@@ -976,15 +980,18 @@ cmd_show_chr(int argc, char **argv)
 static int
 cmd_show_conn(int argc, char **argv)
 {
+    struct ble_gap_conn_desc conn_desc;
     struct bletiny_conn *conn;
+    int rc;
     int i;
 
     for (i = 0; i < bletiny_num_conns; i++) {
         conn = bletiny_conns + i;
 
-        console_printf("handle=%d addr=", conn->handle);
-        print_addr(conn->addr);
-        console_printf(" addr_type=%d\n", conn->addr_type);
+        rc = ble_gap_find_conn(conn->handle, &conn_desc);
+        if (rc == 0) {
+            print_conn_desc(&conn_desc);
+        }
     }
 
     return 0;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fecf72ad/apps/bletiny/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/main.c b/apps/bletiny/src/main.c
index c6c93eb..325135b 100755
--- a/apps/bletiny/src/main.c
+++ b/apps/bletiny/src/main.c
@@ -160,38 +160,6 @@ bletiny_print_error(char *msg, uint16_t conn_handle,
 }
 
 static void
-bletiny_print_mac(uint8_t *mac) {
-    int i;
-    for (i = 5; i >= 0; i--) {
-        console_printf("%s0x%02x", i != 5 ? ":" : "", mac[i]);
-    }
-}
-
-static void
-bletiny_print_conn_desc(struct ble_gap_conn_desc *desc)
-{
-    console_printf("handle=%d peer_addr_type=%d peer_addr=",
-                   desc->conn_handle, desc->peer_addr_type);
-    bletiny_print_mac(desc->peer_addr);
-    console_printf(" conn_itvl=%d conn_latency=%d supervision_timeout=%d "
-                   "pair_alg=%d enc_enabled=%d authenticated=%d",
-                   desc->conn_itvl, desc->conn_latency,
-                   desc->supervision_timeout,
-                   desc->sec_state.pair_alg,
-                   desc->sec_state.enc_enabled,
-                   desc->sec_state.authenticated);
-}
-
-static void
-bletiny_print_enh_conn_info(struct ble_gap_enhanced_conn *penh)
-{
-    console_printf(" local_rpa ");
-    bletiny_print_mac(penh->local_rpa);
-    console_printf(" peer_rpa ");
-    bletiny_print_mac(penh->peer_rpa);
-}
-
-static void
 bletiny_print_adv_fields(struct ble_hs_adv_fields *fields)
 {
     uint32_t u32;
@@ -288,7 +256,7 @@ bletiny_print_adv_fields(struct ble_hs_adv_fields *fields)
 
     if (fields->le_addr != NULL) {
         console_printf("    le_addr=");
-        bletiny_print_mac(fields->le_addr);
+        print_addr(fields->le_addr);
         console_printf("\n");
     }
 
@@ -675,8 +643,6 @@ bletiny_conn_add(struct ble_gap_conn_desc *desc)
     bletiny_num_conns++;
 
     conn->handle = desc->conn_handle;
-    conn->addr_type = desc->peer_addr_type;
-    memcpy(conn->addr, desc->peer_addr, 6);
     SLIST_INIT(&conn->svcs);
 
     return conn;
@@ -925,15 +891,11 @@ bletiny_gap_event(int event, struct ble_gap_conn_ctxt *ctxt, void *arg)
 
     switch (event) {
     case BLE_GAP_EVENT_CONNECT:
+        
         console_printf("connection %s; status=%d ",
                        ctxt->connect.status == 0 ? "established" : "failed",
                        ctxt->connect.status);
-        bletiny_print_conn_desc(ctxt->desc);
-
-        if (ctxt->connect.status  == 0) {
-            bletiny_print_enh_conn_info(ctxt->connect.enhanced_conn);
-        }
-        console_printf("\n");
+        print_conn_desc(ctxt->desc);
 
         if (ctxt->connect.status == 0) {
             bletiny_conn_add(ctxt->desc);
@@ -942,7 +904,7 @@ bletiny_gap_event(int event, struct ble_gap_conn_ctxt *ctxt, void *arg)
 
     case BLE_GAP_EVENT_DISCONNECT:
         console_printf("disconnect; reason=%d ", ctxt->disconnect.reason);
-        bletiny_print_conn_desc(ctxt->desc);
+        print_conn_desc(ctxt->desc);
         console_printf("\n");
 
         conn_idx = bletiny_conn_find_idx(ctxt->desc->conn_handle);
@@ -958,7 +920,7 @@ bletiny_gap_event(int event, struct ble_gap_conn_ctxt *ctxt, void *arg)
     case BLE_GAP_EVENT_CONN_UPDATE:
         console_printf("connection updated; status=%d ",
                        ctxt->conn_update.status);
-        bletiny_print_conn_desc(ctxt->desc);
+        print_conn_desc(ctxt->desc);
         console_printf("\n");
         return 0;
 
@@ -981,7 +943,7 @@ bletiny_gap_event(int event, struct ble_gap_conn_ctxt *ctxt, void *arg)
     case BLE_GAP_EVENT_ENC_CHANGE:
         console_printf("encryption change event; status=%d ",
                        ctxt->enc_change.status);
-        bletiny_print_conn_desc(ctxt->desc);
+        print_conn_desc(ctxt->desc);
         console_printf("\n");
         return 0;
 
@@ -1013,7 +975,7 @@ bletiny_on_scan(int event, int status, struct ble_gap_disc_desc *desc,
     case BLE_GAP_EVENT_DISC_SUCCESS:
         console_printf("received advertisement; event_type=%d addr_type=%d "
                        "addr=", desc->event_type, desc->addr_type);
-        bletiny_print_mac(desc->addr);
+        print_addr(desc->addr);
         console_printf(" length_data=%d rssi=%d data=", desc->length_data,
                        desc->rssi);
         print_bytes(desc->data, desc->length_data);
@@ -1429,8 +1391,8 @@ bletiny_sec_restart(uint16_t conn_handle,
         }
 
         memset(&key_sec, 0, sizeof key_sec);
-        key_sec.peer_addr_type = desc.peer_addr_type;
-        memcpy(key_sec.peer_addr, desc.peer_addr, 6);
+        key_sec.peer_addr_type = desc.peer_id_addr_type;
+        memcpy(key_sec.peer_addr, desc.peer_id_addr, 6);
 
         rc = ble_hs_atomic_conn_flags(conn_handle, &conn_flags);
         if (rc != 0) {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fecf72ad/apps/bletiny/src/misc.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/misc.c b/apps/bletiny/src/misc.c
index 179c9a7..a96a388 100644
--- a/apps/bletiny/src/misc.c
+++ b/apps/bletiny/src/misc.c
@@ -19,6 +19,7 @@
 
 #include "console/console.h"
 #include "host/ble_uuid.h"
+#include "host/ble_gap.h"
 
 #include "bletiny.h"
 
@@ -91,3 +92,23 @@ chr_is_empty(struct bletiny_svc *svc, struct bletiny_chr *chr)
 {
     return chr_end_handle(svc, chr) <= chr->chr.val_handle;
 }
+
+void
+print_conn_desc(struct ble_gap_conn_desc *desc)
+{
+    console_printf("handle=%d peer_effective_addr_type=%d "
+                   "peer_effective_addr=",
+                   desc->conn_handle, desc->peer_effective_addr_type);
+    print_addr(desc->peer_effective_addr);
+    console_printf(" peer_identity_addr_type=%d peer_identity_addr=",
+                   desc->peer_id_addr_type);
+    print_addr(desc->peer_id_addr);
+    console_printf(" conn_itvl=%d conn_latency=%d supervision_timeout=%d "
+                   "pair_alg=%d enc_enabled=%d authenticated=%d bonded=%d\n",
+                   desc->conn_itvl, desc->conn_latency,
+                   desc->supervision_timeout,
+                   desc->sec_state.pair_alg,
+                   desc->sec_state.enc_enabled,
+                   desc->sec_state.authenticated,
+                   desc->sec_state.bonded);
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fecf72ad/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 7da00e4..a2ff51c 100644
--- a/net/nimble/host/include/host/ble_gap.h
+++ b/net/nimble/host/include/host/ble_gap.h
@@ -119,12 +119,14 @@ struct ble_gap_adv_params {
 
 struct ble_gap_conn_desc {
     struct ble_gap_sec_state sec_state;
-    uint8_t peer_addr[6];
+    uint8_t peer_effective_addr[6];
+    uint8_t peer_id_addr[6];
     uint16_t conn_handle;
     uint16_t conn_itvl;
     uint16_t conn_latency;
     uint16_t supervision_timeout;
-    uint8_t peer_addr_type;
+    uint8_t peer_effective_addr_type;
+    uint8_t peer_id_addr_type;
 };
 
 struct ble_gap_crt_params {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fecf72ad/net/nimble/host/src/ble_gap.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gap.c b/net/nimble/host/src/ble_gap.c
index 0edc8bc..8b7e632 100644
--- a/net/nimble/host/src/ble_gap.c
+++ b/net/nimble/host/src/ble_gap.c
@@ -273,9 +273,19 @@ static void
 ble_gap_fill_conn_desc(struct ble_hs_conn *conn,
                        struct ble_gap_conn_desc *desc)
 {
+    uint8_t *peer_effective_addr;
+    uint8_t *peer_id_addr;
+    uint8_t *our_effective_addr;
+
+    ble_hs_conn_addrs(conn,
+                      NULL, &our_effective_addr,
+                      NULL, NULL,
+                      &desc->peer_effective_addr_type, &peer_effective_addr,
+                      &desc->peer_id_addr_type, &peer_id_addr);
+
     desc->conn_handle = conn->bhc_handle;
-    desc->peer_addr_type = conn->bhc_addr_type;
-    memcpy(desc->peer_addr, conn->bhc_addr, sizeof desc->peer_addr);
+    memcpy(desc->peer_effective_addr, peer_effective_addr, 6);
+    memcpy(desc->peer_id_addr, peer_id_addr, 6);
     desc->conn_itvl = conn->bhc_itvl;
     desc->conn_latency = conn->bhc_latency;
     desc->supervision_timeout = conn->bhc_supervision_timeout;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fecf72ad/net/nimble/host/src/test/ble_gap_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_gap_test.c b/net/nimble/host/src/test/ble_gap_test.c
index 620c067..7868f2a 100644
--- a/net/nimble/host/src/test/ble_gap_test.c
+++ b/net/nimble/host/src/test/ble_gap_test.c
@@ -706,7 +706,7 @@ TEST_CASE(ble_gap_test_case_conn_dir_good)
 
     TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_CONNECT);
     TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
-    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_addr, peer_addr, 6) == 0);
+    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr, peer_addr, 6) == 0);
 
     TEST_ASSERT(ble_hs_atomic_conn_flags(2, NULL) == 0);
 }
@@ -838,7 +838,7 @@ TEST_CASE(ble_gap_test_case_conn_cancel_ctlr_fail)
 
     TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_CONNECT);
     TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
-    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_addr,
+    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr,
                        peer_addr, 6) == 0);
 
     TEST_ASSERT(ble_hs_atomic_conn_flags(2, NULL) == 0);
@@ -909,8 +909,8 @@ TEST_CASE(ble_gap_test_case_conn_terminate_good)
     TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_DISCONNECT);
     TEST_ASSERT(ble_gap_test_conn_status == BLE_HS_ENOTCONN);
     TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
-    TEST_ASSERT(ble_gap_test_conn_desc.peer_addr_type == BLE_ADDR_TYPE_PUBLIC);
-    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_addr, peer_addr, 6) == 0);
+    TEST_ASSERT(ble_gap_test_conn_desc.peer_id_addr_type == BLE_ADDR_TYPE_PUBLIC);
+    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr, peer_addr, 6) == 0);
     TEST_ASSERT(ble_gap_test_conn_arg == NULL);
 
     TEST_ASSERT(ble_hs_atomic_conn_flags(2, NULL) == BLE_HS_ENOTCONN);
@@ -948,8 +948,8 @@ TEST_CASE(ble_gap_test_case_conn_terminate_ctlr_fail)
     TEST_ASSERT(ble_gap_test_conn_status ==
                 BLE_HS_HCI_ERR(BLE_ERR_UNSUPPORTED));
     TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
-    TEST_ASSERT(ble_gap_test_conn_desc.peer_addr_type == BLE_ADDR_TYPE_PUBLIC);
-    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_addr, peer_addr, 6) == 0);
+    TEST_ASSERT(ble_gap_test_conn_desc.peer_id_addr_type == BLE_ADDR_TYPE_PUBLIC);
+    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr, peer_addr, 6) == 0);
     TEST_ASSERT(ble_gap_test_conn_arg == NULL);
 
     TEST_ASSERT(ble_hs_atomic_conn_flags(2, NULL) == 0);
@@ -1128,7 +1128,7 @@ TEST_CASE(ble_gap_test_case_conn_adv_good)
                             BLE_GAP_EVENT_CONNECT);
                 TEST_ASSERT(ble_gap_test_conn_status == 0);
                 TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
-                TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_addr,
+                TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr,
                                    peer_addr, 6) == 0);
                 TEST_ASSERT(ble_gap_test_conn_arg == NULL);
             }
@@ -1318,7 +1318,7 @@ ble_gap_test_util_update(struct ble_gap_upd_params *params,
     TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_CONN_UPDATE);
     TEST_ASSERT(ble_gap_test_conn_status == 0);
     TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
-    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_addr, peer_addr, 6) == 0);
+    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr, peer_addr, 6) == 0);
     TEST_ASSERT(ble_gap_test_conn_desc.conn_itvl == params->itvl_max);
     TEST_ASSERT(ble_gap_test_conn_desc.conn_latency == params->latency);
     TEST_ASSERT(ble_gap_test_conn_desc.supervision_timeout ==
@@ -1332,7 +1332,7 @@ fail:
     TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_CONN_UPDATE);
     TEST_ASSERT(ble_gap_test_conn_status == status);
     TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
-    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_addr, peer_addr, 6) == 0);
+    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr, peer_addr, 6) == 0);
     TEST_ASSERT(ble_gap_test_conn_desc.conn_itvl ==
                 BLE_GAP_INITIAL_CONN_ITVL_MAX);
     TEST_ASSERT(ble_gap_test_conn_desc.conn_latency ==
@@ -1363,7 +1363,7 @@ ble_gap_test_util_update_peer(uint8_t status,
     TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_CONN_UPDATE);
     TEST_ASSERT(ble_gap_test_conn_status == BLE_HS_HCI_ERR(status));
     TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
-    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_addr,
+    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr,
                        peer_addr, 6) == 0);
 
     if (status == 0) {
@@ -1418,7 +1418,7 @@ ble_gap_test_util_update_req_pos(struct ble_gap_upd_params *peer_params,
     TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_CONN_UPDATE);
     TEST_ASSERT(ble_gap_test_conn_status == 0);
     TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
-    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_addr, peer_addr, 6) == 0);
+    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr, peer_addr, 6) == 0);
     TEST_ASSERT(ble_gap_test_conn_desc.conn_itvl == self_params->itvl_max);
     TEST_ASSERT(ble_gap_test_conn_desc.conn_latency == self_params->latency);
     TEST_ASSERT(ble_gap_test_conn_desc.supervision_timeout ==
@@ -1430,7 +1430,7 @@ hci_fail:
     TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_CONN_UPDATE);
     TEST_ASSERT(ble_gap_test_conn_status == BLE_HS_HCI_ERR(hci_status));
     TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
-    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_addr, peer_addr, 6) == 0);
+    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr, peer_addr, 6) == 0);
     TEST_ASSERT(ble_gap_test_conn_desc.conn_itvl ==
                 BLE_GAP_INITIAL_CONN_ITVL_MAX);
     TEST_ASSERT(ble_gap_test_conn_desc.conn_latency ==
@@ -1479,7 +1479,7 @@ hci_fail:
     TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_CONN_UPDATE);
     TEST_ASSERT(ble_gap_test_conn_status == BLE_HS_HCI_ERR(hci_status));
     TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
-    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_addr, peer_addr, 6) == 0);
+    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr, peer_addr, 6) == 0);
     TEST_ASSERT(ble_gap_test_conn_desc.conn_itvl ==
                 BLE_GAP_INITIAL_CONN_ITVL_MAX);
     TEST_ASSERT(ble_gap_test_conn_desc.conn_latency ==
@@ -1554,7 +1554,7 @@ ble_gap_test_util_update_req_concurrent(
     TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_CONN_UPDATE);
     TEST_ASSERT(ble_gap_test_conn_status == 0);
     TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
-    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_addr, peer_addr, 6) == 0);
+    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr, peer_addr, 6) == 0);
     TEST_ASSERT(ble_gap_test_conn_desc.conn_itvl == self_params->itvl_max);
     TEST_ASSERT(ble_gap_test_conn_desc.conn_latency == self_params->latency);
     TEST_ASSERT(ble_gap_test_conn_desc.supervision_timeout ==
@@ -1566,7 +1566,7 @@ hci_fail:
     TEST_ASSERT(ble_gap_test_conn_event == BLE_GAP_EVENT_CONN_UPDATE);
     TEST_ASSERT(ble_gap_test_conn_status == BLE_HS_HCI_ERR(fail_status));
     TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
-    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_addr, peer_addr, 6) == 0);
+    TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr, peer_addr, 6) == 0);
     TEST_ASSERT(ble_gap_test_conn_desc.conn_itvl ==
                 BLE_GAP_INITIAL_CONN_ITVL_MAX);
     TEST_ASSERT(ble_gap_test_conn_desc.conn_latency ==

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fecf72ad/net/nimble/host/src/test/ble_hs_test_util.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_hs_test_util.c b/net/nimble/host/src/test/ble_hs_test_util.c
index bb7ea89..5a8cac1 100644
--- a/net/nimble/host/src/test/ble_hs_test_util.c
+++ b/net/nimble/host/src/test/ble_hs_test_util.c
@@ -819,4 +819,6 @@ ble_hs_test_util_init(void)
     ble_hs_cfg.max_outstanding_pkts_per_conn = 0;
 
     ble_hs_test_util_prev_hci_tx_clear();
+
+    ble_hs_test_util_set_public_addr(g_dev_addr);
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fecf72ad/net/nimble/host/src/test/ble_os_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_os_test.c b/net/nimble/host/src/test/ble_os_test.c
index 587bd11..ee7ffd6 100644
--- a/net/nimble/host/src/test/ble_os_test.c
+++ b/net/nimble/host/src/test/ble_os_test.c
@@ -108,8 +108,8 @@ ble_gap_direct_connect_test_connect_cb(int event,
     TEST_ASSERT(event == BLE_GAP_EVENT_CONNECT);
     TEST_ASSERT(ctxt->connect.status == 0);
     TEST_ASSERT(ctxt->desc->conn_handle == 2);
-    TEST_ASSERT(ctxt->desc->peer_addr_type == BLE_ADDR_TYPE_PUBLIC);
-    TEST_ASSERT(memcmp(ctxt->desc->peer_addr, ble_os_test_peer_addr, 6) == 0);
+    TEST_ASSERT(ctxt->desc->peer_id_addr_type == BLE_ADDR_TYPE_PUBLIC);
+    TEST_ASSERT(memcmp(ctxt->desc->peer_id_addr, ble_os_test_peer_addr, 6) == 0);
 
     return 0;
 }


[2/4] incubator-mynewt-core git commit: BLE Host - SM: correctly report encrypted state.

Posted by cc...@apache.org.
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 <cc...@apache.org>
Authored: Wed Jun 8 08:19:29 2016 +0800
Committer: Christopher Collins <cc...@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;
         }
     }


[3/4] incubator-mynewt-core git commit: BLE Host - Fix wrong peer addr type in ltk req rx.

Posted by cc...@apache.org.
BLE Host - Fix wrong peer addr type in ltk req rx.


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

Branch: refs/heads/upf54
Commit: dc76ec57efed99900a8513a891e9b7dbd64c9a15
Parents: f935a79
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Jun 8 09:36:27 2016 +0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Jun 8 09:36:50 2016 +0800

----------------------------------------------------------------------
 apps/bletiny/src/misc.c                |  8 +++++---
 net/nimble/host/include/host/ble_gap.h |  2 ++
 net/nimble/host/src/ble_gap.c          |  3 ++-
 net/nimble/host/src/ble_sm.c           | 13 ++++++++++---
 4 files changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dc76ec57/apps/bletiny/src/misc.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/misc.c b/apps/bletiny/src/misc.c
index ecfcd9a..83c28cd 100644
--- a/apps/bletiny/src/misc.c
+++ b/apps/bletiny/src/misc.c
@@ -96,9 +96,11 @@ chr_is_empty(struct bletiny_svc *svc, struct bletiny_chr *chr)
 void
 print_conn_desc(struct ble_gap_conn_desc *desc)
 {
-    console_printf("handle=%d peer_ota_addr_type=%d "
-                   "peer_ota_addr=",
-                   desc->conn_handle, desc->peer_ota_addr_type);
+    console_printf("handle=%d our_ota_addr_type=%d our_ota_addr=",
+                   desc->conn_handle, desc->our_ota_addr_type);
+    print_addr(desc->our_ota_addr);
+    console_printf(" peer_ota_addr_type=%d peer_ota_addr=",
+                   desc->peer_ota_addr_type);
     print_addr(desc->peer_ota_addr);
     console_printf(" peer_id_addr_type=%d peer_id_addr=",
                    desc->peer_id_addr_type);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dc76ec57/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 dce7802..f40c477 100644
--- a/net/nimble/host/include/host/ble_gap.h
+++ b/net/nimble/host/include/host/ble_gap.h
@@ -121,12 +121,14 @@ struct ble_gap_conn_desc {
     struct ble_gap_sec_state sec_state;
     uint8_t peer_ota_addr[6];
     uint8_t peer_id_addr[6];
+    uint8_t our_ota_addr[6];
     uint16_t conn_handle;
     uint16_t conn_itvl;
     uint16_t conn_latency;
     uint16_t supervision_timeout;
     uint8_t peer_ota_addr_type;
     uint8_t peer_id_addr_type;
+    uint8_t our_ota_addr_type;
 };
 
 struct ble_gap_crt_params {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dc76ec57/net/nimble/host/src/ble_gap.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gap.c b/net/nimble/host/src/ble_gap.c
index 879df6c..669a3fc 100644
--- a/net/nimble/host/src/ble_gap.c
+++ b/net/nimble/host/src/ble_gap.c
@@ -278,7 +278,7 @@ ble_gap_fill_conn_desc(struct ble_hs_conn *conn,
     uint8_t *our_ota_addr;
 
     ble_hs_conn_addrs(conn,
-                      NULL, &our_ota_addr,
+                      &desc->our_ota_addr_type, &our_ota_addr,
                       NULL, NULL,
                       &desc->peer_ota_addr_type, &peer_ota_addr,
                       &desc->peer_id_addr_type, &peer_id_addr);
@@ -286,6 +286,7 @@ ble_gap_fill_conn_desc(struct ble_hs_conn *conn,
     desc->conn_handle = conn->bhc_handle;
     memcpy(desc->peer_ota_addr, peer_ota_addr, 6);
     memcpy(desc->peer_id_addr, peer_id_addr, 6);
+    memcpy(desc->our_ota_addr, our_ota_addr, 6);
     desc->conn_itvl = conn->bhc_itvl;
     desc->conn_latency = conn->bhc_latency;
     desc->supervision_timeout = conn->bhc_supervision_timeout;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dc76ec57/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 68c0c0d..3c8f1b3 100644
--- a/net/nimble/host/src/ble_sm.c
+++ b/net/nimble/host/src/ble_sm.c
@@ -1189,6 +1189,7 @@ ble_sm_ltk_req_rx(struct hci_le_lt_key_req *evt)
     int store_rc;
     int bonding;
     uint8_t peer_addr[6];
+    uint8_t *peer_id_addr;
     uint8_t peer_addr_type;
 
     /* Silence gcc warning. */
@@ -1238,8 +1239,10 @@ ble_sm_ltk_req_rx(struct hci_le_lt_key_req *evt)
         if (conn == NULL) {
             res.app_status = BLE_HS_ENOTCONN;
         } else {
-            peer_addr_type = conn->bhc_addr_type;
-            memcpy(peer_addr, conn->bhc_addr, 6);
+            ble_hs_conn_addrs(conn,
+                              NULL, NULL, NULL, NULL,
+                              NULL, NULL, &peer_addr_type, &peer_id_addr);
+            memcpy(peer_addr, peer_id_addr, 6);
         }
     }
 
@@ -1638,6 +1641,7 @@ ble_sm_sec_req_rx(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
     struct ble_store_value_sec value_sec;
     struct ble_store_key_sec key_sec;
     struct ble_hs_conn *conn;
+    uint8_t *peer_id_addr;
     int authreq_mitm;
 
     res->app_status = ble_hs_misc_pullup_base(om, BLE_SM_SEC_REQ_SZ);
@@ -1666,9 +1670,12 @@ ble_sm_sec_req_rx(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
          * sender; remember the sender's address while the connection list is
          * locked.
          */
+        ble_hs_conn_addrs(conn,
+                          NULL, NULL, NULL, NULL,
+                          NULL, NULL, &key_sec.peer_addr_type, &peer_id_addr);
         memset(&key_sec, 0, sizeof key_sec);
         key_sec.peer_addr_type = conn->bhc_addr_type;
-        memcpy(key_sec.peer_addr, conn->bhc_addr, 6);
+        memcpy(key_sec.peer_addr, peer_id_addr, 6);
     }
 
     ble_hs_unlock();


[4/4] incubator-mynewt-core git commit: BLE Host - rename effective->ota; identity->id

Posted by cc...@apache.org.
BLE Host - rename effective->ota; identity->id


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

Branch: refs/heads/upf54
Commit: f935a799ad3f645e421a008bc35a71acd4e4030d
Parents: d710074
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Jun 8 08:45:23 2016 +0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Jun 8 09:36:50 2016 +0800

----------------------------------------------------------------------
 apps/bletiny/src/misc.c                |  10 +--
 net/nimble/host/include/host/ble_gap.h |   4 +-
 net/nimble/host/src/ble_gap.c          |  10 +--
 net/nimble/host/src/ble_hs_conn.c      | 100 ++++++++++++++--------------
 net/nimble/host/src/ble_hs_conn_priv.h |  16 ++---
 net/nimble/host/src/ble_sm.c           |  16 ++---
 net/nimble/host/src/ble_sm_sc.c        |  32 ++++-----
 7 files changed, 94 insertions(+), 94 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f935a799/apps/bletiny/src/misc.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/misc.c b/apps/bletiny/src/misc.c
index a96a388..ecfcd9a 100644
--- a/apps/bletiny/src/misc.c
+++ b/apps/bletiny/src/misc.c
@@ -96,11 +96,11 @@ chr_is_empty(struct bletiny_svc *svc, struct bletiny_chr *chr)
 void
 print_conn_desc(struct ble_gap_conn_desc *desc)
 {
-    console_printf("handle=%d peer_effective_addr_type=%d "
-                   "peer_effective_addr=",
-                   desc->conn_handle, desc->peer_effective_addr_type);
-    print_addr(desc->peer_effective_addr);
-    console_printf(" peer_identity_addr_type=%d peer_identity_addr=",
+    console_printf("handle=%d peer_ota_addr_type=%d "
+                   "peer_ota_addr=",
+                   desc->conn_handle, desc->peer_ota_addr_type);
+    print_addr(desc->peer_ota_addr);
+    console_printf(" peer_id_addr_type=%d peer_id_addr=",
                    desc->peer_id_addr_type);
     print_addr(desc->peer_id_addr);
     console_printf(" conn_itvl=%d conn_latency=%d supervision_timeout=%d "

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f935a799/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 a2ff51c..dce7802 100644
--- a/net/nimble/host/include/host/ble_gap.h
+++ b/net/nimble/host/include/host/ble_gap.h
@@ -119,13 +119,13 @@ struct ble_gap_adv_params {
 
 struct ble_gap_conn_desc {
     struct ble_gap_sec_state sec_state;
-    uint8_t peer_effective_addr[6];
+    uint8_t peer_ota_addr[6];
     uint8_t peer_id_addr[6];
     uint16_t conn_handle;
     uint16_t conn_itvl;
     uint16_t conn_latency;
     uint16_t supervision_timeout;
-    uint8_t peer_effective_addr_type;
+    uint8_t peer_ota_addr_type;
     uint8_t peer_id_addr_type;
 };
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f935a799/net/nimble/host/src/ble_gap.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gap.c b/net/nimble/host/src/ble_gap.c
index 8b7e632..879df6c 100644
--- a/net/nimble/host/src/ble_gap.c
+++ b/net/nimble/host/src/ble_gap.c
@@ -273,18 +273,18 @@ static void
 ble_gap_fill_conn_desc(struct ble_hs_conn *conn,
                        struct ble_gap_conn_desc *desc)
 {
-    uint8_t *peer_effective_addr;
+    uint8_t *peer_ota_addr;
     uint8_t *peer_id_addr;
-    uint8_t *our_effective_addr;
+    uint8_t *our_ota_addr;
 
     ble_hs_conn_addrs(conn,
-                      NULL, &our_effective_addr,
+                      NULL, &our_ota_addr,
                       NULL, NULL,
-                      &desc->peer_effective_addr_type, &peer_effective_addr,
+                      &desc->peer_ota_addr_type, &peer_ota_addr,
                       &desc->peer_id_addr_type, &peer_id_addr);
 
     desc->conn_handle = conn->bhc_handle;
-    memcpy(desc->peer_effective_addr, peer_effective_addr, 6);
+    memcpy(desc->peer_ota_addr, peer_ota_addr, 6);
     memcpy(desc->peer_id_addr, peer_id_addr, 6);
     desc->conn_itvl = conn->bhc_itvl;
     desc->conn_latency = conn->bhc_latency;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f935a799/net/nimble/host/src/ble_hs_conn.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_conn.c b/net/nimble/host/src/ble_hs_conn.c
index 07550ec..967e8b3 100644
--- a/net/nimble/host/src/ble_hs_conn.c
+++ b/net/nimble/host/src/ble_hs_conn.c
@@ -317,70 +317,70 @@ ble_hs_conn_first(void)
 
 void
 ble_hs_conn_addrs(struct ble_hs_conn *conn,
-                  uint8_t *out_our_effective_addr_type,
-                  uint8_t **out_our_effective_addr,
-                  uint8_t *out_our_identity_addr_type,
-                  uint8_t **out_our_identity_addr,
-                  uint8_t *out_peer_effective_addr_type,
-                  uint8_t **out_peer_effective_addr,
-                  uint8_t *out_peer_identity_addr_type,
-                  uint8_t **out_peer_identity_addr)
+                  uint8_t *out_our_ota_addr_type,
+                  uint8_t **out_our_ota_addr,
+                  uint8_t *out_our_id_addr_type,
+                  uint8_t **out_our_id_addr,
+                  uint8_t *out_peer_ota_addr_type,
+                  uint8_t **out_peer_ota_addr,
+                  uint8_t *out_peer_id_addr_type,
+                  uint8_t **out_peer_id_addr)
 {
 
-    uint8_t peer_effective_addr_type;
-    uint8_t peer_identity_addr_type;
-    uint8_t our_effective_addr_type;
-    uint8_t our_identity_addr_type;
-    uint8_t *peer_effective_addr;
-    uint8_t *peer_identity_addr;
-    uint8_t *our_effective_addr;
-    uint8_t *our_identity_addr;
+    uint8_t peer_ota_addr_type;
+    uint8_t peer_id_addr_type;
+    uint8_t our_ota_addr_type;
+    uint8_t our_id_addr_type;
+    uint8_t *peer_ota_addr;
+    uint8_t *peer_id_addr;
+    uint8_t *our_ota_addr;
+    uint8_t *our_id_addr;
 
     /* Determine our address information. */
-    our_identity_addr =
-        bls_hs_priv_get_local_identity_addr(&our_identity_addr_type);
+    our_id_addr =
+        bls_hs_priv_get_local_identity_addr(&our_id_addr_type);
     if (memcmp(conn->our_rpa_addr, ble_hs_conn_null_addr, 6) == 0) {
-        our_effective_addr_type = our_identity_addr_type;
-        our_effective_addr = our_identity_addr;
+        our_ota_addr_type = our_id_addr_type;
+        our_ota_addr = our_id_addr;
     } else {
-        switch (our_identity_addr_type) {
+        switch (our_id_addr_type) {
         case BLE_ADDR_TYPE_PUBLIC:
-            our_effective_addr_type = BLE_ADDR_TYPE_RPA_PUB_DEFAULT;
+            our_ota_addr_type = BLE_ADDR_TYPE_RPA_PUB_DEFAULT;
             break;
 
         case BLE_ADDR_TYPE_RANDOM:
-            our_effective_addr_type = BLE_ADDR_TYPE_RPA_RND_DEFAULT;
+            our_ota_addr_type = BLE_ADDR_TYPE_RPA_RND_DEFAULT;
             break;
 
         default:
             BLE_HS_DBG_ASSERT(0);
         }
 
-        our_effective_addr = conn->our_rpa_addr;
+        our_ota_addr = conn->our_rpa_addr;
     }
 
     /* Determine peer address information. */
-    peer_effective_addr_type = conn->bhc_addr_type;
-    peer_identity_addr = conn->bhc_addr;
+    peer_ota_addr_type = conn->bhc_addr_type;
+    peer_id_addr = conn->bhc_addr;
     switch (conn->bhc_addr_type) {
     case BLE_ADDR_TYPE_PUBLIC:
-        peer_identity_addr_type = BLE_ADDR_TYPE_PUBLIC;
-        peer_effective_addr = conn->bhc_addr;
+        peer_id_addr_type = BLE_ADDR_TYPE_PUBLIC;
+        peer_ota_addr = conn->bhc_addr;
         break;
 
     case BLE_ADDR_TYPE_RANDOM:
-        peer_identity_addr_type = BLE_ADDR_TYPE_RANDOM;
-        peer_effective_addr = conn->bhc_addr;
+        peer_id_addr_type = BLE_ADDR_TYPE_RANDOM;
+        peer_ota_addr = conn->bhc_addr;
         break;
 
     case BLE_ADDR_TYPE_RPA_PUB_DEFAULT:
-        peer_identity_addr_type = BLE_ADDR_TYPE_PUBLIC;
-        peer_effective_addr = conn->peer_rpa_addr;
+        peer_id_addr_type = BLE_ADDR_TYPE_PUBLIC;
+        peer_ota_addr = conn->peer_rpa_addr;
         break;
 
     case BLE_ADDR_TYPE_RPA_RND_DEFAULT:
-        peer_identity_addr_type = BLE_ADDR_TYPE_RANDOM;
-        peer_effective_addr = conn->peer_rpa_addr;
+        peer_id_addr_type = BLE_ADDR_TYPE_RANDOM;
+        peer_ota_addr = conn->peer_rpa_addr;
         break;
 
     default:
@@ -388,29 +388,29 @@ ble_hs_conn_addrs(struct ble_hs_conn *conn,
         break;
     }
 
-    if (out_our_effective_addr_type != NULL) {
-        *out_our_effective_addr_type = our_effective_addr_type;
+    if (out_our_ota_addr_type != NULL) {
+        *out_our_ota_addr_type = our_ota_addr_type;
     }
-    if (out_our_effective_addr != NULL) {
-        *out_our_effective_addr = our_effective_addr;
+    if (out_our_ota_addr != NULL) {
+        *out_our_ota_addr = our_ota_addr;
     }
-    if (out_our_identity_addr_type != NULL) {
-        *out_our_identity_addr_type = our_identity_addr_type;
+    if (out_our_id_addr_type != NULL) {
+        *out_our_id_addr_type = our_id_addr_type;
     }
-    if (out_our_identity_addr != NULL) {
-        *out_our_identity_addr = our_identity_addr;
+    if (out_our_id_addr != NULL) {
+        *out_our_id_addr = our_id_addr;
     }
-    if (out_peer_effective_addr_type != NULL) {
-        *out_peer_effective_addr_type = peer_effective_addr_type;
+    if (out_peer_ota_addr_type != NULL) {
+        *out_peer_ota_addr_type = peer_ota_addr_type;
     }
-    if (out_peer_effective_addr != NULL) {
-        *out_peer_effective_addr = peer_effective_addr;
+    if (out_peer_ota_addr != NULL) {
+        *out_peer_ota_addr = peer_ota_addr;
     }
-    if (out_peer_identity_addr_type != NULL) {
-        *out_peer_identity_addr_type = peer_identity_addr_type;
+    if (out_peer_id_addr_type != NULL) {
+        *out_peer_id_addr_type = peer_id_addr_type;
     }
-    if (out_peer_identity_addr != NULL) {
-        *out_peer_identity_addr = peer_identity_addr;
+    if (out_peer_id_addr != NULL) {
+        *out_peer_id_addr = peer_id_addr;
     }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f935a799/net/nimble/host/src/ble_hs_conn_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_conn_priv.h b/net/nimble/host/src/ble_hs_conn_priv.h
index 1ef4829..e6d940e 100644
--- a/net/nimble/host/src/ble_hs_conn_priv.h
+++ b/net/nimble/host/src/ble_hs_conn_priv.h
@@ -76,14 +76,14 @@ struct ble_l2cap_chan *ble_hs_conn_chan_find(struct ble_hs_conn *conn,
 int ble_hs_conn_chan_insert(struct ble_hs_conn *conn,
                             struct ble_l2cap_chan *chan);
 void ble_hs_conn_addrs(struct ble_hs_conn *conn,
-                       uint8_t *our_effective_addr_type,
-                       uint8_t **our_effective_addr,
-                       uint8_t *our_identity_addr_type,
-                       uint8_t **our_identity_addr,
-                       uint8_t *peer_effective_addr_type,
-                       uint8_t **peer_effective_addr,
-                       uint8_t *peer_identity_addr_type,
-                       uint8_t **peer_identity_addr);
+                       uint8_t *our_ota_addr_type,
+                       uint8_t **our_ota_addr,
+                       uint8_t *our_id_addr_type,
+                       uint8_t **our_id_addr,
+                       uint8_t *peer_ota_addr_type,
+                       uint8_t **peer_ota_addr,
+                       uint8_t *peer_id_addr_type,
+                       uint8_t **peer_id_addr);
 
 int ble_hs_conn_init(void);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f935a799/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 1189bb5..68c0c0d 100644
--- a/net/nimble/host/src/ble_sm.c
+++ b/net/nimble/host/src/ble_sm.c
@@ -527,8 +527,8 @@ ble_sm_ia_ra(struct ble_sm_proc *proc,
              uint8_t *out_rat, uint8_t *out_ra)
 {
     struct ble_hs_conn *conn;
-    uint8_t *peer_effective_addr;
-    uint8_t *our_effective_addr;
+    uint8_t *peer_ota_addr;
+    uint8_t *our_ota_addr;
     uint8_t peer_id_addr_type;
     uint8_t our_id_addr_type;
 
@@ -538,23 +538,23 @@ ble_sm_ia_ra(struct ble_sm_proc *proc,
     }
 
     ble_hs_conn_addrs(conn,
-                      NULL, &our_effective_addr,
+                      NULL, &our_ota_addr,
                       &our_id_addr_type, NULL,
-                      NULL, &peer_effective_addr,
+                      NULL, &peer_ota_addr,
                       &peer_id_addr_type, NULL);
 
     if (proc->flags & BLE_SM_PROC_F_INITIATOR) {
         *out_iat = our_id_addr_type;
-        memcpy(out_ia, our_effective_addr, 6);
+        memcpy(out_ia, our_ota_addr, 6);
 
         *out_rat = peer_id_addr_type;
-        memcpy(out_ra, peer_effective_addr, 6);
+        memcpy(out_ra, peer_ota_addr, 6);
     } else {
         *out_iat = peer_id_addr_type;
-        memcpy(out_ia, peer_effective_addr, 6);
+        memcpy(out_ia, peer_ota_addr, 6);
 
         *out_rat = our_id_addr_type;
-        memcpy(out_ra, our_effective_addr, 6);
+        memcpy(out_ra, our_ota_addr, 6);
     }
 
     return 0;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f935a799/net/nimble/host/src/ble_sm_sc.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_sm_sc.c b/net/nimble/host/src/ble_sm_sc.c
index 5939916..5405eaa 100644
--- a/net/nimble/host/src/ble_sm_sc.c
+++ b/net/nimble/host/src/ble_sm_sc.c
@@ -523,9 +523,9 @@ ble_sm_sc_public_key_rx(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
 static int
 ble_sm_sc_dhkey_addrs(struct ble_sm_proc *proc,
                       uint8_t *out_our_id_addr_type,
-                      uint8_t **out_our_effective_addr,
+                      uint8_t **out_our_ota_addr,
                       uint8_t *out_peer_id_addr_type,
-                      uint8_t **out_peer_effective_addr)
+                      uint8_t **out_peer_ota_addr)
 {
     struct ble_hs_conn *conn;
 
@@ -535,9 +535,9 @@ ble_sm_sc_dhkey_addrs(struct ble_sm_proc *proc,
     }
 
     ble_hs_conn_addrs(conn,
-                      NULL, out_our_effective_addr,
+                      NULL, out_our_ota_addr,
                       out_our_id_addr_type, NULL,
-                      NULL, out_peer_effective_addr,
+                      NULL, out_peer_ota_addr,
                       out_peer_id_addr_type, NULL);
 
     return 0;
@@ -557,8 +557,8 @@ ble_sm_sc_dhkey_check_exec(struct ble_sm_proc *proc, struct ble_sm_result *res,
                            void *arg)
 {
     struct ble_sm_dhkey_check cmd;
-    uint8_t *our_effective_addr;
-    uint8_t *peer_effective_addr;
+    uint8_t *our_ota_addr;
+    uint8_t *peer_ota_addr;
     uint8_t peer_id_addr_type;
     uint8_t our_id_addr_type;
     uint8_t iocap[3];
@@ -571,16 +571,16 @@ ble_sm_sc_dhkey_check_exec(struct ble_sm_proc *proc, struct ble_sm_result *res,
     }
 
     rc = ble_sm_sc_dhkey_addrs(proc,
-                               &our_id_addr_type, &our_effective_addr,
-                               &peer_id_addr_type, &peer_effective_addr);
+                               &our_id_addr_type, &our_ota_addr,
+                               &peer_id_addr_type, &peer_ota_addr);
     if (rc != 0) {
         goto err;
     }
 
     rc = ble_sm_alg_f6(proc->mackey, ble_sm_our_pair_rand(proc),
                        ble_sm_peer_pair_rand(proc), proc->tk, iocap,
-                       our_id_addr_type, our_effective_addr,
-                       peer_id_addr_type, peer_effective_addr,
+                       our_id_addr_type, our_ota_addr,
+                       peer_id_addr_type, peer_ota_addr,
                        cmd.value);
     if (rc != 0) {
         goto err;
@@ -609,8 +609,8 @@ ble_sm_dhkey_check_process(struct ble_sm_proc *proc,
                            struct ble_sm_result *res)
 {
     uint8_t exp_value[16];
-    uint8_t *peer_effective_addr;
-    uint8_t *our_effective_addr;
+    uint8_t *peer_ota_addr;
+    uint8_t *our_ota_addr;
     uint8_t peer_id_addr_type;
     uint8_t our_id_addr_type;
     uint8_t iocap[3];
@@ -624,9 +624,9 @@ ble_sm_dhkey_check_process(struct ble_sm_proc *proc,
 
     res->app_status = ble_sm_sc_dhkey_addrs(proc,
                                             &our_id_addr_type,
-                                            &our_effective_addr,
+                                            &our_ota_addr,
                                             &peer_id_addr_type,
-                                            &peer_effective_addr);
+                                            &peer_ota_addr);
     if (res->app_status != 0) {
         res->sm_err = BLE_SM_ERR_UNSPECIFIED;
         res->enc_cb = 1;
@@ -641,8 +641,8 @@ ble_sm_dhkey_check_process(struct ble_sm_proc *proc,
                                     ble_sm_peer_pair_rand(proc),
                                     ble_sm_our_pair_rand(proc),
                                     proc->tk, iocap,
-                                    peer_id_addr_type, peer_effective_addr,
-                                    our_id_addr_type, our_effective_addr,
+                                    peer_id_addr_type, peer_ota_addr,
+                                    our_id_addr_type, our_ota_addr,
                                     exp_value);
     if (res->app_status != 0) {
         res->sm_err = BLE_SM_ERR_UNSPECIFIED;