From 6e430351816299521461739ce40af0493e358d8a Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 13 Jan 2024 02:53:38 +0100 Subject: Implemented enough to wake up a sleepy server by connecting nodemcu to dc power --- init.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 init.lua (limited to 'init.lua') diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..1756628 --- /dev/null +++ b/init.lua @@ -0,0 +1,22 @@ +--- Somewhat safely loads "run.lua" module into a global variable RUN. Loaded module itself should be a function. If +--- everything seems fine, true is returned. +function init () + wifi.setmode(wifi.NULLMODE, false) + local l, r = pcall(require, "run") + if not l then + print("run.lua not found") + return + end + RUN = r + l, r = node.bootreason() + if l == 2 and (r == 2 or r == 4) then + print("Most likely an exception restarted last boot, run.lua loaded into RUN and left as is") + return + end + return true +end + + +if init() then + RUN() +end -- cgit v1.1