You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2021/07/26 11:16:49 UTC

[mynewt-nimble] branch master updated: nimble/ll: Fix scanner assert on receiving AUX_ADV_IND

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 3900772  nimble/ll: Fix scanner assert on receiving AUX_ADV_IND
3900772 is described below

commit 39007724580f80678bb56b22bc657e68f05e3ab6
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Thu Jul 22 14:51:42 2021 +0200

    nimble/ll: Fix scanner assert on receiving AUX_ADV_IND
    
    If scanned chain was truncated due to low buffers for HCI event we may
    be already too late to remove next AUX from scheduler and thus can
    receive next packet. Just ignore PDU if truncated was already sent.
---
 nimble/controller/src/ble_ll_scan.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index 197ec91..164b2ab 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -2606,6 +2606,16 @@ ble_ll_hci_send_ext_adv_report(uint8_t ptype, uint8_t *adva, uint8_t adva_type,
         goto done;
     }
 
+    /* Just ignore PDU if truncated was already sent.
+     * This can happen if next PDU in chain was already received before we
+     * manage to cancel scan on error (which resulted in sending truncated HCI
+     * event)
+     */
+    if (aux_data && (aux_data->flags_ll & BLE_LL_AUX_FLAG_HCI_SENT_TRUNCATED)) {
+        rc = -1;
+        goto done;
+    }
+
     /*
      * We keep one allocated event in aux_data to be able to truncate chain
      * properly in case of error. If there is no event in aux_data it means this
@@ -2646,7 +2656,6 @@ ble_ll_hci_send_ext_adv_report(uint8_t ptype, uint8_t *adva, uint8_t adva_type,
         /* Need to send truncated event if we already sent some reports */
         if (aux_data && (aux_data->flags_ll & BLE_LL_AUX_FLAG_HCI_SENT_ANY)) {
             BLE_LL_ASSERT(!(aux_data->flags_ll & BLE_LL_AUX_FLAG_HCI_SENT_COMPLETED));
-            BLE_LL_ASSERT(!(aux_data->flags_ll & BLE_LL_AUX_FLAG_HCI_SENT_TRUNCATED));
 
             aux_data->flags_ll |= BLE_LL_AUX_FLAG_SCAN_ERROR;
             aux_data->flags_ll |= BLE_LL_AUX_FLAG_HCI_SENT_TRUNCATED;