From 81ab69c74dfee8e389c402c5255d765750fe8fe7 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Wed, 13 Nov 2019 15:35:35 +0100 Subject: [PATCH] nimble/ll: Fix reporting peer ID addr without WL enabled If WL is disabled and host provided peer RPA in LE Create Connection peer address and adress type needs to be updated. Otheerwise host will receive LE Enhanced Connection event with invalid ID address and ID address type. This was affecting LL/CON/MAS/BV-102-C qualification test case. --- nimble/controller/src/ble_ll_conn.c | 38 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/nimble/controller/src/ble_ll_conn.c b/nimble/controller/src/ble_ll_conn.c index eeed881e6..e01879eb9 100644 --- a/nimble/controller/src/ble_ll_conn.c +++ b/nimble/controller/src/ble_ll_conn.c @@ -2715,9 +2715,6 @@ void ble_ll_init_rx_pkt_in(uint8_t pdu_type, uint8_t *rxbuf, struct ble_mbuf_hdr *ble_hdr) { -#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) - int8_t rpa_index; -#endif uint8_t addr_type; uint8_t *addr; uint8_t *adv_addr; @@ -2791,30 +2788,25 @@ ble_ll_init_rx_pkt_in(uint8_t pdu_type, uint8_t *rxbuf, goto scan_continue; } - if (ble_ll_scan_whitelist_enabled()) { - #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) - /* - * Did we resolve this address? If so, set correct peer address - * and peer address type. - */ - rpa_index = connsm->rpa_index; - - if (rpa_index >= 0) { - addr_type = g_ble_ll_resolv_list[rpa_index].rl_addr_type + 2; - addr = g_ble_ll_resolv_list[rpa_index].rl_identity_addr; - } else { - addr = adv_addr; - } -#else + /* + * Did we resolve this address? If so, set correct peer address + * and peer address type. + */ + if (connsm->rpa_index >= 0) { + addr_type = g_ble_ll_resolv_list[connsm->rpa_index].rl_addr_type + 2; + addr = g_ble_ll_resolv_list[connsm->rpa_index].rl_identity_addr; + } else { addr = adv_addr; + } +#else + addr = adv_addr; #endif + if (connsm->rpa_index >= 0) { connsm->peer_addr_type = addr_type; memcpy(connsm->peer_addr, addr, BLE_DEV_ADDR_LEN); - } - if (connsm->rpa_index >= 0) { ble_ll_scan_set_peer_rpa(adv_addr); #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) @@ -2825,6 +2817,12 @@ ble_ll_init_rx_pkt_in(uint8_t pdu_type, uint8_t *rxbuf, } #endif + } else if (ble_ll_scan_whitelist_enabled()) { + /* if WL is used we need to store peer addr also if it was not + * resolved + */ + connsm->peer_addr_type = addr_type; + memcpy(connsm->peer_addr, addr, BLE_DEV_ADDR_LEN); } /* Connection has been created. Stop scanning */