net: coap: Improve the handling of CoAP response code 'continue'

When using block-wise transfer, call the reply callback only when
the last block arrived.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
This commit is contained in:
Lukas Woodtli 2023-07-13 16:02:24 +02:00 committed by Carles Cufí
parent 96aefc09da
commit 2f6c0d7ca3
2 changed files with 6 additions and 1 deletions

View File

@ -259,6 +259,9 @@ struct coap_option {
* @typedef coap_reply_t
* @brief Helper function to be called when a response matches the
* a pending request.
* When sending blocks, the callback is only executed when the
* reply of the last block is received.
* i.e. it is not called when the code of the reply is 'continue' (2.31).
*/
typedef int (*coap_reply_t)(const struct coap_packet *response,
struct coap_reply *reply,

View File

@ -1499,7 +1499,9 @@ struct coap_reply *coap_response_received(
/* handle observed requests only if received in order */
if (age == -ENOENT || is_newer(r->age, age)) {
r->age = age;
r->reply(response, r, from);
if (coap_header_get_code(response) != COAP_RESPONSE_CODE_CONTINUE) {
r->reply(response, r, from);
}
}
return r;