You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/05/14 13:14:57 UTC

[GitHub] sjanc closed pull request #87: nimble/gap: Fix assert on slave connection with ext advertising

sjanc closed pull request #87: nimble/gap: Fix assert on slave connection with ext advertising
URL: https://github.com/apache/mynewt-nimble/pull/87
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c
index 39289a51..3abc4215 100644
--- a/nimble/host/src/ble_gap.c
+++ b/nimble/host/src/ble_gap.c
@@ -152,14 +152,15 @@ struct ble_gap_slave_state {
     unsigned int preempted:1;  /** Set to 1 if advertising was preempted. */
     unsigned int connectable:1;
 
+#if MYNEWT_VAL(BLE_EXT_ADV)
     unsigned int configured:1; /** If instance is configured */
     unsigned int scannable:1;
     unsigned int directed:1;
     unsigned int legacy_pdu:1;
     unsigned int rnd_addr_set:1;
-
+    uint8_t rnd_addr[6];
+#else
 /* timer is used only with legacy advertising */
-#if !MYNEWT_VAL(BLE_EXT_ADV)
     unsigned int exp_set:1;
     ble_npl_time_t exp_os_ticks;
 #endif
@@ -1424,6 +1425,9 @@ ble_gap_rx_conn_complete(struct hci_le_conn_complete *evt, uint8_t instance)
         conn->bhc_cb = ble_gap_slave[instance].cb;
         conn->bhc_cb_arg = ble_gap_slave[instance].cb_arg;
         conn->bhc_our_addr_type = ble_gap_slave[instance].our_addr_type;
+#if MYNEWT_VAL(BLE_EXT_ADV)
+        memcpy(conn->bhc_our_rnd_addr, ble_gap_slave[instance].rnd_addr, 6);
+#endif
         ble_gap_slave_reset_state(instance);
     }
 
@@ -2565,6 +2569,7 @@ ble_gap_ext_adv_set_addr_no_lock(uint8_t instance, const uint8_t *addr)
     }
 
     ble_gap_slave[instance].rnd_addr_set = 1;
+    memcpy(ble_gap_slave[instance].rnd_addr, addr, 6);
 
     return 0;
 }
diff --git a/nimble/host/src/ble_hs_conn.c b/nimble/host/src/ble_hs_conn.c
index afb5439b..00fa4f8c 100644
--- a/nimble/host/src/ble_hs_conn.c
+++ b/nimble/host/src/ble_hs_conn.c
@@ -365,8 +365,23 @@ ble_hs_conn_addrs(const struct ble_hs_conn *conn,
     /* Determine our address information. */
     addrs->our_id_addr.type =
         ble_hs_misc_addr_type_to_id(conn->bhc_our_addr_type);
+
+#if MYNEWT_VAL(BLE_EXT_ADV)
+    /* With EA enabled random address for slave connection is per advertising
+     * instance and requires special handling here.
+     */
+
+    if (!(conn->bhc_flags & BLE_HS_CONN_F_MASTER) &&
+            addrs->our_id_addr.type == BLE_ADDR_RANDOM) {
+        our_id_addr_val = conn->bhc_our_rnd_addr;
+    } else {
+        rc = ble_hs_id_addr(addrs->our_id_addr.type, &our_id_addr_val, NULL);
+        assert(rc == 0);
+    }
+#else
     rc = ble_hs_id_addr(addrs->our_id_addr.type, &our_id_addr_val, NULL);
     assert(rc == 0);
+#endif
 
     memcpy(addrs->our_id_addr.val, our_id_addr_val, 6);
 
diff --git a/nimble/host/src/ble_hs_conn_priv.h b/nimble/host/src/ble_hs_conn_priv.h
index b66b96a5..92aacd40 100644
--- a/nimble/host/src/ble_hs_conn_priv.h
+++ b/nimble/host/src/ble_hs_conn_priv.h
@@ -42,6 +42,9 @@ struct ble_hs_conn {
     SLIST_ENTRY(ble_hs_conn) bhc_next;
     uint16_t bhc_handle;
     uint8_t bhc_our_addr_type;
+#if MYNEWT_VAL(BLE_EXT_ADV)
+    uint8_t bhc_our_rnd_addr[6];
+#endif
     ble_addr_t bhc_peer_addr;
     ble_addr_t bhc_our_rpa_addr;
     ble_addr_t bhc_peer_rpa_addr;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services