From e42f992022d26c6291c4863fdab288b9da702618 Mon Sep 17 00:00:00 2001 From: Kamil Kasperczyk <66371704+kkasperczyk-no@users.noreply.github.com> Date: Fri, 21 Feb 2025 18:56:37 +0100 Subject: [PATCH] [zephyr] Fixed error check in BLE manager impl (#37706) The error check for rand address generation is done after the address is set, what is too late. --- src/platform/Zephyr/BLEManagerImpl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/platform/Zephyr/BLEManagerImpl.cpp b/src/platform/Zephyr/BLEManagerImpl.cpp index 6b8ba4b6989ce6..4907f6f09aa66a 100644 --- a/src/platform/Zephyr/BLEManagerImpl.cpp +++ b/src/platform/Zephyr/BLEManagerImpl.cpp @@ -122,7 +122,6 @@ int InitRandomStaticAddress(bool idPresent, int & id) // generating the address addr.type = BT_ADDR_LE_RANDOM; error = sys_csrand_get(addr.a.val, sizeof(addr.a.val)); - BT_ADDR_SET_STATIC(&addr.a); if (error) { @@ -130,6 +129,8 @@ int InitRandomStaticAddress(bool idPresent, int & id) return error; } + BT_ADDR_SET_STATIC(&addr.a); + if (!idPresent) { id = bt_id_create(&addr, nullptr);