This is an automated email from the ASF dual-hosted git repository.

janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit e5acfe06c32b1b5806f890997c3ca7d7f32aad52
Author: Szymon Janc <[email protected]>
AuthorDate: Fri Dec 22 14:10:53 2023 +0100

    nimble/ll: Fix channel map update instant calculation
    
    The instant for channel map update was calculated at the time PDU was
    enqueued in connsm. This caused new map to be always applied at instant
    regardless if PDU was even dequeued for tx, e.g. in case there
    encryption procedure pending. This could result in connection being
    dropped.
    
    Currently we calculate instant when PDU is dequeued to make sure this is
    the next PDU to be sent and thus instant is valid.
---
 nimble/controller/src/ble_ll_ctrl.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/nimble/controller/src/ble_ll_ctrl.c 
b/nimble/controller/src/ble_ll_ctrl.c
index 6c739a3c..6eb883c8 100644
--- a/nimble/controller/src/ble_ll_ctrl.c
+++ b/nimble/controller/src/ble_ll_ctrl.c
@@ -1883,12 +1883,15 @@ ble_ll_ctrl_chanmap_req_make(struct ble_ll_conn_sm 
*connsm, uint8_t *pyld)
     memcpy(pyld, g_ble_ll_data.chan_map, BLE_LL_CHAN_MAP_LEN);
     memcpy(connsm->req_chanmap, pyld, BLE_LL_CHAN_MAP_LEN);
 
+    /* Instant is placed in ble_ll_ctrl_chanmap_req_instant()*/
+}
+
+static void
+ble_ll_ctrl_chanmap_req_instant(struct ble_ll_conn_sm *connsm, uint8_t *pyld)
+{
     /* Place instant into request */
     connsm->chanmap_instant = connsm->event_cntr + connsm->periph_latency + 6 
+ 1;
     put_le16(pyld + BLE_LL_CHAN_MAP_LEN, connsm->chanmap_instant);
-
-    /* Set scheduled flag */
-    connsm->flags.chanmap_update_sched = 1;
 }
 
 /**
@@ -3106,6 +3109,10 @@ ble_ll_ctrl_tx_start(struct ble_ll_conn_sm *connsm, 
struct os_mbuf *txpdu)
         ble_ll_ctrl_conn_update_make_ind_pdu(connsm, ctrdata);
         connsm->flags.conn_update_sched = 1;
         break;
+    case BLE_LL_CTRL_CHANNEL_MAP_REQ:
+        ble_ll_ctrl_chanmap_req_instant(connsm, ctrdata);
+        connsm->flags.chanmap_update_sched = 1;
+        break;
 #if MYNEWT_VAL(BLE_LL_PHY)
     case BLE_LL_CTRL_PHY_UPDATE_IND:
         if (ble_ll_ctrl_phy_update_ind_instant(connsm, ctrdata)) {

Reply via email to