From 29cb2d05a3b76173a52eda9edb0d89e94d0ea00e Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Wed, 28 Sep 2022 12:16:54 +0200 Subject: [PATCH] tests/nanocoap_cli: add test for no-response --- tests/nanocoap_cli/main.c | 2 ++ tests/nanocoap_cli/nanocli_client.c | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/tests/nanocoap_cli/main.c b/tests/nanocoap_cli/main.c index 66cdab023d..1d73012339 100644 --- a/tests/nanocoap_cli/main.c +++ b/tests/nanocoap_cli/main.c @@ -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 } diff --git a/tests/nanocoap_cli/nanocli_client.c b/tests/nanocoap_cli/nanocli_client.c index 6d0161029d..7cf40ffcab 100644 --- a/tests/nanocoap_cli/nanocli_client.c +++ b/tests/nanocoap_cli/nanocli_client.c @@ -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 \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; +}