3#include <zephyr/kernel.h>
4#include <zephyr/random/random.h>
14 auto *mutex =
new k_mutex();
15 this->handle_ = mutex;
18Mutex::~Mutex() {
delete static_cast<k_mutex *
>(this->handle_); }
19void Mutex::lock() { k_mutex_lock(
static_cast<k_mutex *
>(this->handle_), K_FOREVER); }
20bool Mutex::try_lock() {
return k_mutex_lock(
static_cast<k_mutex *
>(this->handle_), K_NO_WAIT) == 0; }
21void Mutex::unlock() { k_mutex_unlock(
static_cast<k_mutex *
>(this->handle_)); }
29 sys_rand_get(data,
len);
35 mac[0] = ((NRF_FICR->DEVICEADDR[1] & 0xFFFF) >> 8) | 0xC0;
36 mac[1] = NRF_FICR->DEVICEADDR[1] & 0xFFFF;
37 mac[2] = NRF_FICR->DEVICEADDR[0] >> 24;
38 mac[3] = NRF_FICR->DEVICEADDR[0] >> 16;
39 mac[4] = NRF_FICR->DEVICEADDR[0] >> 8;
40 mac[5] = NRF_FICR->DEVICEADDR[0];
bool random_bytes(uint8_t *data, size_t len)
Generate len random bytes using the platform's secure RNG (hardware RNG or OS CSPRNG).
void get_mac_address_raw(uint8_t *mac)
Get the device MAC address as raw bytes, written into the provided byte array (6 bytes).