From 2f5f8bdbdbc4aba62854e54f49921619b547d288 Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Wed, 17 Apr 2024 14:25:17 -0500 Subject: [PATCH] add comment --- src/platform/silabs/efr32/BLEManagerImpl.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/platform/silabs/efr32/BLEManagerImpl.cpp b/src/platform/silabs/efr32/BLEManagerImpl.cpp index 1e893b99719854..38536120a820f3 100644 --- a/src/platform/silabs/efr32/BLEManagerImpl.cpp +++ b/src/platform/silabs/efr32/BLEManagerImpl.cpp @@ -137,15 +137,17 @@ CHIP_ERROR BLEManagerImpl::_Init() mFlags.ClearAll().Set(Flags::kAdvertisingEnabled, CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART); mFlags.Set(Flags::kFastAdvertisingEnabled, true); + // Check that an address was not already configured at boot. + // This covers the init-shutdown-init case to comply with the BLE address change at boot only requirement if (std::all_of(randomizedAddr.addr, randomizedAddr.addr + (sizeof(randomizedAddr.addr) / sizeof(uint8_t)), [](uint8_t i) { return i == 0; })) { - // Since random address configured, generate one - // Copy random value to address. We don't care of the ordering since it's a random value. + // Since a random address is not configured, configure one uint64_t random = Crypto::GetRandU64(); + // Copy random value to address. We don't care of the ordering since it's a random value. memcpy(&randomizedAddr, &random, sizeof(randomizedAddr)); - // Set MSB to 11 to properly - BLE Static Device Address requirement + // Set two MSBs to 11 to properly the address - BLE Static Device Address requirement randomizedAddr.addr[5] |= 0xC0; }