From 07152de04c9eb6f6d57eb4a824504a36b060a7b3 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Mon, 12 Feb 2024 15:35:49 +0100 Subject: [PATCH] examples/suit_update: make use of nanocoap_resources --- examples/suit_update/Makefile | 1 + examples/suit_update/coap_handler.c | 11 +++-------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/examples/suit_update/Makefile b/examples/suit_update/Makefile index 3ca57555d7..7416456e1a 100644 --- a/examples/suit_update/Makefile +++ b/examples/suit_update/Makefile @@ -38,6 +38,7 @@ QUIET ?= 1 # USEMODULE += suit suit_transport_coap +USEMODULE += nanocoap_resources # enable VFS transport (only works on boards with external storage) USEMODULE += suit_transport_vfs diff --git a/examples/suit_update/coap_handler.c b/examples/suit_update/coap_handler.c index 5d31e76fa8..0c15aac7a4 100644 --- a/examples/suit_update/coap_handler.c +++ b/examples/suit_update/coap_handler.c @@ -22,13 +22,8 @@ static ssize_t _riot_board_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len, COAP_FORMAT_TEXT, (uint8_t*)RIOT_BOARD, strlen(RIOT_BOARD)); } -/* must be sorted by path (ASCII order) */ -const coap_resource_t coap_resources[] = { - COAP_WELL_KNOWN_CORE_DEFAULT_HANDLER, - { "/riot/board", COAP_GET, _riot_board_handler, NULL }, - - /* this line adds the whole "/suit"-subtree */ - SUIT_COAP_SUBTREE, +NANOCOAP_RESOURCE(board) { + .path = "/riot/board", .methods = COAP_GET, .handler = _riot_board_handler, }; -const unsigned coap_resources_numof = ARRAY_SIZE(coap_resources); +NANOCOAP_RESOURCE(suit) SUIT_COAP_SUBTREE;