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

examples/nanocoap_server: enable fileserver for large boards

This commit is contained in:
Benjamin Valentin 2023-02-23 00:30:34 +01:00 committed by Benjamin Valentin
parent cc30b819eb
commit 88789454dd
2 changed files with 38 additions and 1 deletions

View File

@ -18,7 +18,7 @@ USEMODULE += sock_udp
USEMODULE += gnrc_icmpv6_echo
USEMODULE += nanocoap_sock
USEMODULE += nanocoap_server
USEMODULE += nanocoap_resources
USEMODULE += xtimer
@ -43,6 +43,23 @@ ifneq (,$(filter $(BOARD),$(LOW_MEMORY_BOARDS)))
USEMODULE += prng_minstd
endif
# Enable fileserver for boards with plenty of memory
HIGH_MEMORY_BOARDS := native same54-xpro mcb2388
ifneq (,$(filter $(BOARD),$(HIGH_MEMORY_BOARDS)))
USEMODULE += gcoap_fileserver
USEMODULE += vfs_default
# we don't want to run GCoAP
CFLAGS += -DCONFIG_GCOAP_NO_AUTO_INIT=1
CFLAGS += -DCONFIG_NANOCOAP_SERVER_WELL_KNOWN_CORE=1
# always enable auto-format for native
ifeq ($(BOARD),native)
USEMODULE += vfs_auto_format
endif
endif
# Change this to 0 show compiler invocation lines by default:
QUIET ?= 1

View File

@ -181,3 +181,23 @@ NANOCOAP_RESOURCE(ver) {
NANOCOAP_RESOURCE(sha256) {
.path = "/sha256", .methods = COAP_POST, .handler = _sha256_handler
};
/* we can also include the fileserver module */
#ifdef MODULE_GCOAP_FILESERVER
#include "net/gcoap/fileserver.h"
#include "vfs_default.h"
NANOCOAP_RESOURCE(fileserver) {
.path = "/vfs",
.methods = COAP_GET
#if IS_USED(MODULE_GCOAP_FILESERVER_PUT)
| COAP_PUT
#endif
#if IS_USED(MODULE_GCOAP_FILESERVER_DELETE)
| COAP_DELETE
#endif
| COAP_MATCH_SUBTREE,
.handler = gcoap_fileserver_handler,
.context = VFS_DEFAULT_DATA
};
#endif