From 2dd6a65ea91b1c70003f6cb514909c7ba132cdf2 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Mon, 12 Feb 2024 15:43:23 +0100 Subject: [PATCH] tests/riotboot_flashwrite: make use of nanocoap_resources --- tests/riotboot_flashwrite/Makefile | 1 + tests/riotboot_flashwrite/coap_handler.c | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/riotboot_flashwrite/Makefile b/tests/riotboot_flashwrite/Makefile index 739f759942b4..9c2b9f4ba52b 100644 --- a/tests/riotboot_flashwrite/Makefile +++ b/tests/riotboot_flashwrite/Makefile @@ -13,6 +13,7 @@ USEMODULE += gnrc_icmpv6_echo # Required for nanocoap server USEMODULE += nanocoap_sock +USEMODULE += nanocoap_resources # include this for printing IP addresses USEMODULE += shell_cmds_default diff --git a/tests/riotboot_flashwrite/coap_handler.c b/tests/riotboot_flashwrite/coap_handler.c index 4a892e10c703..12a09de83916 100644 --- a/tests/riotboot_flashwrite/coap_handler.c +++ b/tests/riotboot_flashwrite/coap_handler.c @@ -78,10 +78,9 @@ ssize_t _flashwrite_handler(coap_pkt_t* pkt, uint8_t *buf, size_t len, coap_requ return pkt_pos - (uint8_t*)pkt->hdr; } -/* must be sorted by path (ASCII order) */ -const coap_resource_t coap_resources[] = { - COAP_WELL_KNOWN_CORE_DEFAULT_HANDLER, - { "/flashwrite", COAP_POST, _flashwrite_handler, &_writer }, +NANOCOAP_RESOURCE(flashwrite) { + .path = "/flashwrite", + .methods = COAP_POST, + .handler = _flashwrite_handler, + .context = &_writer }; - -const unsigned coap_resources_numof = ARRAY_SIZE(coap_resources);