Skip to content

Commit

Permalink
examples/gcoap: Added special lines for GDTLS
Browse files Browse the repository at this point in the history
  • Loading branch information
rfuentess committed Jun 13, 2017
1 parent e9ed85b commit db086dd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/gcoap/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ USEMODULE += ps
# development process:
CFLAGS += -DDEVELHELP

# Enable this line for making use of (tiny)DTLS.
# NOTE: This also changes the default port to 20220 (DTLS default port)
# WARNING: The BOARD_BLACKLIST of examples/dtls-echo must be considered.
# USEMODULE += gnrc_dtls

# Change this to 0 show compiler invocation lines by default:
QUIET ?= 1

Expand Down
24 changes: 24 additions & 0 deletions examples/gcoap/gcoap_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,30 @@ static size_t _send(uint8_t *buf, size_t len, char *addr_str, char *port_str)
return bytes_sent;
}

#ifdef MODULE_GNRC_DTLS
int dtlsc_cli_cmd(int argc, char **argv)
{
(void) argc;
(void) argv;

/* TODO: Adding renegotiate [and start?] */
if (argc < 2) {
printf("usage: %s dtlsc [stop]\n", argv[0]);
return 0;
}

if (strcmp(argv[1], "stop") == 0) {
gcoap_end_dtls_session();
}
else {
printf("usage: %s dtlsc [stop]\n", argv[0]);
return 0;
}

return 1;
}
#endif

int gcoap_cli_cmd(int argc, char **argv)
{
/* Ordered like the RFC method code numbers, but off by 1. GET is code 0. */
Expand Down
7 changes: 7 additions & 0 deletions examples/gcoap/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@ static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];
extern int gcoap_cli_cmd(int argc, char **argv);
extern void gcoap_cli_init(void);

#ifdef MODULE_GNRC_DTLS
extern int dtlsc_cli_cmd(int argc, char **argv);
#endif

static const shell_command_t shell_commands[] = {
{ "coap", "CoAP example", gcoap_cli_cmd },
#ifdef MODULE_GNRC_DTLS
{ "dtlsc", "DTLS Client operators", dtlsc_cli_cmd },
#endif
{ NULL, NULL, NULL }
};

Expand Down

0 comments on commit db086dd

Please sign in to comment.