diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c index 87ccef2b0..5a1d4819f 100644 --- a/nimble/host/src/ble_gap.c +++ b/nimble/host/src/ble_gap.c @@ -5727,8 +5727,17 @@ ble_gap_ext_connect(uint8_t own_addr_type, const ble_addr_t *peer_addr, } ble_conn_reattempt[reattempt_idx].own_addr_type = own_addr_type; - memcpy(&ble_conn_reattempt[reattempt_idx].peer_addr, peer_addr, - sizeof(ble_addr_t)); + + if (peer_addr != NULL) { + ble_conn_reattempt[reattempt_idx].peer_addr_present = 1; + memcpy(&ble_conn_reattempt[reattempt_idx].peer_addr, peer_addr, + sizeof(ble_addr_t)); + } else { + ble_conn_reattempt[reattempt_idx].peer_addr_present = 0; + memset(&ble_conn_reattempt[reattempt_idx].peer_addr, 0, + sizeof(ble_addr_t)); + } + ble_conn_reattempt[reattempt_idx].duration_ms = duration_ms; if (phy_mask & BLE_GAP_LE_PHY_1M_MASK) {