Skip to content

Commit 6c6af1b

Browse files
author
Donatien Garnier
committed
Added missing masks and fixed bit ordering in is_random_xx_address() functions
1 parent d8b63fc commit 6c6af1b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

features/FEATURE_BLE/source/generic/GenericGap.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ static bool is_prand_24_bits_valid(const BLEProtocol::AddressBytes_t address)
229229
*/
230230
static bool is_random_static_address(const BLEProtocol::AddressBytes_t address)
231231
{
232-
// top two msb bits shall be equal to 1.
233-
if ((address[5] >> 6) != 0x03) {
232+
// top two msb bits shall be equal to 0b11.
233+
if (((address[5] >> 6) & 0xC0) != 0xC0) {
234234
return false;
235235
}
236236

@@ -243,8 +243,8 @@ static bool is_random_static_address(const BLEProtocol::AddressBytes_t address)
243243
static bool is_random_private_non_resolvable_address(
244244
const BLEProtocol::AddressBytes_t address
245245
) {
246-
// top two msb bits shall be equal to 0.
247-
if ((address[5] >> 6) != 0x00) {
246+
// top two msb bits shall be equal to 0b00.
247+
if (((address[5] >> 6) & 0xC0) != 0x00) {
248248
return false;
249249
}
250250

@@ -257,8 +257,8 @@ static bool is_random_private_non_resolvable_address(
257257
static bool is_random_private_resolvable_address(
258258
const BLEProtocol::AddressBytes_t address
259259
) {
260-
// top two msb bits shall be equal to 01.
261-
if ((address[5] >> 6) != 0x01) {
260+
// top two msb bits shall be equal to 0b01.
261+
if (((address[5] >> 6) & 0xC0) != 0x40) {
262262
return false;
263263
}
264264

0 commit comments

Comments
 (0)