Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
31c71c0e
Commit
31c71c0e
authored
Apr 05, 2020
by
Nathaniel Wesley Filardo
Committed by
Marcel Stör
Jun 09, 2020
Browse files
lua_examples/lfs/HTTP_OTA: move :connect() after :on()
IMHO, it's generally good style to register the callbacks first.
parent
e1a81aa1
Changes
1
Hide whitespace changes
Inline
Side-by-side
lua_examples/lfs/HTTP_OTA.lua
View file @
31c71c0e
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment