diff --git a/src/coap_block.c b/src/coap_block.c index d7914ca2..0335cd34 100644 --- a/src/coap_block.c +++ b/src/coap_block.c @@ -1492,6 +1492,7 @@ coap_build_missing_pdu(coap_session_t *session, coap_lg_crcv_t *lg_crcv) { size_t len = coap_encode_var_safe8(buf, sizeof(token), token); memset(&drop_options, 0, sizeof(coap_opt_filter_t)); + coap_option_filter_set(&drop_options, COAP_OPTION_Q_BLOCK1); coap_option_filter_set(&drop_options, COAP_OPTION_Q_BLOCK2); coap_option_filter_set(&drop_options, COAP_OPTION_OBSERVE); pdu = coap_pdu_duplicate_lkd(lg_crcv->sent_pdu, session, len, buf, diff --git a/src/coap_net.c b/src/coap_net.c index e85f882c..6caa3191 100644 --- a/src/coap_net.c +++ b/src/coap_net.c @@ -4014,7 +4014,7 @@ skip_handler: /* No delays to response */ #if COAP_Q_BLOCK_SUPPORT if (session->block_mode & COAP_BLOCK_USE_LIBCOAP && - !lg_xmit_ctrl && response->code == COAP_RESPONSE_CODE(205) && + !lg_xmit_ctrl && COAP_RESPONSE_CLASS(response->code) == 2 && coap_get_block_b(session, response, COAP_OPTION_Q_BLOCK2, &block) && block.m) { if (coap_send_q_block2(session, resource, query, pdu->code, block, @@ -4216,8 +4216,7 @@ handle_response(coap_context_t *context, coap_session_t *session, } #if COAP_Q_BLOCK_SUPPORT /* Check to see if checking out Q-Block support */ - if (session->block_mode & COAP_BLOCK_PROBE_Q_BLOCK && - session->remote_test_mid == rcvd->mid) { + if (session->block_mode & COAP_BLOCK_PROBE_Q_BLOCK) { if (rcvd->code == COAP_RESPONSE_CODE(402)) { coap_log_debug("Q-Block support not available\n"); set_block_mode_drop_q(session->block_mode); @@ -4233,6 +4232,8 @@ handle_response(coap_context_t *context, coap_session_t *session, } } session->doing_first = 0; + if (rcvd->type == COAP_MESSAGE_CON) + coap_send_ack_lkd(session, rcvd); return; } #endif /* COAP_Q_BLOCK_SUPPORT */ diff --git a/src/coap_proxy.c b/src/coap_proxy.c index 3fe25b14..f9e8165e 100644 --- a/src/coap_proxy.c +++ b/src/coap_proxy.c @@ -740,6 +740,12 @@ coap_proxy_call_response_handler(coap_session_t *session, const coap_pdu_t *sent proxy_req->mid = resp_pdu->mid; + /* If sent early ACK, and this is an ACK, need to convert it to CON */ + if (COAP_PROTO_NOT_RELIABLE(session->proto) && resp_pdu->type == COAP_MESSAGE_ACK && + !(session->block_mode & COAP_BLOCK_CACHE_RESPONSE)) { + resp_pdu->type = COAP_MESSAGE_CON; + } + if (coap_get_data_large(rcvd, &size, &data, &offset, &total)) { uint16_t media_type = 0; int maxage = -1;