Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
cs_RandomGenerator.h
Go to the documentation of this file.
1/*
2 * Author: Crownstone Team
3 * Copyright: Crownstone (https://crownstone.rocks)
4 * Date: 23 Feb, 2021
5 * License: LGPLv3+, Apache License 2.0, and/or MIT (triple-licensed)
6 */
7#pragma once
8
10#include <third/random/seed.h>
11#include <third/random/state.h>
12
18private:
20
21public:
27 RandomGenerator(uint32_t seed) : _state(Msws::seed(seed)) {}
28
32 uint32_t rand() { return Msws::msws(_state); }
33
34 uint32_t operator()() { return rand(); }
35};
Wrapper class for internal state of the Msws generator.
Definition: state.h:17
Crownstones pseudo random number generator wrapper.
Definition: cs_RandomGenerator.h:17
uint32_t rand()
Generates a new random number and updates the internal state.
Definition: cs_RandomGenerator.h:32
uint32_t operator()()
Definition: cs_RandomGenerator.h:34
RandomGenerator(uint32_t seed)
The given seed need not be very high quality.
Definition: cs_RandomGenerator.h:27
Msws::State _state
Definition: cs_RandomGenerator.h:19
Definition: random.h:43
static uint32_t msws()
Generate new pseudo random number from global state variables and update them.
Definition: random.h:59