Skip to content

Commit

Permalink
tests/pkg/edhoc_c: make use of nanocoap_server_auto_init
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Feb 12, 2024
1 parent d02d194 commit 49f51e4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 28 deletions.
7 changes: 6 additions & 1 deletion tests/pkg/edhoc_c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
27 changes: 0 additions & 27 deletions tests/pkg/edhoc_c/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 49f51e4

Please sign in to comment.