]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_core/commitdiff
Tree tidying
authorNathaniel Wesley Filardo <nwfilardo@gmail.com>
Sun, 12 Aug 2018 10:27:02 +0000 (11:27 +0100)
committerNathaniel Wesley Filardo <nwfilardo@gmail.com>
Sun, 12 Aug 2018 11:05:48 +0000 (12:05 +0100)
fifo/fifo.lua
init.lua
net/nwfnet-go.lua
util/diag.lua

index 794ad0868d95eb5d3e3970dc4c56128c2aeb9aa9..eadc579dcfeb54adbcf6291b04c93ab1530fa345 100644 (file)
@@ -6,7 +6,13 @@
 -- Returns 'true' if the queue was not empty, 'false' otherwise.
 local function dequeue(q,k)
   if #q > 0
-   then local new = k(q[1]) ; if new == nil then table.remove(q,1) else q[1] = new end ; return true
+   then
+     local new = k(q[1])
+     if new == nil
+       then table.remove(q,1)
+       else q[1] = new
+     end
+     return true
    else q._go = true ; return false
   end
 end
index 59576019839d670d21149d987350118cf6291a24..0762247a41166c2bb6d579e4d769197242232af7 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -77,6 +77,14 @@ local function bootPANIC()
   tmr.alarm(6,300000,tmr.ALARM_SINGLE,node.restart)
   goab()
 end
-local bct = { [0] = waitFLASH, [1] = bootPANIC, [2] = bootPANIC, [3] = bootPANIC, [4] = waitFLASH, [5] = goi2, [6] = waitFLASH }
+local bct = {
+  [0] = waitFLASH, -- power on
+  [1] = bootPANIC, -- hardware watchdog
+  [2] = bootPANIC, -- exception
+  [3] = bootPANIC, -- software watchdog
+  [4] = waitFLASH, -- software reset
+  [5] = goi2,      -- deep sleep
+  [6] = waitFLASH, -- external reset
+}
 local _, bc = node.bootreason()
 if bct[bc] then bct[bc]() else waitFLASH() end
index 4579caebbce6acae7897e804cce29c39545086cc..7d4f201eeb6d2fae9b1421e3fd10e7fddfc3799e 100644 (file)
@@ -49,7 +49,10 @@ end
 if file.open("nwfnet.conf2","r") then
   local conf = sjson.decode(file.read() or "")
   if type(conf) == "table" then
-    if conf["verify"] == 1 then print("Enabling certificate verification"); pcall(net.cert.verify,true) end
+    if conf["verify"] == 1 then
+      print("Enabling certificate verification")
+      pcall(net.cert.verify,true)
+    end
    else print("nwfnet.conf2 malformed")
   end
 end
index 7c312582bc7cbcc3a148c513261c98ad76558a2c..977aea84396520729707f7d1f4fe586c86caa244 100644 (file)
@@ -1,31 +1,31 @@
 -- SOFT DEPENDS: file, rtcfifo, node, wifi
 local k,v
 if node then
-  print('INFO:',string.format("major=%d minor=%d dev=%d chip=%d flash=%d fs=%d fm=%d fs=%d",node.info()))
-  print('HEAP:', node.heap())
+  print('INFO',string.format("major=%d minor=%d dev=%d chip=%d flash=%d fs=%d fm=%d fs=%d",node.info()))
+  print('HEAP', node.heap())
 end
 if wifi then
-  print('WIFI:',wifi.getmode())
-  print('MAC:',wifi.sta.getmac(), wifi.ap.getmac())
-  print('HOST:',wifi.sta.gethostname())
-  print('WSTA:',wifi.sta.getconfig())
-  print('WAP:',wifi.ap.getconfig())
-  print('IP:',wifi.sta.getip(), wifi.ap.getip())
+  print('WIFI',wifi.getmode())
+  print('MAC',wifi.sta.getmac(), wifi.ap.getmac())
+  print('HOST',wifi.sta.gethostname())
+  print('WSTA',wifi.sta.getconfig())
+  print('WAP',wifi.ap.getconfig())
+  print('IP',wifi.sta.getip(), wifi.ap.getip())
 end
 if rtcfifo then
-  if rtcfifo.ready() ~= 0 then print('RTCF:',rtcfifo.count()) else print('RTCF:','NOT PREPARED') end
+  if rtcfifo.ready() ~= 0 then print('RTCF',rtcfifo.count()) else print('RTCF','NOT PREPARED') end
 end
 if file then
-  print('FS:', file.fsinfo()); for k,v in pairs(file.list()) do print("",k,v) end
+  print('FS', file.fsinfo()); for k,v in pairs(file.list()) do print("",k,v) end
 end
 if node.flashindex then
  local ut, fa, ma, sz, t = node.flashindex()
  if ut then
-   print('LFS:', ut, fa, ma, sz)
+   print('LFS', ut, fa, ma, sz)
    for k,v in ipairs(t) do print("", v) end
  else
-   print('LFS:', fa, ma)
+   print('LFS', fa, ma)
  end
 end
-print('PACKAGES:'); for k,v in pairs(package.loaded) do print("",k,v) end
-print('GLOBAL:'); for k,v in pairs(_G) do print("",k,v) end
+print('PACKAGES'); for k,v in pairs(package.loaded) do print("",k,v) end
+print('GLOBAL'); for k,v in pairs(_G) do print("",k,v) end