You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2020/01/09 13:10:06 UTC

[mynewt-nimble] branch master updated: nimble/ll: Adjust max_skip to include some error margin

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

andk 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 1effd23  nimble/ll: Adjust max_skip to include some error margin
1effd23 is described below

commit 1effd2345b65a0344ed203b827c29d7180d6862c
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Wed Jan 8 22:54:00 2020 +0100

    nimble/ll: Adjust max_skip to include some error margin
    
    If calculated max_skip interval is larger than sync timeout we adjust it
    to be the same as timeout. However, this means we have only single event
    to scan properly or sync will be lost.
    
    To avoid this, let's adjust max_skip by an extra 6 events (the same as
    used when syncing) so we will have at least 6 events to scan before sync
    is lost.
---
 nimble/controller/src/ble_ll_sync.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/nimble/controller/src/ble_ll_sync.c b/nimble/controller/src/ble_ll_sync.c
index 3d1169b..2bae8e2 100644
--- a/nimble/controller/src/ble_ll_sync.c
+++ b/nimble/controller/src/ble_ll_sync.c
@@ -259,6 +259,8 @@ ble_ll_sync_find(const uint8_t *addr, uint8_t addr_type, uint8_t sid)
 static uint16_t
 get_max_skip(uint32_t interval_us, uint32_t timeout_us)
 {
+    uint16_t max_skip;
+
     BLE_LL_ASSERT(interval_us);
     BLE_LL_ASSERT(timeout_us);
 
@@ -266,7 +268,20 @@ get_max_skip(uint32_t interval_us, uint32_t timeout_us)
         return 0;
     }
 
-    return (timeout_us / interval_us) - 1;
+    /*
+     * Calculate max allowed skip to receive something before timeout. We adjust
+     * current skip value to be no more than max_skip-6 so we have at least few
+     * attempts to receive an event (so we don't timeout immediately after just
+     * one missed event).
+     */
+
+    max_skip = (timeout_us / interval_us) - 1;
+
+    if (max_skip < 6) {
+        return 0;
+    }
+
+    return max_skip - 6;
 }
 
 #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PERIODIC_ADV_SYNC_TRANSFER)