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 <aleksandr.khromykh@nordicsemi.no>
This commit is contained in:
Aleksandr Khromykh 2024-04-25 10:20:19 +02:00 committed by Carles Cufí
commit dad7c31e7f
3 changed files with 10 additions and 7 deletions

View file

@ -6,11 +6,11 @@
#include <string.h>
#include <zephyr/bluetooth/mesh.h>
#include <zephyr/bluetooth/crypto.h>
#include <zephyr/settings/settings.h>
#include "access.h"
#include "dfu.h"
#include "blob.h"
#include <zephyr/random/random.h>
#include <common/bt_str.h>
#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;
}

View file

@ -6,9 +6,9 @@
#include <stdlib.h>
#include <zephyr/sys/slist.h>
#include <zephyr/random/random.h>
#include <zephyr/sys/byteorder.h>
#include <zephyr/bluetooth/hci.h>
#include <zephyr/bluetooth/crypto.h>
#include <zephyr/bluetooth/mesh/rpr_srv.h>
#include <common/bt_str.h>
#include <zephyr/bluetooth/mesh/sar_cfg.h>
@ -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));
}

View file

@ -1,5 +1,3 @@
CONFIG_ENTROPY_GENERATOR=y
CONFIG_BT_MESH=y
CONFIG_BT_MESH_RELAY=y
CONFIG_BT_MESH_PB_ADV=y