Skip to content

Allow setting a seed for random numbers - #399

Open
MaartenS11 wants to merge 2 commits into
mainfrom
feat/random-seeds
Open

Allow setting a seed for random numbers#399
MaartenS11 wants to merge 2 commits into
mainfrom
feat/random-seeds

Conversation

@MaartenS11

@MaartenS11 MaartenS11 commented Aug 4, 2026

Copy link
Copy Markdown
Member

Adds random_set_seed to set the seed used by random_int.

Currently we use std::minstd_rand on Zephyr, this due to a linker conflict between the random functions defined by both Zephyr and ESP-IDF.

Base automatically changed from fix/sockets-send-len to main August 4, 2026 13:21
@MaartenS11
MaartenS11 force-pushed the feat/random-seeds branch 5 times, most recently from e02eaf8 to 0d9f738 Compare August 5, 2026 08:25
…and Zephyr conflict

Ideally we should not have to do this and it increases the size of the binary slightly but there is no way to avoid the conflict between ESP-IDF and Zephyr otherwise. However, rand and srand do work fine on other boards.

Why rand/srand:
The entropy API appears to be more useful for cryptographic purposes by using hardware entropy which we don't really need for basic random numbers.

We still have some conf options for this but this is mostly becaues the networking stack can also sometimes use entropy.

By using rand we can also use srand to set the seed which the entropy API does not support.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant