mirror of
https://github.com/espressif/openthread.git
synced 2026-08-18 16:39:52 +00:00
Add current time to posix RNG seed. (#730)
This commit is contained in:
committed by
Jonathan Hui
parent
081a5acd07
commit
5eb602d443
@@ -34,6 +34,7 @@
|
||||
* This implementation is not a true random number generator and does @em satisfy the Thread requirements.
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
#include <openthread-types.h>
|
||||
|
||||
#include <common/code_utils.hpp>
|
||||
@@ -44,7 +45,8 @@ static uint32_t s_state = 1;
|
||||
|
||||
void posixRandomInit(void)
|
||||
{
|
||||
s_state = NODE_ID;
|
||||
// Multiplying NODE_ID assures that no two nodes gets the same seed within an hour.
|
||||
s_state = (uint32_t)time(NULL) + (3600 * NODE_ID);
|
||||
}
|
||||
|
||||
uint32_t otPlatRandomGet(void)
|
||||
|
||||
Reference in New Issue
Block a user