Skip to content

Commit

Permalink
* MDF [protocol] review PR #10
Browse files Browse the repository at this point in the history
  • Loading branch information
JaylinYu committed Mar 11, 2022
1 parent e248b83 commit 4411d39
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/sp/protocol/mqtt/mqtt_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,8 +683,8 @@ nmq_connack_encode(nng_msg *msg, conn_param *cparam, uint8_t reason)
nng_msg_header_append(msg, &cmd, 1);
nng_msg_header_append(msg, var_len, bytes);

print_hex("Header: ", nni_msg_header(msg), nni_msg_header_len(msg));
print_hex("Body: ", nni_msg_body(msg), nni_msg_len(msg));
// print_hex("Header: ", nni_msg_header(msg), nni_msg_header_len(msg));
// print_hex("Body: ", nni_msg_body(msg), nni_msg_len(msg));
}

/**
Expand Down Expand Up @@ -949,7 +949,8 @@ nano_msg_notify_disconnect(conn_param *cparam, uint8_t code)
string.len = strlen(string.body);
topic.body = DISCONNECT_TOPIC;
topic.len = strlen(DISCONNECT_TOPIC);
msg = nano_msg_composer(&msg, 0, 0, &string, &topic, cparam->pro_ver);
// V4 notification msg as default
msg = nano_msg_composer(&msg, 0, 0, &string, &topic, PROTOCOL_VERSION_v311);
return msg;
}

Expand All @@ -966,7 +967,7 @@ nano_msg_notify_connect(conn_param *cparam, uint8_t code)
string.len = strlen(string.body);
topic.body = CONNECT_TOPIC;
topic.len = strlen(CONNECT_TOPIC);
msg = nano_msg_composer(&msg, 0, 0, &string, &topic, cparam->pro_ver);
msg = nano_msg_composer(&msg, 0, 0, &string, &topic, PROTOCOL_VERSION_v311);
return msg;
}

Expand Down
4 changes: 2 additions & 2 deletions src/sp/protocol/mqtt/nmq_mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,7 @@ nano_pipe_close(void *arg)
// depends on MQTT V5 reason code
// create disconnect event msg
if (p->event) {
msg =
nano_msg_notify_disconnect(p->conn_param, p->reason_code);
msg = nano_msg_notify_disconnect(p->conn_param, p->reason_code);
if (msg == NULL) {
nni_mtx_unlock(&s->lk);
return;
Expand All @@ -773,6 +772,7 @@ nano_pipe_close(void *arg)
nni_list_remove(&s->recvq, ctx);
nni_mtx_unlock(&s->lk);
nni_aio_set_msg(aio, msg);
// must be sync due to conn_param racing.
nni_aio_finish_sync(aio, 0, nni_msg_len(msg));
return;
} else {
Expand Down

0 comments on commit 4411d39

Please sign in to comment.