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

tests/pkg/edhoc_c: make use of nanocoap_server_auto_init

This commit is contained in:
Benjamin Valentin 2024-02-12 18:18:10 +01:00
parent d02d194c85
commit 49f51e4706
2 changed files with 6 additions and 28 deletions

View File

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

View File

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