Abtin Keshavarzian 4de7bc578e [random] introduce template-based NonCrypto random APIs (#13142)
This commit introduces a new set of template-based APIs for
non-cryptographic random number generation in the `Random::NonCrypto`
namespace. These new methods provide a cleaner, type-safe, and more
robust interface compared to the previous methods.

Key additions:
- `Generate<UintType>()`: Returns a random value of the given
  unsigned integer type (`uint8_t`, `uint16_t`, or `uint32_t`).
- `GenerateUpToExcluding<UintType>(aMax)`: Returns a random value in
  the range `[0, aMax)`.
- `GenerateFromMinUpToExcluding<UintType>(aMin, aMax)`: Returns a
  random value in the range `[aMin, aMax)`.
- `GenerateInClosedRange<UintType>(aMin, aMax)`: Returns a random
  value in the closed range `[aMin, aMax]`.

The introduction of `GenerateInClosedRange` is an improvement as it
safely handles ranges up to the maximum value of the integer type
(e.g., `0xffff`) without the risk of overflow.

All call sites across the OpenThread core stack and tests have been
updated to adopt these new APIs. The public `otRandomNonCrypto`
functions are also updated to leverage the new internal methods.

Doxygen documentation is added for all new template methods,
detailing their behavior, including edge cases where the upper bound
is smaller than or equal to the lower bound.
2026-05-25 19:39:59 -07:00
2024-04-22 07:38:41 -07:00
2025-06-17 14:21:37 +09:00
2024-12-19 14:24:26 -08:00
2022-12-07 16:21:29 -08:00

OpenThread Ask DeepWiki


What is OpenThread?

OpenThread released by Google is... Thread Certified Component

...an open-source implementation of the Thread networking protocol. Google Nest has released OpenThread to make the technology used in Nest products more broadly available to developers to accelerate the development of products for the connected home.

...OS and platform agnostic, with a narrow platform abstraction layer and a small memory footprint, making it highly portable. It supports both system-on-chip (SoC) and network co-processor (NCP) designs.

...a Thread Certified Component, implementing all features defined in the Thread 1.4.0 specification, including all Thread networking layers (IPv6, 6LoWPAN, IEEE 802.15.4 with MAC security, Mesh Link Establishment, Mesh Routing) and device roles, as well as Border Router support.

More information about Thread can be found at threadgroup.org. Thread is a registered trademark of the Thread Group, Inc.

Who supports OpenThread?

AmazonAqaraARMBekenCascodaEeroEspressifGoogleInfineonMMB NetworksNabu CasaNanoleafNordicNXPQorvoQualcommSamsungSilicon LabsSTMicroelectronicsSynopsysTelink SemiconductorTexas InstrumentsZephyr Project

Getting started

All end-user documentation and guides are located at openthread.io. If you're looking to do things like...

  • Learn more about OpenThread features and enhancements
  • Use OpenThread in your products
  • Learn how to build and configure a Thread network
  • Port OpenThread to a new platform
  • Build an application on top of OpenThread
  • Certify a product using OpenThread

...then openthread.io is the place for you.

Note: For users in China, end-user documentation is available at openthread.google.cn.

If you're interested in contributing to OpenThread, read on.

Contributing

We would love for you to contribute to OpenThread and help make it even better than it is today! See our Contributing Guidelines for more information.

Contributors are required to abide by our Code of Conduct and Coding Conventions and Style Guide.

License

OpenThread is released under the BSD 3-Clause license. See the LICENSE file for more information.

Please only use the OpenThread name and marks when accurately referencing this software distribution. Do not use the marks in a way that suggests you are endorsed by or otherwise affiliated with Nest, Google, or The Thread Group.

Need help?

OpenThread support is available on GitHub:

S
Description
Languages
C++ 66.1%
Python 23.3%
C 9%
Shell 0.8%
CMake 0.7%