From 96464a9c3d4bf511d010bf024a85bec9264dde4f Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 22 Mar 2024 16:40:11 +0100 Subject: [PATCH] HACK: nanocoap_sock: always add token to block-wise request https://github.com/plgd-dev/go-coap/issues/512 https://github.com/plgd-dev/go-coap/issues/502 --- sys/net/application_layer/nanocoap/sock.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/net/application_layer/nanocoap/sock.c b/sys/net/application_layer/nanocoap/sock.c index 43f3e14acb3b..6268eb6423b2 100644 --- a/sys/net/application_layer/nanocoap/sock.c +++ b/sys/net/application_layer/nanocoap/sock.c @@ -601,7 +601,10 @@ static int _fetch_block(nanocoap_sock_t *sock, uint8_t *buf, size_t len, }; uint16_t lastonum = 0; - buf += coap_build_hdr(pkt.hdr, COAP_TYPE_CON, NULL, 0, COAP_METHOD_GET, + /* HACK: go-coap always expects a token */ + /* see https://github.com/plgd-dev/go-coap/issues/512 */ + const uint8_t token[4] = "CoAP"; + buf += coap_build_hdr(pkt.hdr, COAP_TYPE_CON, (void *)token, sizeof(token), COAP_METHOD_GET, nanocoap_sock_next_msg_id(sock)); buf += coap_opt_put_uri_pathquery(buf, &lastonum, path); buf += coap_opt_put_uint(buf, lastonum, COAP_OPT_BLOCK2, (num << 4) | blksize);