From: Mark Qvist Date: Sat, 30 Mar 2024 14:11:24 +0000 (+0100) Subject: Use hardware RNG for CSMA r-value seed on ESP32 X-Git-Url: https://git.tnoah.ca/?a=commitdiff_plain;h=e63b5b6cdbae90ad22448b5ca25a384c3953d533;p=lora-radio.git Use hardware RNG for CSMA r-value seed on ESP32 --- diff --git a/RNode_Firmware.ino b/RNode_Firmware.ino index 54ddb12..7b46094 100644 --- a/RNode_Firmware.ino +++ b/RNode_Firmware.ino @@ -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));