You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ry...@apache.org on 2019/01/08 13:11:22 UTC

[mynewt-nimble] branch master updated (bf1ff83 -> f6f2ce4)

This is an automated email from the ASF dual-hosted git repository.

rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git.


    from bf1ff83  mesh: Fix for handling conn_handle == 0
     new 0c37b30  nimble/ll: Remove reduntant comment
     new 4213e93  nimble/ll: Fix extended advertising report event length
     new 8ec1aa0  nimble/ll: Fix legacy extended directed advertising event length
     new b25cbd4  nimble/ll: Improve data packing in extended advertising report
     new 62621ab  nimble/ll: Fix extended scan active for directed advertising
     new f6f2ce4  nimble/ll: Fix InitA type when resolved

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 nimble/controller/src/ble_ll_scan.c | 72 +++++++++++++++++++++++++++----------
 1 file changed, 54 insertions(+), 18 deletions(-)


[mynewt-nimble] 03/06: nimble/ll: Fix legacy extended directed advertising event length

Posted by ry...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 8ec1aa01dfd47350f778c6041214b159210267c9
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Thu Jan 3 12:10:45 2019 +0100

    nimble/ll: Fix legacy extended directed advertising event length
    
    Directed address is already within `struct ble_ll_ext_adv_report' so
    there is no need to increase `evt->event_len`
---
 nimble/controller/src/ble_ll_scan.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index 6498bda..719ee11 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -753,7 +753,6 @@ ble_ll_hci_send_legacy_ext_adv_report(uint8_t evtype,
     if (inita) {
         evt->dir_addr_type = inita_type;
         memcpy(evt->dir_addr, inita, BLE_DEV_ADDR_LEN);
-        evt->event_len += BLE_DEV_ADDR_LEN  + 1;
     } else if (adv_data_len <= (MYNEWT_VAL(BLE_HCI_EVT_BUF_SIZE) - sizeof(*evt))) {
         evt->adv_data_len = adv_data_len;
         os_mbuf_copydata(adv_data, 0, adv_data_len, evt->adv_data);


[mynewt-nimble] 01/06: nimble/ll: Remove reduntant comment

Posted by ry...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 0c37b30ac217ed41a657baf2e60b121197a5aae8
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Thu Jan 3 11:55:53 2019 +0100

    nimble/ll: Remove reduntant comment
    
    This should go away already with following patch:
    
    commit 21f7dc82be5ff535708fcce70acd33ee6a5b2bed
    Author: Łukasz Rymanowski <lu...@codecoup.pl>
    Date:   Tue Oct 9 13:36:21 2018 +0200
    
        nimble/ll: Fix InitA address type in the advertising report
---
 nimble/controller/src/ble_ll_scan.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index 8749304..0a16060 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -751,7 +751,6 @@ ble_ll_hci_send_legacy_ext_adv_report(uint8_t evtype,
     evt->event_len = sizeof(*evt);
 
     if (inita) {
-        /* TODO Really ?? */
         evt->dir_addr_type = inita_type;
         memcpy(evt->dir_addr, inita, BLE_DEV_ADDR_LEN);
         evt->event_len += BLE_DEV_ADDR_LEN  + 1;


[mynewt-nimble] 06/06: nimble/ll: Fix InitA type when resolved

Posted by ry...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit f6f2ce43d244aa86fa602c059f9c0c1e315c0720
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Fri Jan 4 17:08:39 2019 +0100

    nimble/ll: Fix InitA type when resolved
---
 nimble/controller/src/ble_ll_scan.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index ea8134d..ad5f203 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -2770,7 +2770,7 @@ ble_ll_scan_rx_pkt_in(uint8_t ptype, struct os_mbuf *om, struct ble_mbuf_hdr *hd
            /* Let's try resolve InitA. */
            if (ble_ll_resolv_rpa(init_addr, g_ble_ll_resolv_list[index].rl_local_irk)) {
                init_addr = ble_ll_get_our_devaddr(scansm->own_addr_type & 1);
-               init_addr_type = scansm->own_addr_type;
+               init_addr_type = scansm->own_addr_type & 1;
            }
        }
     } else if (init_addr && ble_ll_resolv_enabled() && ble_ll_is_rpa(init_addr, init_addr_type)) {
@@ -2778,7 +2778,7 @@ ble_ll_scan_rx_pkt_in(uint8_t ptype, struct os_mbuf *om, struct ble_mbuf_hdr *hd
         rl = ble_ll_resolv_list_find(ident_addr, ident_addr_type);
         if (rl && ble_ll_resolv_rpa(init_addr, rl->rl_local_irk)) {
             init_addr = ble_ll_get_our_devaddr(scansm->own_addr_type & 1);
-            init_addr_type = scansm->own_addr_type;
+            init_addr_type = scansm->own_addr_type & 1;
         }
     }
 #endif


[mynewt-nimble] 02/06: nimble/ll: Fix extended advertising report event length

Posted by ry...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 4213e93c0c4d76618fce344cc2d7ab85a2f09fa4
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Thu Jan 3 12:00:33 2019 +0100

    nimble/ll: Fix extended advertising report event length
    
    `struct ble_ll_ext_adv_report` contains event meta code and event
    length (HCI event header) which shall not be calculated into event length.
    This patch fixes it.
---
 nimble/controller/src/ble_ll_scan.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index 0a16060..6498bda 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -471,7 +471,7 @@ ble_ll_scan_send_truncated_if_chained(struct ble_ll_aux_data *aux_data)
         }
     }
 
-    evt->event_len = sizeof(*evt);
+    evt->event_len = sizeof(*evt) - BLE_HCI_EVENT_HDR_LEN;
     evt->evt_type = aux_data->evt_type;
     evt->evt_type |= (BLE_HCI_ADV_DATA_STATUS_TRUNCATED);
     BLE_LL_SET_AUX_FLAG(aux_data, BLE_LL_AUX_TRUNCATED_SENT);
@@ -748,7 +748,7 @@ ble_ll_hci_send_legacy_ext_adv_report(uint8_t evtype,
     evt->addr_type = addr_type;
     memcpy(evt->addr, addr, BLE_DEV_ADDR_LEN);
 
-    evt->event_len = sizeof(*evt);
+    evt->event_len = sizeof(*evt) - BLE_HCI_EVENT_HDR_LEN;
 
     if (inita) {
         evt->dir_addr_type = inita_type;


[mynewt-nimble] 05/06: nimble/ll: Fix extended scan active for directed advertising

Posted by ry...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 62621ab54ceef7f812434813c6004b07c8a5ac5d
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Fri Jan 4 17:00:25 2019 +0100

    nimble/ll: Fix extended scan active for directed advertising
    
    In advertising extentions it is possible to have directed scannable
    advertising. This patch makes sure that Nimble sends AUX_SCAN_REQ only
    when directed advertising is for him.
---
 nimble/controller/src/ble_ll_scan.c | 55 ++++++++++++++++++++++++++++++-------
 1 file changed, 45 insertions(+), 10 deletions(-)

diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index 3222531..ea8134d 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -2204,6 +2204,8 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
     uint8_t peer_addr_type = 0;
     uint8_t *adv_addr = NULL;
     uint8_t *peer = NULL;
+    uint8_t *inita = NULL;
+    uint8_t inita_type = 0;
     uint8_t *rxbuf;
     struct ble_mbuf_hdr *ble_hdr;
     struct ble_ll_scan_sm *scansm;
@@ -2213,6 +2215,9 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
     uint8_t phy_mode;
     uint16_t adi;
 #endif
+#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY)
+    struct ble_ll_resolv_entry *rl = NULL;
+#endif
 
     /* Get scanning state machine */
     scansm = &g_ble_ll_scan_sm;
@@ -2288,7 +2293,7 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
     /* Lets get addresses from advertising report*/
     if (ble_ll_scan_adv_decode_addr(pdu_type, rxbuf, ble_hdr,
                                     &peer, &peer_addr_type,
-                                    NULL, NULL, &ext_adv_mode)) {
+                                    &inita, &inita_type, &ext_adv_mode)) {
         goto scan_rx_isr_exit;
     }
 
@@ -2338,19 +2343,41 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
 
     index = -1;
 #if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
-    if (ble_ll_is_rpa(peer, peer_addr_type) && ble_ll_resolv_enabled()) {
-        index = ble_hw_resolv_list_match();
-        if (index >= 0) {
-            ble_hdr->rxinfo.flags |= BLE_MBUF_HDR_F_RESOLVED;
-            peer = g_ble_ll_resolv_list[index].rl_identity_addr;
-            peer_addr_type = g_ble_ll_resolv_list[index].rl_addr_type;
-            resolved = 1;
-        } else {
-            if (chk_wl) {
+    if (ble_ll_resolv_enabled()) {
+        if (ble_ll_is_rpa(peer, peer_addr_type)) {
+            index = ble_hw_resolv_list_match();
+            if (index >= 0) {
+                ble_hdr->rxinfo.flags |= BLE_MBUF_HDR_F_RESOLVED;
+                peer = g_ble_ll_resolv_list[index].rl_identity_addr;
+                peer_addr_type = g_ble_ll_resolv_list[index].rl_addr_type;
+                resolved = 1;
+                if (ble_ll_is_rpa(inita, inita_type) &&
+                    !ble_ll_resolv_rpa(inita, g_ble_ll_resolv_list[index].rl_local_irk)) {
+                    goto scan_rx_isr_exit;
+                }
+            } else {
+                if (chk_wl) {
+                    goto scan_rx_isr_exit;
+                }
+                /* We don't know peer and InitA is RPA so nothing to do more here */
+                if (chk_send_req && inita && ble_ll_is_rpa(inita, inita_type)) {
+                    goto scan_rx_isr_exit;
+                }
+            }
+        } else if (chk_send_req && inita && ble_ll_is_rpa(inita, inita_type)) {
+            /* If remove is identity address but InitA is RPA, make sure we can resolve it.
+             * If not, nothing more to do here
+             */
+            rl = ble_ll_resolv_list_find(peer, peer_addr_type);
+            if (!rl || !ble_ll_resolv_rpa(inita, rl->rl_local_irk)) {
                 goto scan_rx_isr_exit;
             }
         }
     }
+#else
+    if (chk_send_req && inita && ble_ll_is_rpa(inita, inita_type)) {
+        goto scan_rx_isr_exit;
+    }
 #endif
     scansm->scan_rpa_index = index;
 
@@ -2364,6 +2391,14 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
     if (chk_send_req) {
 #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
         if (pdu_type == BLE_ADV_PDU_TYPE_ADV_EXT_IND) {
+            /* Let us check if InitA is our device.
+             * Note that InitA RPA is handled above where privacy is handled
+             */
+            if (inita && !ble_ll_is_rpa(inita, inita_type) &&
+                         !ble_ll_is_our_devaddr(inita, inita_type)) {
+                goto scan_rx_isr_exit;
+            }
+
             if (ble_ll_scan_get_adi(ble_hdr->rxinfo.user_data, &adi) < 0) {
                 /* There is not ADI in scannable packet? This must be some trash,
                  * ignore it


[mynewt-nimble] 04/06: nimble/ll: Improve data packing in extended advertising report

Posted by ry...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit b25cbd4c2eaea611dba715122ed526b7f5238f16
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Thu Jan 3 12:14:03 2019 +0100

    nimble/ll: Improve data packing in extended advertising report
    
    Without this patch, even having buffer of 257 octets for the HCI event, Nimble was
    sending 253 octets of data plus 2 octets of header.
    This patch fixes it.
---
 nimble/controller/src/ble_ll_scan.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index 719ee11..3222531 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -2539,7 +2539,7 @@ ble_ll_hci_send_ext_adv_report(uint8_t ptype, uint8_t *adva, uint8_t adva_type,
     int datalen;
     int rc;
     bool need_event;
-    uint8_t max_event_len;
+    uint16_t max_event_len;
 
     if (!ble_ll_hci_is_le_event_enabled(BLE_HCI_LE_SUBEV_EXT_ADV_RPT)) {
         rc = -1;
@@ -2570,8 +2570,11 @@ ble_ll_hci_send_ext_adv_report(uint8_t ptype, uint8_t *adva, uint8_t adva_type,
         goto done;
     }
 
+    /* Max_event_len contains advertising data and BLE_HCI_EVENT_HDR_LEN as this is related
+     * to the buffer available for the event. The maximum is 255 + 2
+     */
     offset = 0;
-    max_event_len = min(UINT8_MAX, BLE_LL_MAX_EVT_LEN);
+    max_event_len = min(UINT8_MAX + BLE_HCI_EVENT_HDR_LEN, BLE_LL_MAX_EVT_LEN);
 
     do {
         need_event = false;