Skip to content

Support to BlueNRG_2 BLE component #13246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a465cb3
Add support to BlueNRG_2 BLE component
apalmieriGH Jul 8, 2020
37e202b
Minor change
apalmieriGH Jul 9, 2020
fca16bc
Update BlueNRG_2 README
apalmieriGH Jul 9, 2020
cf7da6d
Update BlueNRG_MS README
apalmieriGH Jul 9, 2020
dc8926d
Add prefixes to include directives
apalmieriGH Jul 9, 2020
9447f7e
Update BlueNRG_2 README
apalmieriGH Jul 10, 2020
784fd26
Restore commands to init static random address
apalmieriGH Jul 14, 2020
9a71498
Update BlueNRG_2 README
apalmieriGH Jul 14, 2020
3894f76
Update BlueNRG_MS README
apalmieriGH Jul 14, 2020
dbee50a
Enable Link Layer Only mode at runtime
apalmieriGH Jul 31, 2020
8c5a7f7
Add binary for updating BlueNRG_2 FW using NUCLEO-L476RG
apalmieriGH Jul 31, 2020
c70c372
Add pic for SPI reset mapping on pin D7
apalmieriGH Jul 31, 2020
118b8fd
Update README
apalmieriGH Jul 31, 2020
48f810b
Fix astyle
apalmieriGH Jul 31, 2020
fc369d2
Fix astyle
apalmieriGH Jul 31, 2020
85892b7
Move COMPONENT_BlueNRG_2 to connectivity/drivers/FEATURE_BLE/
apalmieriGH Aug 27, 2020
6df43f1
Update includes and IRQ timeout constant
apalmieriGH Sep 29, 2020
bc447dc
Rename binary for updating BlueNRG_2 FW with NUCLEO-L476RG
apalmieriGH Oct 14, 2020
6f29ea3
Add binary for updating BlueNRG_2 FW with NUCLEO-F401RE
apalmieriGH Oct 14, 2020
93aefa6
Add BlueNRG-2 FW Image
apalmieriGH Oct 30, 2020
f5f3a4e
Update README
apalmieriGH Oct 30, 2020
dad2b25
Move outside binaries for BlueNRG_2 FW update
apalmieriGH Nov 5, 2020
caf5f27
Add pics for BlueNRG_2 FW update description
apalmieriGH Nov 5, 2020
76f6090
Update README
apalmieriGH Nov 5, 2020
7fbc9ad
Fix broken links in README
apalmieriGH Nov 5, 2020
7b8fa1c
rpa swap workaround for bluenrg2
paul-szczepanek-arm Nov 10, 2020
4fe8671
Add CMakeLists file
apalmieriGH Dec 10, 2020
b28d1b4
Update README
apalmieriGH Dec 10, 2020
413c444
Add BlueNRG_2 component entry
apalmieriGH Dec 10, 2020
46661ea
Add extra configuration for NUCLEO_F446RE
apalmieriGH Dec 14, 2020
0da4f8a
Update README
apalmieriGH Dec 14, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,30 @@ static void hciEvtParseLeConnCmpl(hciEvt_t *pMsg, uint8_t *p, uint8_t len)
pMsg->hdr.status = pMsg->leConnCmpl.status;
}

#ifndef CORDIO_RPA_SWAP_WORKAROUND
#define CORDIO_RPA_SWAP_WORKAROUND 0
#endif
#if CORDIO_RPA_SWAP_WORKAROUND
/*************************************************************************************************/
/*!
* \brief Check if address bits are all 0s or all 1s.
*
* \param p Pointer to address.
*
* \return TRUE if address is invalid.
*/
/*************************************************************************************************/
static bool_t isAddressInvalid(uint8_t *p)
{
for (int i = 0; i < 6; i++) {
if ((p[i] != 0xff) && (p[i] != 0x00)) {
return FALSE; // meaning valid address
}
}
return TRUE;
}
#endif // CORDIO_RPA_SWAP_WORKAROUND

/*************************************************************************************************/
/*!
* \brief Parse an HCI event.
Expand All @@ -384,9 +408,21 @@ static void hciEvtParseLeEnhancedConnCmpl(hciEvt_t *pMsg, uint8_t *p, uint8_t le
BSTREAM_TO_UINT16(pMsg->leConnCmpl.handle, p);
BSTREAM_TO_UINT8(pMsg->leConnCmpl.role, p);
BSTREAM_TO_UINT8(pMsg->leConnCmpl.addrType, p);
BSTREAM_TO_BDA(pMsg->leConnCmpl.peerAddr, p);
BSTREAM_TO_BDA(pMsg->leConnCmpl.localRpa, p);
BSTREAM_TO_BDA(pMsg->leConnCmpl.peerRpa, p);

#if CORDIO_RPA_SWAP_WORKAROUND
if (isAddressInvalid(p)) {
memset(pMsg->leConnCmpl.peerRpa, 0x00, BDA_ADDR_LEN);
p += BDA_ADDR_LEN;
BSTREAM_TO_BDA(pMsg->leConnCmpl.localRpa, p);
BSTREAM_TO_BDA(pMsg->leConnCmpl.peerAddr, p);
} else
#endif // CORDIO_RPA_SWAP_WORKAROUND
{
BSTREAM_TO_BDA(pMsg->leConnCmpl.peerAddr, p);
BSTREAM_TO_BDA(pMsg->leConnCmpl.localRpa, p);
BSTREAM_TO_BDA(pMsg->leConnCmpl.peerRpa, p);
}

BSTREAM_TO_UINT16(pMsg->leConnCmpl.connInterval, p);
BSTREAM_TO_UINT16(pMsg->leConnCmpl.connLatency, p);
BSTREAM_TO_UINT16(pMsg->leConnCmpl.supTimeout, p);
Expand Down
12 changes: 11 additions & 1 deletion connectivity/FEATURE_BLE/source/cordio/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@
"help": "Maximum number of EATT channels per DM connection.",
"value": 1,
"macro_name": "EATT_CONN_CHAN_MAX"
},
"rpa-swap-workaround": {
"help": "Check connection complete event if it needs the addresses swapped due to bug in controller",
"value": null,
"macro_name": "CORDIO_RPA_SWAP_WORKAROUND"
}
},
"target_overrides": {
"NUCLEO_WB55RG": {
"rpa-swap-workaround": true
}
}
}
}
16 changes: 2 additions & 14 deletions connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,30 +401,18 @@ class PalGap final : public ble::PalGap {

static GapConnectionCompleteEvent convert(const hciLeConnCmplEvt_t *conn_evt)
{
const bdAddr_t *peer_rpa = &conn_evt->peerRpa;
const bdAddr_t *peer_address = &conn_evt->peerAddr;

#if defined(TARGET_MCU_STM32WB55xx)
const bdAddr_t invalidAddress = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
if (conn_evt->addrType == DM_ADDR_RANDOM &&
memcmp(peer_address, invalidAddress, sizeof(invalidAddress)) == 0 &&
memcmp(peer_rpa, invalidAddress, sizeof(invalidAddress) != 0)
) {
std::swap(peer_rpa, peer_address);
}
#endif
return GapConnectionCompleteEvent(
conn_evt->status,
// note the usage of the stack handle, not the HCI handle
conn_evt->hdr.param,
(connection_role_t::type) conn_evt->role,
(peer_address_type_t::type) conn_evt->addrType,
*peer_address,
conn_evt->peerAddr,
conn_evt->connInterval,
conn_evt->connLatency,
conn_evt->supTimeout,
conn_evt->localRpa,
*peer_rpa
conn_evt->peerRpa
);
}
};
Expand Down
4 changes: 4 additions & 0 deletions connectivity/drivers/ble/FEATURE_BLE/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

if("BlueNRG_2" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(COMPONENT_BlueNRG_2)
endif()

if("BlueNRG_MS" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(COMPONENT_BlueNRG_MS)
endif()
Expand Down
Loading