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 2022/08/05 08:33:32 UTC

[mynewt-nimble] 01/02: nimble/ll/css: Fix window offset for 1st connection event

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

commit 0f8cfaa4c2c68f10e7369ac7e733627e74e3fc3c
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Tue Aug 2 16:03:02 2022 +0200

    nimble/ll/css: Fix window offset for 1st connection event
    
    Depending on timing, connection anchor point calculated for current
    period and requested slot might have already passed at the time
    advertising PDU is received and this causes window offset to be
    calculated incorrectly. In such case we just move connection to next
    period and recalculate anchor point again.
---
 nimble/controller/src/ble_ll_sched.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/nimble/controller/src/ble_ll_sched.c b/nimble/controller/src/ble_ll_sched.c
index 036a3518..5456e8e2 100644
--- a/nimble/controller/src/ble_ll_sched.c
+++ b/nimble/controller/src/ble_ll_sched.c
@@ -516,9 +516,17 @@ ble_ll_sched_conn_central_new(struct ble_ll_conn_sm *connsm,
             max_delay = 0;
         }
 
-        ble_ll_sched_css_set_conn_anchor(connsm);
+        /* It's possible that calculated anchor point in current period has
+         * already passed, so just move to next period and recalculate.
+         */
+        connsm->css_period_idx--;
+        do {
+            connsm->css_period_idx++;
+            ble_ll_sched_css_set_conn_anchor(connsm);
+            sch->start_time =
+                    connsm->anchor_point - g_ble_ll_sched_offset_ticks;
+        } while (LL_TMR_LT(sch->start_time, orig_start_time));
 
-        sch->start_time = connsm->anchor_point - g_ble_ll_sched_offset_ticks;
         sch->end_time = connsm->anchor_point;
         sch->remainder = connsm->anchor_point_usecs;