Skip to content

Commit 99aba34

Browse files
adeltcAdel Tayeb-Cherif
authored andcommitted
#2954: adapt LuaOTA to the new firmware api for the timer and some other sma… (#3016)
* #2954: adapt to the new firmware api for the timer and some other small fixes * reduce the error msg in when not response is sent back from esp * cleanup: remove trailing whitespaces Co-authored-by: Adel Tayeb-Cherif <[email protected]>
1 parent fd26dea commit 99aba34

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

lua_examples/luaOTA/_doTick.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
-- luacheck: globals self
2-
if (self.timer) then self.timer:stop() end--SAFETRIM
1+
--if (self.timer) then self.timer:stop() end--SAFETRIM
32
-- function _doTick(self)
43

54
-- Upvals
@@ -33,7 +32,7 @@ if (self.timer) then self.timer:stop() end--SAFETRIM
3332
-- some resources that are no longer needed and set backstop timer for general
3433
-- timeout. This also dereferences the previous doTick cb so it can now be GCed.
3534
collectgarbage()
36-
self.timer:alarm(0, 30000, tmr.ALARM_SINGLE, self.startApp)
35+
self.timer:alarm(30000, tmr.ALARM_SINGLE, self.startApp)
3736
return self:_provision(socket,rec)
3837
end
3938

lua_examples/luaOTA/check.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ end
4545

4646
function self.startApp(arg) --upval: gc, self, wifi
4747
gc();gc()
48-
self.timer.unregister()
48+
self.timer:unregister()
4949
self.socket = nil
5050
if not self.config.leave then wifi.setmode(wifi.NULLMODE,false) end
5151
local appMod = self.config.app or "luaOTA.default"

lua_examples/luaOTA/luaOTAserver.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ local socket = require "socket"
2323
local lfs = require "lfs"
2424
local md5 = require "md5"
2525
local json = require "cjson"
26-
require "etc.strict" -- see http://www.lua.org/extras/5.1/strict.lua
26+
require "std.strict" -- see http://www.lua.org/extras/5.1/strict.lua
2727

2828
-- Local functions (implementation see below) ------------------------------------------
2929

@@ -162,6 +162,10 @@ end
162162
----------------------------------------------------------------------
163163
receive_and_parse = function(esp)
164164
local line = esp:receive("*l")
165+
if (not line) then
166+
error( "Empty response from ESP, possible cause: file signature failure", 0)
167+
--return nil
168+
end
165169
local packed_cmd, sig = line:sub(1,#line-6),line:sub(-6)
166170
-- print("reply:", packed_cmd, sig)
167171
local status, cmd = pcall(json.decode, packed_cmd)

0 commit comments

Comments
 (0)