From f52fadaa9a5dfb60caea4147324f3e9c65cec036 Mon Sep 17 00:00:00 2001 From: Jon Shallow Date: Sat, 25 Jul 2026 16:54:00 +0100 Subject: [PATCH] coap_net.c: For NON responses, use server generated message id --- src/coap_net.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/coap_net.c b/src/coap_net.c index ce83013d..f4eff091 100644 --- a/src/coap_net.c +++ b/src/coap_net.c @@ -4017,9 +4017,13 @@ handle_request(coap_context_t *context, coap_session_t *session, coap_pdu_t *pdu goto fail_response; } - response = coap_pdu_init(pdu->type == COAP_MESSAGE_CON ? - COAP_MESSAGE_ACK : COAP_MESSAGE_NON, - 0, pdu->mid, coap_session_max_pdu_size_lkd(session)); + if (pdu->type == COAP_MESSAGE_CON) { + response = coap_pdu_init(COAP_MESSAGE_ACK, 0, pdu->mid, + coap_session_max_pdu_size_lkd(session)); + } else { + response = coap_pdu_init(COAP_MESSAGE_NON, 0, coap_new_message_id_lkd(session), + coap_session_max_pdu_size_lkd(session)); + } if (!response) { coap_log_err("could not create response PDU\n"); resp = 500;