diff --git a/src/coap_net.c b/src/coap_net.c index fcf9b7ff..2f2406ac 100644 --- a/src/coap_net.c +++ b/src/coap_net.c @@ -1096,7 +1096,7 @@ coap_send(coap_session_t *session, coap_pdu_t *pdu) { } /* A lot of the reliable code assumes type is CON */ - if (COAP_PROTO_RELIABLE(session->proto) && pdu->type == COAP_MESSAGE_NON) + if (COAP_PROTO_RELIABLE(session->proto) && pdu->type != COAP_MESSAGE_CON) pdu->type = COAP_MESSAGE_CON; #if COAP_OSCORE_SUPPORT diff --git a/src/coap_pdu.c b/src/coap_pdu.c index afe445c8..56cb55b6 100644 --- a/src/coap_pdu.c +++ b/src/coap_pdu.c @@ -1435,6 +1435,11 @@ coap_pdu_encode_header(coap_pdu_t *pdu, coap_proto_t proto) { coap_log_warn("coap_pdu_encode_header: corrupted PDU\n"); return 0; } + + /* A lot of the reliable code assumes type is CON */ + if (pdu->type != COAP_MESSAGE_CON) + pdu->type = COAP_MESSAGE_CON; + if (proto == COAP_PROTO_WS || proto == COAP_PROTO_WSS) len = 0; else