Skip to content

Commit

Permalink
Use hardware RNG for CSMA r-value seed on ESP32
Browse files Browse the repository at this point in the history
  • Loading branch information
markqvist committed Mar 30, 2024
1 parent 854b345 commit e63b5b6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions RNode_Firmware.ino
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,17 @@ void setup() {
}
#endif

// Seed the PRNG
randomSeed(analogRead(0));
// Seed the PRNG for CSMA R-value selection
# 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
memset(serialBuffer, 0, sizeof(serialBuffer));
Expand Down

0 comments on commit e63b5b6

Please sign in to comment.