1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #20374 from benpicco/coap_resources_numof-remove

always use nanocoap_resources instead of manually assembling coap_resources[]
This commit is contained in:
benpicco 2024-02-12 16:00:34 +00:00 committed by GitHub
commit 597b2ad907
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 13 additions and 20 deletions

View File

@ -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

View File

@ -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;

View File

@ -26,6 +26,7 @@ USEMODULE += sock_udp
# Additional networking modules that can be dropped if not needed
USEMODULE += gnrc_icmpv6_echo
USEMODULE += nanocoap_sock
USEMODULE += nanocoap_resources
# include this for printing IP addresses
USEMODULE += shell_cmds_default

View File

@ -98,14 +98,10 @@ ssize_t _edhoc_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len, coap_request_c
return msg_len;
}
/* must be sorted by path (ASCII order) */
const coap_resource_t coap_resources[] = {
COAP_WELL_KNOWN_CORE_DEFAULT_HANDLER,
{ "/.well-known/edhoc", COAP_POST, _edhoc_handler, NULL },
NANOCOAP_RESOURCE(edhoc) {
.path = "/.well-known/edhoc", .methods = COAP_POST, .handler = _edhoc_handler
};
const unsigned coap_resources_numof = ARRAY_SIZE(coap_resources);
int responder_cmd(int argc, char **argv)
{
if (argc < 2) {

View File

@ -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

View File

@ -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);