From dad7c31e7f870eabea17d38d5d72bc2d201612fc Mon Sep 17 00:00:00 2001 From: Aleksandr Khromykh Date: Thu, 25 Apr 2024 10:20:19 +0200 Subject: [PATCH] Bluetooth: Mesh: use bt_rand instead of sys_rand Commit adds using host\controller based random number generator instead of zephyr driver. No mesh dependency anymore on zephyr system random driver. Signed-off-by: Aleksandr Khromykh --- subsys/bluetooth/mesh/dfu_cli.c | 8 ++++++-- subsys/bluetooth/mesh/rpr_srv.c | 7 ++++--- tests/bluetooth/tester/overlay-mesh.conf | 2 -- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/subsys/bluetooth/mesh/dfu_cli.c b/subsys/bluetooth/mesh/dfu_cli.c index 2345ef8e33b..f02b884d222 100644 --- a/subsys/bluetooth/mesh/dfu_cli.c +++ b/subsys/bluetooth/mesh/dfu_cli.c @@ -6,11 +6,11 @@ #include #include +#include #include #include "access.h" #include "dfu.h" #include "blob.h" -#include #include #define LOG_LEVEL CONFIG_BT_MESH_DFU_LOG_LEVEL @@ -1017,7 +1017,11 @@ int bt_mesh_dfu_cli_send(struct bt_mesh_dfu_cli *cli, cli->xfer.blob.size = xfer->slot->size; if (xfer->blob_id == 0) { - sys_rand_get(&cli->xfer.blob.id, sizeof(cli->xfer.blob.id)); + int err = bt_rand(&cli->xfer.blob.id, sizeof(cli->xfer.blob.id)); + + if (err) { + return err; + } } else { cli->xfer.blob.id = xfer->blob_id; } diff --git a/subsys/bluetooth/mesh/rpr_srv.c b/subsys/bluetooth/mesh/rpr_srv.c index ac3fd190880..d31368f3178 100644 --- a/subsys/bluetooth/mesh/rpr_srv.c +++ b/subsys/bluetooth/mesh/rpr_srv.c @@ -6,9 +6,9 @@ #include #include -#include #include #include +#include #include #include #include @@ -193,14 +193,15 @@ static void link_report_send(void) static void scan_report_schedule(void) { - uint32_t delay; + uint32_t delay = 0; if (k_work_delayable_remaining_get(&srv.scan.report) || atomic_test_bit(srv.flags, SCAN_REPORT_PENDING)) { return; } - delay = (sys_rand32_get() % 480) + 20; + (void)bt_rand(&delay, sizeof(uint32_t)); + delay = (delay % 480) + 20; k_work_reschedule(&srv.scan.report, K_MSEC(delay)); } diff --git a/tests/bluetooth/tester/overlay-mesh.conf b/tests/bluetooth/tester/overlay-mesh.conf index 9fded71f792..1609177c533 100644 --- a/tests/bluetooth/tester/overlay-mesh.conf +++ b/tests/bluetooth/tester/overlay-mesh.conf @@ -1,5 +1,3 @@ -CONFIG_ENTROPY_GENERATOR=y - CONFIG_BT_MESH=y CONFIG_BT_MESH_RELAY=y CONFIG_BT_MESH_PB_ADV=y