You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ry...@apache.org on 2019/01/29 21:50:23 UTC
[mynewt-nimble] branch master updated: nimble/ll: Fix procedure
collision as a slave
This is an automated email from the ASF dual-hosted git repository.
rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
The following commit(s) were added to refs/heads/master by this push:
new 430516d nimble/ll: Fix procedure collision as a slave
430516d is described below
commit 430516d540d773389d46f50ee627924b8ebad7c6
Author: Ćukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Tue Jan 29 19:05:57 2019 +0100
nimble/ll: Fix procedure collision as a slave
This patch fixes following scenarion
1. Nimble as a Slave starts LL procedure "A"
2. Master starts encryption procedure
In such a case, nimble overrided cur_ctrl_proc with BLE_LL_CTRL_PROC_ENCRYPT
which leads to restart procedure "A" once encryption has been done.
---
nimble/controller/src/ble_ll_ctrl.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/nimble/controller/src/ble_ll_ctrl.c b/nimble/controller/src/ble_ll_ctrl.c
index 8a4c665..60306fd 100644
--- a/nimble/controller/src/ble_ll_ctrl.c
+++ b/nimble/controller/src/ble_ll_ctrl.c
@@ -1160,9 +1160,13 @@ ble_ll_ctrl_start_enc_send(struct ble_ll_conn_sm *connsm)
om->om_data[0] = BLE_LL_CTRL_START_ENC_REQ;
ble_ll_conn_enqueue_pkt(connsm, om, BLE_LL_LLID_CTRL, 1);
- /* Wait for LL_START_ENC_RSP */
- connsm->cur_ctrl_proc = BLE_LL_CTRL_PROC_ENCRYPT;
- ble_ll_ctrl_start_rsp_timer(connsm);
+ /* Wait for LL_START_ENC_RSP. If there is already procedure in progress,
+ * LL response timer is already running.
+ */
+ if (connsm->cur_ctrl_proc == BLE_LL_CTRL_PROC_IDLE) {
+ connsm->cur_ctrl_proc = BLE_LL_CTRL_PROC_ENCRYPT;
+ ble_ll_ctrl_start_rsp_timer(connsm);
+ }
rc = 0;
} else {
@@ -1391,10 +1395,11 @@ ble_ll_ctrl_rx_start_enc_rsp(struct ble_ll_conn_sm *connsm)
return BLE_ERR_MAX;
}
- ble_ll_ctrl_proc_stop(connsm, BLE_LL_CTRL_PROC_ENCRYPT);
-
/* If master, we are done. Stop control procedure and sent event to host */
if (connsm->conn_role == BLE_LL_CONN_ROLE_MASTER) {
+
+ ble_ll_ctrl_proc_stop(connsm, BLE_LL_CTRL_PROC_ENCRYPT);
+
/* We are encrypted */
connsm->enc_data.enc_state = CONN_ENC_S_ENCRYPTED;
#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1)
@@ -1404,6 +1409,11 @@ ble_ll_ctrl_rx_start_enc_rsp(struct ble_ll_conn_sm *connsm)
} else {
/* Procedure has completed but slave needs to send START_ENC_RSP */
rc = BLE_LL_CTRL_START_ENC_RSP;
+
+ /* Stop timer if it was started when sending START_ENC_REQ */
+ if (connsm->cur_ctrl_proc == BLE_LL_CTRL_PROC_ENCRYPT) {
+ ble_ll_ctrl_proc_stop(connsm, BLE_LL_CTRL_PROC_ENCRYPT);
+ }
}
/*