diff --git a/sys/net/application_layer/nanocoap/nanocoap.c b/sys/net/application_layer/nanocoap/nanocoap.c index 528a655a80a2ceaf1d84fffd17e483f33f49ddb6..c958201f9c953466b844114ce7e3f6734e950b90 100644 --- a/sys/net/application_layer/nanocoap/nanocoap.c +++ b/sys/net/application_layer/nanocoap/nanocoap.c @@ -370,8 +370,16 @@ ssize_t coap_build_reply(coap_pkt_t *pkt, unsigned code, return -ENOSPC; } - /* if code is COAP_CODE_EMPTY (zero), use RST as type, else RESP */ - unsigned type = code ? COAP_RESP : COAP_RST; + /* if code is COAP_CODE_EMPTY (zero), assume Reset (RST) type */ + unsigned type = COAP_TYPE_RST; + if (code) { + if (coap_get_type(pkt) == COAP_TYPE_CON) { + type = COAP_TYPE_ACK; + } + else { + type = COAP_TYPE_NON; + } + } coap_build_hdr((coap_hdr_t *)rbuf, type, pkt->token, tkl, code, ntohs(pkt->hdr->id));