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/06/22 13:18:22 UTC
[mynewt-nimble] 02/12: nimble/ll: Fix moving anchor point
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 c194ba130a8f97df193cbdda792a762d2a94fedb
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Thu Jun 9 17:42:50 2022 +0200
nimble/ll: Fix moving anchor point
If there was already a control procedure ongoing, pending conn update
context was not preserved properly so invalid update was done once
procedure was started. Now we keep requested offset in connsm and use it
for new procedure.
Also this is not only for css so update code accordingly.
---
nimble/controller/include/controller/ble_ll_conn.h | 1 +
nimble/controller/src/ble_ll_conn.c | 12 ++----------
nimble/controller/src/ble_ll_ctrl.c | 13 +++++++++++++
3 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/nimble/controller/include/controller/ble_ll_conn.h b/nimble/controller/include/controller/ble_ll_conn.h
index 437d7c25..4215349f 100644
--- a/nimble/controller/include/controller/ble_ll_conn.h
+++ b/nimble/controller/include/controller/ble_ll_conn.h
@@ -377,6 +377,7 @@ struct ble_ll_conn_sm
/* For connection update procedure */
struct ble_ll_conn_upd_req conn_update_req;
+ uint16_t conn_update_anchor_offset_req;
/* XXX: for now, just store them all */
struct ble_ll_conn_params conn_cp;
diff --git a/nimble/controller/src/ble_ll_conn.c b/nimble/controller/src/ble_ll_conn.c
index b6660196..393ae879 100644
--- a/nimble/controller/src/ble_ll_conn.c
+++ b/nimble/controller/src/ble_ll_conn.c
@@ -2185,8 +2185,6 @@ ble_ll_conn_get_anchor(struct ble_ll_conn_sm *connsm, uint16_t conn_event,
int
ble_ll_conn_move_anchor(struct ble_ll_conn_sm *connsm, uint16_t offset)
{
- struct ble_ll_conn_params cp = { };
-
BLE_LL_ASSERT(connsm->conn_role == BLE_LL_CONN_ROLE_CENTRAL);
if (IS_PENDING_CTRL_PROC(connsm, BLE_LL_CTRL_PROC_CONN_PARAM_REQ) ||
@@ -2194,14 +2192,8 @@ ble_ll_conn_move_anchor(struct ble_ll_conn_sm *connsm, uint16_t offset)
return -1;
}
- /* Keep parameters, we just want to move anchor */
- cp.interval_max = connsm->conn_itvl;
- cp.interval_min = connsm->conn_itvl;
- cp.latency = connsm->periph_latency;
- cp.timeout = connsm->supervision_tmo;
- cp.offset0 = offset;
-
- ble_ll_ctrl_proc_start(connsm, BLE_LL_CTRL_PROC_CONN_UPDATE, &cp);
+ connsm->conn_update_anchor_offset_req = offset;
+ ble_ll_ctrl_proc_start(connsm, BLE_LL_CTRL_PROC_CONN_UPDATE, NULL);
return 0;
}
diff --git a/nimble/controller/src/ble_ll_ctrl.c b/nimble/controller/src/ble_ll_ctrl.c
index 7ece7b1c..07f30300 100644
--- a/nimble/controller/src/ble_ll_ctrl.c
+++ b/nimble/controller/src/ble_ll_ctrl.c
@@ -394,6 +394,7 @@ static void
ble_ll_ctrl_conn_upd_make(struct ble_ll_conn_sm *connsm, uint8_t *pyld,
struct ble_ll_conn_params *cp)
{
+ struct ble_ll_conn_params offset_cp = { };
uint16_t instant;
uint32_t dt;
uint32_t num_old_ce;
@@ -416,6 +417,18 @@ ble_ll_ctrl_conn_upd_make(struct ble_ll_conn_sm *connsm, uint8_t *pyld,
instant = connsm->event_cntr + connsm->periph_latency + 6 + 1;
#endif
+ /* Check if this is a move anchor request and configure proper connection
+ * parameters */
+ if (connsm->conn_update_anchor_offset_req) {
+ offset_cp.interval_min = connsm->conn_itvl;
+ offset_cp.interval_max = connsm->conn_itvl;
+ offset_cp.latency = connsm->periph_latency;
+ offset_cp.timeout = connsm->supervision_tmo;
+ offset_cp.offset0 = connsm->conn_update_anchor_offset_req;
+ connsm->conn_update_anchor_offset_req = 0;
+ cp = &offset_cp;
+ }
+
/*
* XXX: This should change in the future, but for now we will just
* start the new instant at the same anchor using win offset 0.