From 49f51e4706141ccce737017b13861fb9603d395f Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Mon, 12 Feb 2024 18:18:10 +0100 Subject: [PATCH] tests/pkg/edhoc_c: make use of nanocoap_server_auto_init --- tests/pkg/edhoc_c/Makefile | 7 ++++++- tests/pkg/edhoc_c/main.c | 27 --------------------------- 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/tests/pkg/edhoc_c/Makefile b/tests/pkg/edhoc_c/Makefile index 901f28c92def..b2aed7a210b4 100644 --- a/tests/pkg/edhoc_c/Makefile +++ b/tests/pkg/edhoc_c/Makefile @@ -26,7 +26,6 @@ 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 @@ -44,5 +43,11 @@ CFLAGS += -DCONFIG_INITIATOR=$(CONFIG_INITIATOR) CONFIG_RESPONDER ?= 1 CFLAGS += -DCONFIG_RESPONDER=$(CONFIG_RESPONDER) + +ifeq (1, $(CONFIG_RESPONDER)) + USEMODULE += nanocoap_server_auto_init + CFLAGS += -DCONFIG_NANOCOAP_SERVER_BUF_SIZE=512 +endif + include $(RIOTBASE)/Makefile.include include $(RIOTMAKE)/default-radio-settings.inc.mk diff --git a/tests/pkg/edhoc_c/main.c b/tests/pkg/edhoc_c/main.c index fa478b43bbae..a87583a6e1c6 100644 --- a/tests/pkg/edhoc_c/main.c +++ b/tests/pkg/edhoc_c/main.c @@ -30,10 +30,6 @@ static msg_t _main_msg_queue[MAIN_QUEUE_SIZE]; #if IS_ACTIVE(CONFIG_RESPONDER) -static char _nanocoap_server_stack[THREAD_STACKSIZE_MAIN]; -#define NANOCOAP_SERVER_QUEUE_SIZE (4) -static msg_t _nanocoap_server_msg_queue[NANOCOAP_SERVER_QUEUE_SIZE]; -#define NANOCOAP_BUF_SIZE (512U) extern int responder_cli_init(void); extern int responder_cmd(int argc, char **argv); #endif @@ -54,23 +50,6 @@ static const shell_command_t shell_commands[] = { { NULL, NULL, NULL } }; -#if IS_ACTIVE(CONFIG_RESPONDER) -static void *_nanocoap_server_thread(void *arg) -{ - (void)arg; - - /* nanocoap_server uses gnrc sock which uses gnrc which needs a msg queue */ - msg_init_queue(_nanocoap_server_msg_queue, NANOCOAP_SERVER_QUEUE_SIZE); - - /* initialize nanocoap server instance */ - uint8_t buf[NANOCOAP_BUF_SIZE]; - sock_udp_ep_t local = { .port = COAP_PORT, .family = AF_INET6 }; - nanocoap_server(&local, buf, sizeof(buf)); - - return NULL; -} -#endif - int main(void) { #if IS_ACTIVE(CONFIG_INITIATOR) @@ -82,12 +61,6 @@ int main(void) if (responder_cli_init()) { return -1; } - - /* start nanocoap server thread */ - thread_create(_nanocoap_server_stack, sizeof(_nanocoap_server_stack), - THREAD_PRIORITY_MAIN - 1, - THREAD_CREATE_STACKTEST, - _nanocoap_server_thread, NULL, "nanocoap server"); #endif /* the shell contains commands that receive packets via GNRC and thus