2525
2626#include "net/coap.h"
2727#include "net/gnrc/netif.h"
28- #include "net/ipv6.h"
2928#include "net/nanocoap.h"
3029#include "net/nanocoap_sock.h"
31- #include "net/sock/udp.h"
3230#include "net/sock/util.h"
33-
3431#include "od.h"
32+ #include "shell.h"
3533
36- static ssize_t _send (coap_pkt_t * pkt , size_t len , char * addr_str , char * port_str )
34+ static ssize_t _send (coap_pkt_t * pkt , size_t len ,
35+ char * addr_str , const char * port_str )
3736{
3837 ipv6_addr_t addr ;
3938 sock_udp_ep_t remote ;
@@ -81,7 +80,7 @@ static ssize_t _send(coap_pkt_t *pkt, size_t len, char *addr_str, char *port_str
8180 return nanocoap_request (pkt , NULL , & remote , len );
8281}
8382
84- int nanotest_client_cmd (int argc , char * * argv )
83+ static int _cmd_client (int argc , char * * argv )
8584{
8685 /* Ordered like the RFC method code numbers, but off by 1. GET is code 0. */
8786 const char * method_codes [] = {"get" , "post" , "put" };
@@ -166,7 +165,10 @@ int nanotest_client_cmd(int argc, char **argv)
166165 return 1 ;
167166}
168167
169- static int _blockwise_cb (void * arg , size_t offset , uint8_t * buf , size_t len , int more )
168+ SHELL_COMMAND (client , "CoAP client" , _cmd_client );
169+
170+ static int _blockwise_cb (void * arg , size_t offset , uint8_t * buf ,
171+ size_t len , int more )
170172{
171173 (void )arg ;
172174 (void )more ;
@@ -180,7 +182,7 @@ static int _blockwise_cb(void *arg, size_t offset, uint8_t *buf, size_t len, int
180182 return 0 ;
181183}
182184
183- int nanotest_client_url_cmd (int argc , char * * argv )
185+ static int _cmd_url (int argc , char * * argv )
184186{
185187 /* Ordered like the RFC method code numbers, but off by 1. GET is code 0. */
186188 const char * method_codes [] = { "get" , "post" , "put" , "delete" };
@@ -248,6 +250,8 @@ int nanotest_client_url_cmd(int argc, char **argv)
248250 return -1 ;
249251}
250252
253+ SHELL_COMMAND (url , "CoAP client URL request" , _cmd_url );
254+
251255static const char song [] =
252256 "Join us now and share the software;\n"
253257 "You'll be free, hackers, you'll be free.\n"
@@ -269,7 +273,7 @@ static const char song[] =
269273 "Join us now and share the software;\n"
270274 "You'll be free, hackers, you'll be free.\n" ;
271275
272- int nanotest_client_put_cmd (int argc , char * * argv )
276+ static int _cmd_put (int argc , char * * argv )
273277{
274278 int res ;
275279 nanocoap_sock_t sock ;
@@ -304,7 +308,9 @@ int nanotest_client_put_cmd(int argc, char **argv)
304308 return res ;
305309}
306310
307- int nanotest_client_put_non_cmd (int argc , char * * argv )
311+ SHELL_COMMAND (put , "experimental put" , _cmd_put );
312+
313+ static int _cmd_put_non (int argc , char * * argv )
308314{
309315 int res ;
310316
@@ -323,7 +329,9 @@ int nanotest_client_put_non_cmd(int argc, char **argv)
323329 return res ;
324330}
325331
326- int nanotest_client_get_non_cmd (int argc , char * * argv )
332+ SHELL_COMMAND (put_non , "non-confirmable put" , _cmd_put_non );
333+
334+ static int _cmd_get_non (int argc , char * * argv )
327335{
328336 int res ;
329337
@@ -348,3 +356,5 @@ int nanotest_client_get_non_cmd(int argc, char **argv)
348356 }
349357 return res ;
350358}
359+
360+ SHELL_COMMAND (get_non , "non-confirmable get" , _cmd_get_non );
0 commit comments