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
e77bb7dd
Commit
e77bb7dd
authored
Jan 31, 2015
by
Vowstar
Browse files
Merge pull request #158 from tuanpmt/master
fixes nodemcu/nodemcu-firmware#155 lwt qos, retain
parents
278e3541
fb0938db
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/modules/mqtt.c
View file @
e77bb7dd
...
...
@@ -472,7 +472,8 @@ static int mqtt_socket_client( lua_State* L )
stack
++
;
}
if
(
username
==
NULL
)
return
1
;
il
=
0
;
NODE_DBG
(
"lengh username: %d
\r\n
"
,
il
);
mud
->
connect_info
.
username
=
(
uint8_t
*
)
c_zalloc
(
il
+
1
);
if
(
!
mud
->
connect_info
.
username
){
return
luaL_error
(
L
,
"not enough memory"
);
...
...
@@ -486,7 +487,9 @@ static int mqtt_socket_client( lua_State* L )
stack
++
;
}
if
(
password
==
NULL
)
return
1
;
il
=
0
;
NODE_DBG
(
"lengh password: %d
\r\n
"
,
il
);
mud
->
connect_info
.
password
=
(
uint8_t
*
)
c_zalloc
(
il
+
1
);
if
(
!
mud
->
connect_info
.
password
){
return
luaL_error
(
L
,
"not enough memory"
);
...
...
@@ -659,7 +662,7 @@ static int mqtt_socket_lwt( lua_State* L )
lwtMsg
=
luaL_checklstring
(
L
,
stack
,
&
il
);
if
(
lwtMsg
==
NULL
)
{
return
luaL_error
(
L
,
"need lwt
topic
"
);
return
luaL_error
(
L
,
"need lwt
message
"
);
}
mud
->
connect_info
.
will_topic
=
(
uint8_t
*
)
c_zalloc
(
topicSize
+
1
);
...
...
app/mqtt/mqtt_msg.c
View file @
e77bb7dd
...
...
@@ -47,7 +47,7 @@ struct __attribute((__packed__)) mqtt_connect_variable_header
{
uint8_t
lengthMsb
;
uint8_t
lengthLsb
;
uint8_t
magic
[
6
];
uint8_t
magic
[
4
];
uint8_t
version
;
uint8_t
flags
;
uint8_t
keepaliveMsb
;
...
...
@@ -293,9 +293,9 @@ mqtt_message_t* mqtt_msg_connect(mqtt_connection_t* connection, mqtt_connect_inf
connection
->
message
.
length
+=
sizeof
(
*
variable_header
);
variable_header
->
lengthMsb
=
0
;
variable_header
->
lengthLsb
=
6
;
memcpy
(
variable_header
->
magic
,
"MQ
Isdp
"
,
6
);
variable_header
->
version
=
3
;
variable_header
->
lengthLsb
=
4
;
memcpy
(
variable_header
->
magic
,
"MQ
TT
"
,
4
);
variable_header
->
version
=
4
;
variable_header
->
flags
=
0
;
variable_header
->
keepaliveMsb
=
info
->
keepalive
>>
8
;
variable_header
->
keepaliveLsb
=
info
->
keepalive
&
0xff
;
...
...
@@ -322,7 +322,7 @@ mqtt_message_t* mqtt_msg_connect(mqtt_connection_t* connection, mqtt_connect_inf
variable_header
->
flags
|=
MQTT_CONNECT_FLAG_WILL
;
if
(
info
->
will_retain
)
variable_header
->
flags
|=
MQTT_CONNECT_FLAG_WILL_RETAIN
;
variable_header
->
flags
|=
(
info
->
will_qos
&
3
)
<<
4
;
variable_header
->
flags
|=
(
info
->
will_qos
&
3
)
<<
3
;
}
if
(
info
->
username
!=
NULL
&&
info
->
username
[
0
]
!=
'\0'
)
...
...
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