From 191c91ce188febfdb17fba1f0852fc729d126409 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Thu, 3 Dec 2020 10:51:42 +0100 Subject: [PATCH] suit/transport/coap: make blocksize configurable When using SUIT over a link-layer that supports larger PDU, a larger CoAP blocksize is desirable to speed up firmware downloads. To support this, make the CoAP blocksize used by SUIT configurable. --- sys/include/suit/transport/coap.h | 7 +++++++ sys/suit/handlers_command_seq.c | 2 +- sys/suit/transport/coap.c | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/include/suit/transport/coap.h b/sys/include/suit/transport/coap.h index 6a79341d3d..db88d0ca34 100644 --- a/sys/include/suit/transport/coap.h +++ b/sys/include/suit/transport/coap.h @@ -121,6 +121,13 @@ typedef enum { COAP_BLOCKSIZE_1024, } coap_blksize_t; +/** + * @brief Coap block-wise-transfer size used for SUIT + */ +#ifndef CONFIG_SUIT_COAP_BLOCKSIZE +#define CONFIG_SUIT_COAP_BLOCKSIZE COAP_BLOCKSIZE_64 +#endif + /** * @brief Performs a blockwise coap get request to the specified url. * diff --git a/sys/suit/handlers_command_seq.c b/sys/suit/handlers_command_seq.c index 9d0fc6fecd..818bad2752 100644 --- a/sys/suit/handlers_command_seq.c +++ b/sys/suit/handlers_command_seq.c @@ -358,7 +358,7 @@ static int _dtv_fetch(suit_manifest_t *manifest, int key, if (0) {} #ifdef MODULE_SUIT_TRANSPORT_COAP else if (strncmp(manifest->urlbuf, "coap://", 7) == 0) { - res = suit_coap_get_blockwise_url(manifest->urlbuf, COAP_BLOCKSIZE_64, + res = suit_coap_get_blockwise_url(manifest->urlbuf, CONFIG_SUIT_COAP_BLOCKSIZE, suit_storage_helper, manifest); } diff --git a/sys/suit/transport/coap.c b/sys/suit/transport/coap.c index 6b10936a74..77e3702012 100644 --- a/sys/suit/transport/coap.c +++ b/sys/suit/transport/coap.c @@ -346,7 +346,7 @@ ssize_t suit_coap_get_blockwise_url_buf(const char *url, static void _suit_handle_url(const char *url) { LOG_INFO("suit_coap: downloading \"%s\"\n", url); - ssize_t size = suit_coap_get_blockwise_url_buf(url, COAP_BLOCKSIZE_64, + ssize_t size = suit_coap_get_blockwise_url_buf(url, CONFIG_SUIT_COAP_BLOCKSIZE, _manifest_buf, SUIT_MANIFEST_BUFSIZE); if (size >= 0) {