From de4a79f3452fb5ff09bdca698b2894b9a49e4663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Rymanowski?= Date: Tue, 5 Feb 2019 17:04:21 +0100 Subject: [PATCH] nimble/ll: Fix enh connection complete event as a master This patch fixes incorretly used identity address as a local rpa address in the LE Enhanced Connection Complete Evt --- nimble/controller/include/controller/ble_ll_conn.h | 3 +-- nimble/controller/src/ble_ll_conn.c | 2 ++ nimble/controller/src/ble_ll_conn_hci.c | 7 ++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/nimble/controller/include/controller/ble_ll_conn.h b/nimble/controller/include/controller/ble_ll_conn.h index 8652a1140..bc80f2371 100644 --- a/nimble/controller/include/controller/ble_ll_conn.h +++ b/nimble/controller/include/controller/ble_ll_conn.h @@ -271,8 +271,7 @@ struct ble_ll_conn_sm uint32_t last_rxd_pdu_cputime; /* Used exclusively for supervision timer */ /* - * Used to mark that direct advertising from the peer was using - * identity address as InitA + * Used to mark that identity address was used as InitA */ uint8_t inita_identity_used; diff --git a/nimble/controller/src/ble_ll_conn.c b/nimble/controller/src/ble_ll_conn.c index 8b40e67a5..296da902f 100644 --- a/nimble/controller/src/ble_ll_conn.c +++ b/nimble/controller/src/ble_ll_conn.c @@ -2772,6 +2772,8 @@ ble_ll_conn_req_pdu_update(struct os_mbuf *m, uint8_t *adva, uint8_t addr_type, if (addr) { memcpy(dptr, addr, BLE_DEV_ADDR_LEN); + /* Identity address used */ + connsm->inita_identity_used = 1; } } diff --git a/nimble/controller/src/ble_ll_conn_hci.c b/nimble/controller/src/ble_ll_conn_hci.c index 3e6f03a20..1a8d3a03f 100644 --- a/nimble/controller/src/ble_ll_conn_hci.c +++ b/nimble/controller/src/ble_ll_conn_hci.c @@ -164,9 +164,10 @@ ble_ll_conn_comp_event_send(struct ble_ll_conn_sm *connsm, uint8_t status, memset(evdata, 0, 2 * BLE_DEV_ADDR_LEN); if (connsm->conn_role == BLE_LL_CONN_ROLE_MASTER) { if (connsm->inita_identity_used) { - /* If it was direct advertising we were replying to and we used - * identity address there (which might be just fine), we should - * we should take it into account here in this event. + /* We used identity address in CONNECT_IND which can be just fine if + * a) it was direct advertising we replied to and remote uses its identity address + * in device privacy mode or IRK is all zeros. + * b) peer uses RPA and this is first time we connect to him */ rpa = NULL; } else if (connsm->own_addr_type > BLE_HCI_ADV_OWN_ADDR_RANDOM) {