Use hardware RNG for CSMA r-value seed on ESP32
This commit is contained in:
parent
854b345e3d
commit
e63b5b6cdb
@ -60,8 +60,17 @@ void setup() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Seed the PRNG
|
// Seed the PRNG for CSMA R-value selection
|
||||||
randomSeed(analogRead(0));
|
# if MCU_VARIANT == MCU_ESP32
|
||||||
|
// On ESP32, get the seed value from the
|
||||||
|
// hardware RNG
|
||||||
|
int seed_val = (int)esp_random();
|
||||||
|
#else
|
||||||
|
// Otherwise, get a pseudo-random seed
|
||||||
|
// value from an unconnected analog pin
|
||||||
|
int seed_val = analogRead(0);
|
||||||
|
#endif
|
||||||
|
randomSeed(seed_val);
|
||||||
|
|
||||||
// Initialise serial communication
|
// Initialise serial communication
|
||||||
memset(serialBuffer, 0, sizeof(serialBuffer));
|
memset(serialBuffer, 0, sizeof(serialBuffer));
|
||||||
|
Loading…
Reference in New Issue
Block a user