Skip to content

Commit cd10474

Browse files
committed
fixed bugs in mqtt_unsubscripbe.cpp
1 parent cb1d69d commit cd10474

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib_acl_cpp/src/mqtt/mqtt_unsuback.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace acl {
77

88
mqtt_unsuback::mqtt_unsuback(void)
9-
: mqtt_ack(MQTT_PUBACK)
9+
: mqtt_ack(MQTT_UNSUBACK)
1010
{
1111
}
1212

lib_acl_cpp/src/mqtt/mqtt_unsubscribe.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ mqtt_unsubscribe& mqtt_unsubscribe::set_pkt_id(unsigned short id) {
4646

4747
mqtt_unsubscribe& mqtt_unsubscribe::add_topic(const char* topic) {
4848
topics_.push_back(topic);
49-
body_len_ += (unsigned) strlen(topic);
49+
body_len_ += 2 + (unsigned) strlen(topic);
5050
return *this;
5151
}
5252

@@ -63,7 +63,8 @@ bool mqtt_unsubscribe::to_string(string& out) {
6363
body_len_ += sizeof(pkt_id_);
6464

6565
mqtt_header& header = this->get_header();
66-
header.set_remaing_length(body_len_);
66+
header.set_header_flags(0x02)
67+
.set_remaing_length(body_len_);
6768

6869
if (!header.build_header(out)) {
6970
return false;

0 commit comments

Comments
 (0)