diff --git a/lua_examples/luaOTA/_doTick.lua b/lua_examples/luaOTA/_doTick.lua index 979cb003..785822af 100644 --- a/lua_examples/luaOTA/_doTick.lua +++ b/lua_examples/luaOTA/_doTick.lua @@ -1,5 +1,4 @@ --- luacheck: globals self -if (self.timer) then self.timer:stop() end--SAFETRIM +--if (self.timer) then self.timer:stop() end--SAFETRIM -- function _doTick(self) -- Upvals @@ -33,7 +32,7 @@ if (self.timer) then self.timer:stop() end--SAFETRIM -- some resources that are no longer needed and set backstop timer for general -- timeout. This also dereferences the previous doTick cb so it can now be GCed. collectgarbage() - self.timer:alarm(0, 30000, tmr.ALARM_SINGLE, self.startApp) + self.timer:alarm(30000, tmr.ALARM_SINGLE, self.startApp) return self:_provision(socket,rec) end diff --git a/lua_examples/luaOTA/check.lua b/lua_examples/luaOTA/check.lua index e869adf3..9c060c49 100644 --- a/lua_examples/luaOTA/check.lua +++ b/lua_examples/luaOTA/check.lua @@ -45,7 +45,7 @@ end function self.startApp(arg) --upval: gc, self, wifi gc();gc() - self.timer.unregister() + self.timer:unregister() self.socket = nil if not self.config.leave then wifi.setmode(wifi.NULLMODE,false) end local appMod = self.config.app or "luaOTA.default" diff --git a/lua_examples/luaOTA/luaOTAserver.lua b/lua_examples/luaOTA/luaOTAserver.lua index 5356e295..846be9e9 100644 --- a/lua_examples/luaOTA/luaOTAserver.lua +++ b/lua_examples/luaOTA/luaOTAserver.lua @@ -23,7 +23,7 @@ local socket = require "socket" local lfs = require "lfs" local md5 = require "md5" local json = require "cjson" -require "etc.strict" -- see http://www.lua.org/extras/5.1/strict.lua +require "std.strict" -- see http://www.lua.org/extras/5.1/strict.lua -- Local functions (implementation see below) ------------------------------------------ @@ -162,6 +162,10 @@ end ---------------------------------------------------------------------- receive_and_parse = function(esp) local line = esp:receive("*l") + if (not line) then + error( "Empty response from ESP, possible cause: file signature failure", 0) + --return nil + end local packed_cmd, sig = line:sub(1,#line-6),line:sub(-6) -- print("reply:", packed_cmd, sig) local status, cmd = pcall(json.decode, packed_cmd)