From: chenwu Date: Tue, 26 Jun 2018 08:48:30 +0000 (+0800) Subject: fix: response failed when set a large response data X-Git-Tag: v3.2-beta1~182^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=152a06042599bcf71a4854c4f1212904ef374b0a;p=esp-idf fix: response failed when set a large response data set the last parameter of `coap_pdu_init`, from size to COAP_MAX_PDU_SIZE refer to https://github.com/obgm/libcoap.git/examples/contiki/coap-observer.c settings -> COAP_DEFAULT_MTU close https://ezredmine.espressif.cn:8765/issues/23207 --- diff --git a/examples/protocols/coap_server/main/coap_server_example_main.c b/examples/protocols/coap_server/main/coap_server_example_main.c index b3ea703080..0d2ce0a284 100644 --- a/examples/protocols/coap_server/main/coap_server_example_main.c +++ b/examples/protocols/coap_server/main/coap_server_example_main.c @@ -51,8 +51,7 @@ send_async_response(coap_context_t *ctx, const coap_endpoint_t *local_if) coap_pdu_t *response; unsigned char buf[3]; const char* response_data = "Hello World!"; - size_t size = sizeof(coap_hdr_t) + 20; - response = coap_pdu_init(async->flags & COAP_MESSAGE_CON, COAP_RESPONSE_CODE(205), 0, size); + response = coap_pdu_init(async->flags & COAP_MESSAGE_CON, COAP_RESPONSE_CODE(205), 0, COAP_MAX_PDU_SIZE); response->hdr->id = coap_new_message_id(ctx); if (async->tokenlen) coap_add_token(response, async->tokenlen, async->token);