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/11 14:48:38 UTC

[mynewt-nimble] 01/07: nimble/ll: Improve extended scanner to report truncated report

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 f10b0487f9a8e7278dad7ab6e8fe897d0ace4270
Author: Ɓukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Thu Jan 10 12:25:19 2019 +0100

    nimble/ll: Improve extended scanner to report truncated report
    
    If Nimble was scheduled for aux packet but it received something else,
    make sure to send report with Truncated status.
---
 nimble/controller/src/ble_ll_scan.c | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index 3748a4d..7c08227 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -2284,6 +2284,10 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
 
     ble_hdr = BLE_MBUF_HDR_PTR(rxpdu);
 
+    /* Get pdu type, pointer to address and address "type"  */
+    rxbuf = rxpdu->om_data;
+    pdu_type = rxbuf[0] & BLE_ADV_PDU_HDR_TYPE_MASK;
+
 #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
     if (scansm->cur_aux_data) {
         ble_hdr->rxinfo.user_data = scansm->cur_aux_data;
@@ -2293,6 +2297,13 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
             ble_hdr->rxinfo.flags |= BLE_MBUF_HDR_F_AUX_INVALID;
             goto scan_rx_isr_exit;
         }
+
+        /* If we were expecting aux/chain and it not arrived,
+         * lets just exit here.
+         */
+        if (pdu_type != BLE_ADV_PDU_TYPE_ADV_EXT_IND) {
+            goto scan_rx_isr_exit;
+        }
     }
 #endif
 
@@ -2304,10 +2315,6 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
         goto scan_rx_isr_exit;
     }
 
-    /* Get pdu type, pointer to address and address "type"  */
-    rxbuf = rxpdu->om_data;
-    pdu_type = rxbuf[0] & BLE_ADV_PDU_HDR_TYPE_MASK;
-
 #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
     if (pdu_type == BLE_ADV_PDU_TYPE_ADV_EXT_IND) {
         if (!scansm->ext_scanning) {
@@ -2783,6 +2790,17 @@ ble_ll_scan_rx_pkt_in(uint8_t ptype, struct os_mbuf *om, struct ble_mbuf_hdr *hd
         goto scan_continue;
     }
 
+#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
+    if (aux_data && ptype != BLE_ADV_PDU_TYPE_ADV_EXT_IND) {
+        /* LL was scheduled for aux but received something different.
+         * Let's just ignore received event and send truncated for
+         * previous report if needed.
+         */
+        evt_possibly_truncated = 1;
+        goto scan_continue;
+    }
+#endif
+
     if ((ptype == BLE_ADV_PDU_TYPE_SCAN_REQ) || (ptype == BLE_ADV_PDU_TYPE_CONNECT_REQ)) {
         goto scan_continue;
     }