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