Commit 31c71c0e authored by Nathaniel Wesley Filardo's avatar Nathaniel Wesley Filardo Committed by Marcel Stör
Browse files

lua_examples/lfs/HTTP_OTA: move :connect() after :on()

IMHO, it's generally good style to register the callbacks first.
parent e1a81aa1
...@@ -12,8 +12,7 @@ local n, total, size = 0, 0 ...@@ -12,8 +12,7 @@ local n, total, size = 0, 0
doRequest = function(socket, hostIP) -- luacheck: no unused doRequest = function(socket, hostIP) -- luacheck: no unused
if hostIP then if hostIP then
local con = net.createConnection(net.TCP,0) local con = tls.createConnection(net.TCP,0)
con:connect(80,hostIP)
-- Note that the current dev version can only accept uncompressed LFS images -- Note that the current dev version can only accept uncompressed LFS images
con:on("connection",function(sck) con:on("connection",function(sck)
local request = table.concat( { local request = table.concat( {
...@@ -28,6 +27,7 @@ doRequest = function(socket, hostIP) -- luacheck: no unused ...@@ -28,6 +27,7 @@ doRequest = function(socket, hostIP) -- luacheck: no unused
sck:send(request) sck:send(request)
sck:on("receive",firstRec) sck:on("receive",firstRec)
end) end)
con:connect(80,hostIP)
end end
end end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment