From d204d33d3d6f271b1fbbb28422360c293e21f0e6 Mon Sep 17 00:00:00 2001 From: Philip Gladstone Date: Thu, 21 Oct 2021 01:32:46 +0000 Subject: [PATCH] Use the hardware random number generator --- components/lua/lua-5.3/luaconf.h | 5 +++++ components/modules/ble.c | 3 --- components/modules/file.c | 1 - 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/components/lua/lua-5.3/luaconf.h b/components/lua/lua-5.3/luaconf.h index cb5f9b41..8081cf7d 100644 --- a/components/lua/lua-5.3/luaconf.h +++ b/components/lua/lua-5.3/luaconf.h @@ -74,6 +74,11 @@ # define LUA_FLOAT_TYPE LUA_FLOAT_FLOAT #endif +#define L_RANDMAX 2147483647 +extern uint32_t esp_random(void); +#define l_rand() (esp_random() & L_RANDMAX) +#define l_srand(x) + /* ** Configuration for Paths. ** diff --git a/components/modules/ble.c b/components/modules/ble.c index 94e21b91..e197981d 100644 --- a/components/modules/ble.c +++ b/components/modules/ble.c @@ -928,13 +928,10 @@ static int lble_init(lua_State *L) { } if (!seen1800) { - printf("about to call gap_init\n"); ble_svc_gap_init(); } - printf("about to call gatt_init\n"); ble_svc_gatt_init(); - printf("about to call gatts_start\n"); ble_gatts_start(); inited = RUNNING; diff --git a/components/modules/file.c b/components/modules/file.c index 8ced231d..fd45c364 100644 --- a/components/modules/file.c +++ b/components/modules/file.c @@ -543,7 +543,6 @@ static int file_putfile( lua_State* L ) // Warning this code C calls other file_* routines to avoid duplication code. These // use Lua stack addressing of arguments, so this does Lua stack maniplation to // align these - int ret_cnt = 0; lua_settop(L, 2); lua_pushvalue(L, 2); //dup contents onto the ToS [3] lua_pushliteral(L, "w+");