This is an automated email from the ASF dual-hosted git repository. naraj pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
commit f0a74de7a9962a07758666800b8b16a3d7d101e5 Author: MichaĆ Narajowski <[email protected]> AuthorDate: Wed Jan 9 16:39:04 2019 +0100 host: Fix setting peer RPA address on connection complete If peer RPA is not set in the event and peer address is RPA then store the peer RPA address so when the peer address is resolved, the RPA is not forgotten. --- nimble/host/src/ble_gap.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c index b4cddb1..3c7d0a2 100644 --- a/nimble/host/src/ble_gap.c +++ b/nimble/host/src/ble_gap.c @@ -1448,8 +1448,18 @@ ble_gap_rx_conn_complete(struct hci_le_conn_complete *evt, uint8_t instance) conn->bhc_our_rpa_addr.type = BLE_ADDR_RANDOM; memcpy(conn->bhc_our_rpa_addr.val, evt->local_rpa, 6); - conn->bhc_peer_rpa_addr.type = BLE_ADDR_RANDOM; - memcpy(conn->bhc_peer_rpa_addr.val, evt->peer_rpa, 6); + /* If peer RPA is not set in the event and peer address + * is RPA then store the peer RPA address so when the peer + * address is resolved, the RPA is not forgotten. + */ + if (memcmp(BLE_ADDR_ANY->val, evt->peer_rpa, 6) == 0) { + if (BLE_ADDR_IS_RPA(&conn->bhc_peer_addr)) { + conn->bhc_peer_rpa_addr = conn->bhc_peer_addr; + } + } else { + conn->bhc_peer_rpa_addr.type = BLE_ADDR_RANDOM; + memcpy(conn->bhc_peer_rpa_addr.val, evt->peer_rpa, 6); + } ble_hs_lock();
