]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_core/commitdiff
init: Add 'go()' to skip wait at boot
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Sat, 29 Jul 2017 20:08:16 +0000 (16:08 -0400)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Sun, 30 Jul 2017 07:06:22 +0000 (03:06 -0400)
While here, fix indentation

init.lua

index 749a21a798fe4fc44f38151958ddc35b6217a7a1..b2daeffb84a4806c3a960d49887d205b8ce86387 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -8,30 +8,34 @@ if not cjson then _G.cjson = sjson end
 if file and file.exists("init-early.lua") then dofile("init-early.lua") end
 
 local function goab()
-       dofile("nwfnet-diag.lc")(true)
-       dofile("diag.lc")
-       dofile("nwfnet-go.lc")
-       tcpserv = net.createServer(net.TCP, 180)
+    dofile("nwfnet-diag.lc")(true)
+    dofile("diag.lc")
+    dofile("nwfnet-go.lc")
+    tcpserv = net.createServer(net.TCP, 180)
         tcpserv:listen(23,function(k)
           local telnetd = dofile "telnetd.lc"
-         telnetd.on["conn"] = function(k)
+      telnetd.on["conn"] = function(k)
             tmr.unregister(6)
             k:send(string.format("NODE-%06X RECOVERY (auto reboot cancelled)",node.chipid())) end
           telnetd.server(k)
         end)
 end
-local function go(fn) 
-       local f, e = loadfile(fn)
-       if f == nil then print("Error:",fn,e); goab() else node.task.post(f) end
+local function gof(fn)
+    local f, e = loadfile(fn)
+    if f == nil then print("Error:",fn,e); goab() else node.task.post(f) end
 end
-local function goi2() go("init2.lc") end
+local function goi2() gof("init2.lc") end
 local function waitFLASH()
-       local function stop_() gpio.mode(3,gpio.INPUT); gpio.trig(3); tmr.unregister(6); stop = nil end
-        function stop() stop_(); goab(); end
-       print("Reset delay!  Bounce GPIO3 low or type 'stop()' to stop autoboot...")
-       gpio.mode(3,gpio.INT,gpio.PULLUP)
-       tmr.alarm(6,8000,tmr.ALARM_SINGLE,function() print("Continuing boot..."); stop_(); goi2() end)
-       gpio.trig(3,"low",function(_) print("Aborting..."); stop() end)
+    local function stop_()
+      gpio.mode(3,gpio.INPUT); gpio.trig(3); tmr.unregister(6)
+      stop = nil; go = nil
+    end
+    function stop() stop_(); goab() end
+    function go() print("Continuing boot..."); stop_(); goi2() end
+    print("Reset delay!  Bounce GPIO3 low or type 'stop()' to stop autoboot, or 'go()' to go...")
+    gpio.mode(3,gpio.INT,gpio.PULLUP)
+    tmr.alarm(6,8000,tmr.ALARM_SINGLE,go)
+    gpio.trig(3,"low",function(_) print("Aborting..."); stop() end)
 end
 local function bootPANIC()
   print("Panic!  Lingering for five minutes with telnet console up; 'tmr.unregister(6)' to persist...")