From 1004c30507b2c789e0f6f09bf14b0b70ab3bd88b Mon Sep 17 00:00:00 2001 From: Piotr Pryga Date: Fri, 1 Apr 2022 14:30:06 +0200 Subject: [PATCH] Bluetooth: Controller: Fix CTE req periodically after req is disabled There is an error in the condition that checks if new CTE_REQ should be started after end of connection event. The condition verifies if counter req_expire is set to zero. Then new CTE_REQ is started irrespectively to CTE_REQ being disabled. req_interval is used to store information if the CTE_REQ is: - periodic, then value doesn't equal zero, - single shot or disabled, then value equals zero. The condition should verify if the req_interval is not zero and req_expire is not zero. The second part of the if condition is required to avoid starting next CTE_REQ until last one has been completed. Signed-off-by: Piotr Pryga --- subsys/bluetooth/controller/ll_sw/ull_conn.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/subsys/bluetooth/controller/ll_sw/ull_conn.c b/subsys/bluetooth/controller/ll_sw/ull_conn.c index a1560b0d7f7..f260c71eb5d 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_conn.c +++ b/subsys/bluetooth/controller/ll_sw/ull_conn.c @@ -1652,12 +1652,18 @@ void ull_conn_done(struct node_rx_event_done *done) #endif /* CONFIG_BT_CTLR_LE_PING */ #if defined(CONFIG_BT_CTLR_DF_CONN_CTE_REQ) - if (conn->llcp.cte_req.req_expire != 0U) { + /* Check if the CTE_REQ procedure is periodic and counter has been started. + * req_expire is set when: new CTE_REQ is started, after completion of last periodic run. + */ + if (conn->llcp.cte_req.req_interval != 0U && conn->llcp.cte_req.req_expire != 0U) { if (conn->llcp.cte_req.req_expire > elapsed_event) { conn->llcp.cte_req.req_expire -= elapsed_event; } else { uint8_t err; + /* Set req_expire to zero to mark that new periodic CTE_REQ was started. + * The counter is re-started after completion of this run. + */ conn->llcp.cte_req.req_expire = 0U; err = ull_cp_cte_req(conn, conn->llcp.cte_req.min_cte_len,