Skip to content

Commit e1842cc

Browse files
committed
BLE: Workaround for WB55 connection event
The connection event reported by the WB55 is incorrect if controller privacy is not enable and the peer connects with an unknown private resolvable address: The RPA field contains the connection address (it should be empty) and the peer address is all FF while it should be equal to the connection address.
1 parent f32141a commit e1842cc

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,18 +364,30 @@ class PalGap final : public ble::PalGap {
364364

365365
static GapConnectionCompleteEvent convert(const hciLeConnCmplEvt_t *conn_evt)
366366
{
367+
const bdAddr_t *peer_rpa = &conn_evt->peerRpa;
368+
const bdAddr_t *peer_address = &conn_evt->peerAddr;
369+
370+
#if defined(TARGET_MCU_STM32WB55xx)
371+
const bdAddr_t invalidAddress = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
372+
if (conn_evt->addrType == DM_ADDR_RANDOM &&
373+
memcmp(peer_address, invalidAddress, sizeof(invalidAddress)) == 0 &&
374+
memcmp(peer_rpa, invalidAddress, sizeof(invalidAddress) != 0)
375+
) {
376+
std::swap(peer_rpa, peer_address);
377+
}
378+
#endif
367379
return GapConnectionCompleteEvent(
368380
conn_evt->status,
369381
// note the usage of the stack handle, not the HCI handle
370382
conn_evt->hdr.param,
371383
(connection_role_t::type) conn_evt->role,
372384
(peer_address_type_t::type) conn_evt->addrType,
373-
conn_evt->peerAddr,
385+
*peer_address,
374386
conn_evt->connInterval,
375387
conn_evt->connLatency,
376388
conn_evt->supTimeout,
377389
conn_evt->localRpa,
378-
conn_evt->peerRpa
390+
*peer_rpa
379391
);
380392
}
381393
};

0 commit comments

Comments
 (0)