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/07/29 07:28:23 UTC

[mynewt-nimble] branch master updated: nimble/ll: Fix restarting RX on wfr while scanning

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


The following commit(s) were added to refs/heads/master by this push:
     new 708d3b3  nimble/ll: Fix restarting RX on wfr while scanning
708d3b3 is described below

commit 708d3b30ea290fb616d8901659542e272f6a01ab
Author: Ɓukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Fri Jul 26 10:47:42 2019 +0200

    nimble/ll: Fix restarting RX on wfr while scanning
    
    With this patch we move restarting RX on wfr while scanning to interrupt
    context instead of LL context.
    It is because we want to restart RX as fast as possible while scanning.
    Also previous ble_phy_restart_rx call in LL context during
    interrupts enabled was incorrect.
---
 nimble/controller/src/ble_ll_scan.c | 39 +++++++++++++++++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index 4fcdc62..3e3f0a1 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -1392,7 +1392,6 @@ ble_ll_scan_interrupted_event_cb(struct ble_npl_event *ev)
     }
 
     ble_ll_scan_chk_resume();
-    ble_phy_restart_rx();
 }
 
 /**
@@ -2512,9 +2511,45 @@ void
 ble_ll_scan_wfr_timer_exp(void)
 {
     struct ble_ll_scan_sm *scansm;
+    uint8_t chan;
+    int phy;
+    int rc;
+#if (BLE_LL_BT5_PHY_SUPPORTED == 1)
+    uint8_t phy_mode;
+#endif
 
     scansm = &g_ble_ll_scan_sm;
-    ble_ll_scan_interrupted(scansm);
+    if (scansm->cur_aux_data) {
+        /* We actually care about interrupted scan only for EXT ADV because only
+         * then we might consider to send truncated event to the host.
+         */
+        ble_ll_scan_interrupted(scansm);
+
+        /* Need to disable phy since we are going to move to BLE_LL_STATE_STANDBY
+         * or we will need to change channel to primary one
+         */
+        ble_phy_disable();
+
+        if (ble_ll_scan_window_chk(scansm, os_cputime_get32()) == 1) {
+            /* Outside the window scan */
+            ble_ll_state_set(BLE_LL_STATE_STANDBY);
+            return;
+        }
+
+        ble_ll_get_chan_to_scan(scansm, &chan, &phy);
+#if (BLE_LL_BT5_PHY_SUPPORTED == 1)
+        phy_mode = ble_ll_phy_to_phy_mode(phy, BLE_HCI_LE_PHY_CODED_ANY);
+        ble_phy_mode_set(phy_mode, phy_mode);
+#endif
+        rc = ble_phy_setchan(chan, BLE_ACCESS_ADDR_ADV, BLE_LL_CRCINIT_ADV);
+        BLE_LL_ASSERT(rc == 0);
+    }
+
+    if (scansm->scan_rsp_pending) {
+        ble_ll_scan_req_backoff(scansm, 0);
+    }
+
+    ble_phy_restart_rx();
 }
 
 #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)