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 2019/11/12 08:03:22 UTC

[mynewt-nimble] branch master updated: nimble/ll: Update scan backoff if halted while pending scan response

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 ba70dba  nimble/ll: Update scan backoff if halted while pending scan response
ba70dba is described below

commit ba70dba7c88000c17b8224505d1b795b96d7fd67
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Thu Nov 7 09:19:17 2019 +0100

    nimble/ll: Update scan backoff if halted while pending scan response
    
    Make sure we cleanup scan response pending state.
---
 nimble/controller/include/controller/ble_ll_scan.h |  4 ++--
 nimble/controller/src/ble_ll_scan.c                | 21 ++++++++++++++++-----
 nimble/controller/src/ble_ll_sched.c               |  4 ++--
 3 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/nimble/controller/include/controller/ble_ll_scan.h b/nimble/controller/include/controller/ble_ll_scan.h
index 6298a7e..19011b6 100644
--- a/nimble/controller/include/controller/ble_ll_scan.h
+++ b/nimble/controller/include/controller/ble_ll_scan.h
@@ -272,8 +272,8 @@ void ble_ll_scan_aux_data_unref(struct ble_ll_aux_data *aux_scan);
 void ble_ll_scan_end_adv_evt(struct ble_ll_aux_data *aux_data);
 #endif
 
-/* Called to clean up current aux data */
-void ble_ll_scan_clean_cur_aux_data(void);
+/* Called to halt currently running scan */
+void ble_ll_scan_halt(void);
 
 #ifdef __cplusplus
 }
diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index c9926f9..b44847f 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -505,11 +505,8 @@ ble_ll_scan_end_adv_evt(struct ble_ll_aux_data *aux_data)
     ble_ll_scan_send_truncated(aux_data);
 }
 #endif
-/**
- * Do scan machine clean up on PHY disabled
- *
- */
-void
+
+static void
 ble_ll_scan_clean_cur_aux_data(void)
 {
 #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
@@ -524,6 +521,20 @@ ble_ll_scan_clean_cur_aux_data(void)
 #endif
 }
 
+void
+ble_ll_scan_halt(void)
+{
+    struct ble_ll_scan_sm *scansm = &g_ble_ll_scan_sm;
+
+    ble_ll_scan_clean_cur_aux_data();
+
+    /* Update backoff if we failed to receive scan response */
+    if (scansm->scan_rsp_pending) {
+        scansm->scan_rsp_pending = 0;
+        ble_ll_scan_req_backoff(scansm, 0);
+    }
+}
+
 /**
  * Checks to see if we have received a scan response from this advertiser.
  *
diff --git a/nimble/controller/src/ble_ll_sched.c b/nimble/controller/src/ble_ll_sched.c
index 29742c2..5110298 100644
--- a/nimble/controller/src/ble_ll_sched.c
+++ b/nimble/controller/src/ble_ll_sched.c
@@ -1482,10 +1482,10 @@ ble_ll_sched_execute_item(struct ble_ll_sched_item *sch)
 
     if (lls == BLE_LL_STATE_SCANNING) {
         ble_ll_state_set(BLE_LL_STATE_STANDBY);
-        ble_ll_scan_clean_cur_aux_data();
+        ble_ll_scan_halt();
     } else if (lls == BLE_LL_STATE_INITIATING) {
         ble_ll_state_set(BLE_LL_STATE_STANDBY);
-        ble_ll_scan_clean_cur_aux_data();
+        ble_ll_scan_halt();
         /* PHY is disabled - make sure we do not wait for AUX_CONNECT_RSP */
         ble_ll_conn_reset_pending_aux_conn_rsp();
     } else if (lls == BLE_LL_STATE_ADV) {