Skip to content

Commit

Permalink
tests/nanocoap_cli: add test for no-response
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Sep 28, 2022
1 parent 2be16d9 commit 6118ab5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/nanocoap_cli/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ extern int nanotest_client_cmd(int argc, char **argv);
extern int nanotest_client_url_cmd(int argc, char **argv);
extern int nanotest_server_cmd(int argc, char **argv);
extern int nanotest_client_put_cmd(int argc, char **argv);
extern int nanotest_client_put_non_cmd(int argc, char **argv);
static int _list_all_inet6(int argc, char **argv);

static const shell_command_t shell_commands[] = {
{ "client", "CoAP client", nanotest_client_cmd },
{ "url", "CoAP client URL request", nanotest_client_url_cmd },
{ "put", "experimental put", nanotest_client_put_cmd },
{ "put_non", "non-confirmable put", nanotest_client_put_non_cmd },
{ "server", "CoAP server", nanotest_server_cmd },
{ "inet6", "IPv6 addresses", _list_all_inet6 },
{ NULL, NULL, NULL }
Expand Down
19 changes: 19 additions & 0 deletions tests/nanocoap_cli/nanocli_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,22 @@ int nanotest_client_put_cmd(int argc, char **argv)
nanocoap_block_request_done(&ctx);
return res;
}

int nanotest_client_put_non_cmd(int argc, char **argv)
{
int res;

if (argc < 3) {
printf("usage: %s <url> <data>\n", argv[0]);
return 1;
}

nanocoap_sock_t sock;
nanocoap_sock_url_connect(argv[1], &sock);

res = nanocoap_sock_put_non(&sock, sock_urlpath(argv[1]), argv[2], strlen(argv[2]),
NULL, 0);
nanocoap_sock_close(&sock);

return res;
}

0 comments on commit 6118ab5

Please sign in to comment.