summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2024-01-13 02:53:38 +0100
committerAki <please@ignore.pl>2024-01-13 02:53:38 +0100
commit6e430351816299521461739ce40af0493e358d8a (patch)
tree99d009ec11095de3ef9a7f6167be717f6880a204 /init.lua
downloadnodemcu-wakeup-6e430351816299521461739ce40af0493e358d8a.zip
nodemcu-wakeup-6e430351816299521461739ce40af0493e358d8a.tar.gz
nodemcu-wakeup-6e430351816299521461739ce40af0493e358d8a.tar.bz2
Implemented enough to wake up a sleepy server by connecting nodemcu to dc power
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua22
1 files changed, 22 insertions, 0 deletions
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