]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_core/commitdiff
init: switch to OO tmr interface
authorNathaniel Wesley Filardo <nwfilardo@gmail.com>
Tue, 8 Jan 2019 19:39:07 +0000 (19:39 +0000)
committerNathaniel Wesley Filardo <nwfilardo@gmail.com>
Fri, 22 Feb 2019 23:55:08 +0000 (23:55 +0000)
We now assume exclusively the use of OO timers, so always use the
"t:alarm(...)" form rather than "tmr.alarm(t, ...)".

init.lua
telnetd/readme.rst
tq/tq.lua

index aeeb3b1e86832b20802a9aacf3e35bf8f1d1c221..3566ecf5913ad43243799c1028a2e1805b553a29 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -42,6 +42,9 @@ if rtctime then rtctime.set(0) end -- set time to 0 until someone corrects us
 local ie = OVL["init-early"]
 if ie then ie() end
 
+local gotmr = tmr.create()
+got = gotmr
+
 local function goab()
     OVL["nwfnet-diag"]()(true)
     OVL["diag"]()
@@ -50,7 +53,7 @@ local function goab()
     tcpserv:listen(23,function(k)
           local telnetd = OVL["telnetd"]()
           telnetd.on["conn"] = function(s)
-              tmr.unregister(6)
+              if gotmr then gotmr:stop() ; gotmr = nil end
               s(string.format("NODE-%06X RECOVERY (auto reboot cancelled)",node.chipid()))
           end
           telnetd.server(k)
@@ -62,19 +65,20 @@ local function goi2()
 end
 local function waitFLASH()
     local function stop_()
-      gpio.mode(3,gpio.INPUT); gpio.trig(3); tmr.unregister(6)
+      gpio.mode(3,gpio.INPUT); gpio.trig(3)
+      gotmr:stop(); got = nil; gotmr = nil
       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)
+    gotmr:alarm(8000,tmr.ALARM_SINGLE,go)
     gpio.trig(3,"low",function(_) print("Aborting..."); stop() end)
 end
 local function bootPANIC()
-  print("Panic!  Lingering for a minute with telnet console up; 'tmr.unregister(6)' to persist...")
-  tmr.alarm(6,60000,tmr.ALARM_SINGLE,node.restart)
+  print("Panic!  Lingering for a minute with telnet console up; 'got:stop()' to persist...")
+  gotmr:alarm(60000,tmr.ALARM_SINGLE,node.restart)
   goab()
 end
 local bct = {
index 0a237d6288c265281af83798ca9ea0907316286e..38aa4410993c707655698bd290835f373bd343ee 100644 (file)
@@ -43,4 +43,4 @@ Some useful commands
 Schedule a reboot of the node "soon"; we need to give the ESP stack enough
 time to write back the prompt, or we risk racing and panic-ing the stack::
 
-  diag exec tmr.alarm(tmr.create(), 1000, tmr.ALARM_SINGLE, node.restart)
+  diag exec tmr.create():alarm(1000, tmr.ALARM_SINGLE, node.restart)
index 55c5e354a93b19947762ffdb26e1e4d871b0849f..bce15c48cb271fd9897914a6bb49050f0992d0a6 100644 (file)
--- a/tq/tq.lua
+++ b/tq/tq.lua
@@ -70,7 +70,7 @@ local function dequeue(self,what)
   end end
 end
 local function defl_arm(self,t)
-  tmr.alarm(self.tmr, t, tmr.ALARM_SINGLE, function() self:fire() end)
+  self.tmr:alarm(t, tmr.ALARM_SINGLE, function() self:fire() end)
 end
 return function(tmrix) return {
   _q = {}, _tst = 0,