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
501ef9d5
Commit
501ef9d5
authored
May 09, 2016
by
philip
Browse files
Fix bugs with mqtt connection error handling
parent
0577c8af
Changes
1
Show whitespace changes
Inline
Side-by-side
app/modules/mqtt.c
View file @
501ef9d5
...
...
@@ -149,6 +149,8 @@ static void mqtt_socket_reconnected(void *arg, sint8_t err)
os_timer_disarm
(
&
mud
->
mqttTimer
);
mud
->
event_timeout
=
0
;
// no need to count anymore
if
(
mud
->
mqtt_state
.
auto_reconnect
){
pesp_conn
->
proto
.
tcp
->
remote_port
=
mud
->
mqtt_state
.
port
;
pesp_conn
->
proto
.
tcp
->
local_port
=
espconn_port
();
...
...
@@ -608,7 +610,7 @@ void mqtt_socket_timer(void *arg)
mud
->
keep_alive_tick
=
0
;
// not need count anymore
}
else
if
(
mud
->
connState
==
MQTT_CONNECT_SENT
)
{
// wait for CONACK time out.
NODE_DBG
(
"MQTT_CONNECT timeout.
\n
"
);
mud
->
connState
=
=
MQTT_INIT
;
mud
->
connState
=
MQTT_INIT
;
#ifdef CLIENT_SSL_ENABLE
if
(
mud
->
secure
)
...
...
@@ -1055,9 +1057,10 @@ static int mqtt_socket_connect( lua_State* L )
lua_pushvalue
(
L
,
stack
);
// copy argument (func) to the top of stack
luaL_unref
(
L
,
LUA_REGISTRYINDEX
,
mud
->
cb_connect_ref
);
mud
->
cb_connect_ref
=
luaL_ref
(
L
,
LUA_REGISTRYINDEX
);
stack
++
;
}
stack
++
;
// call back function when a connection fails
if
((
stack
<=
top
)
&&
(
lua_type
(
L
,
stack
)
==
LUA_TFUNCTION
||
lua_type
(
L
,
stack
)
==
LUA_TLIGHTFUNCTION
)){
lua_pushvalue
(
L
,
stack
);
// copy argument (func) to the top of stack
...
...
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