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
340ef8fc
Commit
340ef8fc
authored
Oct 17, 2015
by
Vowstar
Browse files
Merge pull request #636 from karrots/mqtt-clean-session
Added mqtt clean session support.
parents
a33e3a4a
5161081c
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/modules/mqtt.c
View file @
340ef8fc
...
@@ -549,7 +549,7 @@ void mqtt_socket_timer(void *arg)
...
@@ -549,7 +549,7 @@ void mqtt_socket_timer(void *arg)
NODE_DBG
(
"leave mqtt_socket_timer.
\n
"
);
NODE_DBG
(
"leave mqtt_socket_timer.
\n
"
);
}
}
// Lua: mqtt.Client(clientid, keepalive, user, pass)
// Lua: mqtt.Client(clientid, keepalive, user, pass
, clean_session
)
static
int
mqtt_socket_client
(
lua_State
*
L
)
static
int
mqtt_socket_client
(
lua_State
*
L
)
{
{
NODE_DBG
(
"enter mqtt_socket_client.
\n
"
);
NODE_DBG
(
"enter mqtt_socket_client.
\n
"
);
...
@@ -566,6 +566,7 @@ static int mqtt_socket_client( lua_State* L )
...
@@ -566,6 +566,7 @@ static int mqtt_socket_client( lua_State* L )
int
keepalive
=
0
;
int
keepalive
=
0
;
int
stack
=
1
;
int
stack
=
1
;
unsigned
secure
=
0
;
unsigned
secure
=
0
;
int
clean_session
=
1
;
int
top
=
lua_gettop
(
L
);
int
top
=
lua_gettop
(
L
);
// create a object
// create a object
...
@@ -627,6 +628,16 @@ static int mqtt_socket_client( lua_State* L )
...
@@ -627,6 +628,16 @@ static int mqtt_socket_client( lua_State* L )
if
(
password
==
NULL
)
if
(
password
==
NULL
)
pwl
=
0
;
pwl
=
0
;
NODE_DBG
(
"lengh password: %d
\r\n
"
,
pwl
);
NODE_DBG
(
"lengh password: %d
\r\n
"
,
pwl
);
if
(
lua_isnumber
(
L
,
stack
))
{
clean_session
=
luaL_checkinteger
(
L
,
stack
);
stack
++
;
}
if
(
clean_session
>
1
){
clean_session
=
1
;
}
// TODO: check the zalloc result.
// TODO: check the zalloc result.
mud
->
connect_info
.
client_id
=
(
uint8_t
*
)
c_zalloc
(
idl
+
1
);
mud
->
connect_info
.
client_id
=
(
uint8_t
*
)
c_zalloc
(
idl
+
1
);
...
@@ -657,7 +668,7 @@ static int mqtt_socket_client( lua_State* L )
...
@@ -657,7 +668,7 @@ static int mqtt_socket_client( lua_State* L )
NODE_DBG
(
"MQTT: Init info: %s, %s, %s
\r\n
"
,
mud
->
connect_info
.
client_id
,
mud
->
connect_info
.
username
,
mud
->
connect_info
.
password
);
NODE_DBG
(
"MQTT: Init info: %s, %s, %s
\r\n
"
,
mud
->
connect_info
.
client_id
,
mud
->
connect_info
.
username
,
mud
->
connect_info
.
password
);
mud
->
connect_info
.
clean_session
=
1
;
mud
->
connect_info
.
clean_session
=
clean_session
;
mud
->
connect_info
.
will_qos
=
0
;
mud
->
connect_info
.
will_qos
=
0
;
mud
->
connect_info
.
will_retain
=
0
;
mud
->
connect_info
.
will_retain
=
0
;
mud
->
connect_info
.
keepalive
=
keepalive
;
mud
->
connect_info
.
keepalive
=
keepalive
;
...
...
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