From 1bb159524abdce1c0b6465fecda65853bb9729e1 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Sat, 29 Jul 2017 16:08:16 -0400 Subject: [PATCH] init: Add 'go()' to skip wait at boot While here, fix indentation --- init.lua | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/init.lua b/init.lua index 749a21a..b2daeff 100644 --- 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...") -- 2.50.1