Skip to content

Commit

Permalink
fix #907 use corect random source for newer ESP32 models
Browse files Browse the repository at this point in the history
  • Loading branch information
Links2004 committed Sep 6, 2024
1 parent bd011d8 commit 87b23a4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/WebSocketsServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
#include "WebSockets.h"
#include "WebSocketsServer.h"

#ifdef ESP32
#if defined __has_include
#if __has_include("soc/wdev_reg.h")
#include "soc/wdev_reg.h"
#endif // __has_include
#endif // defined __has_include
#endif

WebSocketsServerCore::WebSocketsServerCore(const String & origin, const String & protocol) {
_origin = origin;
_protocol = protocol;
Expand Down Expand Up @@ -87,6 +95,8 @@ void WebSocketsServerCore::begin(void) {

#ifdef ESP8266
randomSeed(RANDOM_REG32);
#elif defined(ESP32) && defined(WDEV_RND_REG)
randomSeed(REG_READ(WDEV_RND_REG));
#elif defined(ESP32)
#define DR_REG_RNG_BASE 0x3ff75144
randomSeed(READ_PERI_REG(DR_REG_RNG_BASE));
Expand Down

0 comments on commit 87b23a4

Please sign in to comment.