Skip to content

Commit 31c71c0

Browse files
nwfmarcelstoer
authored andcommitted
lua_examples/lfs/HTTP_OTA: move :connect() after :on()
IMHO, it's generally good style to register the callbacks first.
1 parent e1a81aa commit 31c71c0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lua_examples/lfs/HTTP_OTA.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ local n, total, size = 0, 0
1212

1313
doRequest = function(socket, hostIP) -- luacheck: no unused
1414
if hostIP then
15-
local con = net.createConnection(net.TCP,0)
16-
con:connect(80,hostIP)
15+
local con = tls.createConnection(net.TCP,0)
1716
-- Note that the current dev version can only accept uncompressed LFS images
1817
con:on("connection",function(sck)
1918
local request = table.concat( {
@@ -28,6 +27,7 @@ doRequest = function(socket, hostIP) -- luacheck: no unused
2827
sck:send(request)
2928
sck:on("receive",firstRec)
3029
end)
30+
con:connect(80,hostIP)
3131
end
3232
end
3333

0 commit comments

Comments
 (0)