[coap] fix handling message id 0 (#2104)

This commit is contained in:
Buke Po
2017-08-15 09:12:23 -07:00
committed by Jonathan Hui
parent 02bdc692a2
commit 06247b2d84
+2 -1
View File
@@ -175,7 +175,8 @@ otError Coap::SendMessage(Message &aMessage, const Ip6::MessageInfo &aMessageInf
}
// Set Message Id if it was not already set.
if (header.GetMessageId() == 0)
if (header.GetMessageId() == 0 &&
(header.GetType() == OT_COAP_TYPE_CONFIRMABLE || header.GetType() == OT_COAP_TYPE_NON_CONFIRMABLE))
{
header.SetMessageId(mMessageId++);
aMessage.Write(0, Header::kMinHeaderLength, header.GetBytes());