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/10/25 11:52:40 UTC
[mynewt-nimble] 02/02: nimble/ll/css: Fix scheduling 1st conn 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 36406e05dc73b0386c4d5119e267c4c645df4cb7
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Oct 24 14:20:41 2022 +0200
nimble/ll/css: Fix scheduling 1st conn event
If we try to schedule new connection after reference connection slot,
but before slot for that connection (in the same period), anchor point
will be set too far in the future and thus window offset will be more
than connection interval which is invalid.
This is because reference period idx is advanced after connection event
for reference connection has ended, i.e. stored period idx value is N+1
for each subsequent in N-th period. To schedule connections properly we
should first try to schedule in N-th period, i.e. stored value -1.
---
nimble/controller/src/ble_ll_sched.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/nimble/controller/src/ble_ll_sched.c b/nimble/controller/src/ble_ll_sched.c
index 32900b8e..cf64e82f 100644
--- a/nimble/controller/src/ble_ll_sched.c
+++ b/nimble/controller/src/ble_ll_sched.c
@@ -517,12 +517,22 @@ ble_ll_sched_conn_central_new(struct ble_ll_conn_sm *connsm,
connsm->css_period_idx = 0;
max_delay = connsm->conn_itvl_ticks;
} else {
- connsm->css_period_idx = css->period_anchor_idx;
+ /* Reference connection may be already at next period if it has
+ * slot index lower than our, so we first try schedule one period
+ * earlier since our slot index in that period may not yet have
+ * passed. This avoids scheduling 1st connection event too far in
+ * the future, i.e. more than conn interval.
+ */
+ if (connsm->css_slot_idx > css->period_anchor_slot_idx) {
+ connsm->css_period_idx = css->period_anchor_idx - 1;
+ } else {
+ connsm->css_period_idx = css->period_anchor_idx;
+ }
max_delay = 0;
}
- /* It's possible that calculated anchor point in current period has
- * already passed, so just move to next period and recalculate.
+ /* Calculate anchor point and move to next period if scheduled too
+ * early.
*/
connsm->css_period_idx--;
do {