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.
This commit is contained in:
Andrzej Kaczmarek
2022-10-25 13:52:31 +02:00
parent 7022ad2270
commit 36406e05dc
+13 -3
View File
@@ -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 {