Skip to content

Commit

Permalink
examples/nanocoap_server: define CoAP resources as XFA
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Feb 22, 2023
1 parent 11bf7d7 commit 09f471d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
1 change: 1 addition & 0 deletions examples/nanocoap_server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ USEMODULE += sock_udp
USEMODULE += gnrc_icmpv6_echo

USEMODULE += nanocoap_sock
USEMODULE += nanocoap_server

USEMODULE += xtimer

Expand Down
16 changes: 5 additions & 11 deletions examples/nanocoap_server/coap_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,8 @@ ssize_t _sha256_handler(coap_pkt_t* pkt, uint8_t *buf, size_t len, coap_request_
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,
{ "/echo/", COAP_GET | COAP_MATCH_SUBTREE, _echo_handler, NULL },
{ "/riot/board", COAP_GET, _riot_board_handler, NULL },
{ "/riot/value", COAP_GET | COAP_PUT | COAP_POST, _riot_value_handler, NULL },
{ "/riot/ver", COAP_GET, _riot_block2_handler, NULL },
{ "/sha256", COAP_POST, _sha256_handler, NULL },
};

const unsigned coap_resources_numof = ARRAY_SIZE(coap_resources);
NANOCOAP_RESOURCE(echo) { "/echo/", COAP_GET | COAP_MATCH_SUBTREE, _echo_handler, NULL };
NANOCOAP_RESOURCE(board) { "/riot/board", COAP_GET, _riot_board_handler, NULL };
NANOCOAP_RESOURCE(value) { "/riot/value", COAP_GET | COAP_PUT | COAP_POST, _riot_value_handler, NULL };
NANOCOAP_RESOURCE(ver) { "/riot/ver", COAP_GET, _riot_block2_handler, NULL };
NANOCOAP_RESOURCE(sha256) { "/sha256", COAP_POST, _sha256_handler, NULL };

0 comments on commit 09f471d

Please sign in to comment.