1COAP-CLIENT(5)                coap-client Manual                COAP-CLIENT(5)
2
3
4

NAME

6       coap-client - CoAP Client based on libcoap
7

SYNOPSIS

9       coap-client [-a addr] [-b [num,]size] [-e text] [-f file] [-l loss] [-m
10       method] [-o file] [-p port] [-r] [-s duration] [-t type] [-v num] [-A
11       type] [-B seconds] [-K interval] [-N] [-O num,text] [-P addr[:port]]
12       [-T token] [-U] [[-k key] [-u user]] [[-c certfile] [-C cafile] [-R
13       root_cafile]] URI
14

DESCRIPTION

16       coap-client is a CoAP client to communicate with 6LoWPAN devices via
17       the protocol CoAP (RFC 7252) using the URI given as argument on the
18       command line. The URI must have the scheme coap, coap+tcp, coaps or
19       coaps+tcp. coaps and coaps+tcp are only supported when coap-client is
20       built with support for secure (D)TLS communication.
21
22       If coaps or coap+tcp is being used, provided the CoAP server supports
23       PKI and is configured with a Certificate and Private Key, the
24       coap-client does not need to have a Pre-Shared Key (-k) or Certificate
25       (-c) configured.
26
27       The URI’s host part may be a DNS name or a literal IP address. Note
28       that, for IPv6 address references, angle brackets are required (c.f.
29       EXAMPLES).
30

OPTIONS - GENERAL

32       -a addr
33           The local address of the interface that has to be used.
34
35       -b [num,]size
36           The block size to be used in GET/PUT/POST requests (value must be a
37           multiple of 16 not larger than 1024 as libcoap uses a fixed maximum
38           PDU size of 1400 bytes). If num is present, the request chain will
39           start at block num. When the server includes a Block2 option in its
40           response to a GET request, coap-client will automatically retrieve
41           the subsequent block from the server until there are no more
42           outstanding blocks for the requested content.
43
44       -e text
45           Include text as payload (use percent-encoding for non-ASCII
46           characters).
47
48       -f file
49           File to send with PUT/POST (use - for STDIN).
50
51       -l list
52           Fail to send some datagrams specified by a comma separated list of
53           numbers or number ranges (debugging only).
54
55       -l loss%
56           Randomly failed to send datagams with the specified probability -
57           100% all datagrams, 0% no datagrams (debugging only).
58
59       -m method
60           The request method for action (get|put|post|delete), default is
61           get. (Note that the string passed to -m is compared
62           case-insensitive.)
63
64       -o file
65           A filename to store data retrieved with GET.
66
67       -p port
68           The port to listen on.
69
70       -r
71           Use reliable protocol (TCP or TLS).
72
73       -s duration
74           Subscribe to / observe the resource specified by URI for the given
75           duration in seconds.
76
77       -t type
78           Content format for given resource for PUT/POST.  type must be
79           either a numeric value reflecting a valid CoAP content format or a
80           string describing a registered format. The following registered
81           content format descriptors are supported, with alternative
82           shortcuts given in parentheses:
83
84               text/plain (plain)
85               application/link-format (link, link-format)
86               application/xml (xml)
87               application/octet-stream (binary, octet-stream)
88               application/exi (exi)
89               application/json (json)
90               application/cbor (cbor)
91
92       -v num
93           The verbosity level to use (default 3, maximum is 9). Above 7,
94           there is increased verbosity in GnuTLS logging.
95
96       -A type
97           Accepted media type.  type must be either a numeric value
98           reflecting a valid CoAP content format or a string that specifies a
99           registered format as described for option -t.
100
101       -B seconds
102           Break operation after waiting given seconds (default is 90).
103
104       -K interval
105           Send a ping after interval seconds of inactivity (TCP only). If not
106           specified, keep-alive is disabled (default).
107
108       -N
109           Send NON-confirmable message. If option -N is not specified, a
110           confirmable message will be sent.
111
112       -O num,text
113           Add option num with contents of text to the request.
114
115       -P addr[:port]
116           Address (and port) for proxy to use (automatically adds Proxy-Uri
117           option to request).
118
119       -T token
120           Include the token to the request.
121
122       -U
123           Never include Uri-Host or Uri-Port options.
124

OPTIONS - PSK

126       (If supported by underlying (D)TLS library)
127
128       -k key
129           Pre-shared key for the specified user (-u option also required).
130
131       -u user
132           User identity for pre-shared key mode (-k option also required).
133

OPTIONS - PKI

135       (If supported by underlying (D)TLS library)
136
137       -c certfile
138           Use the specified PEM file which contains the CERTIFICATE and
139           PRIVATE KEY information.
140
141       -C cafile
142           PEM file containing the CA Certificate that was used to sign the
143           certfile defined using -c certfile. This will trigger the
144           validation of the server certificate. If certfile is self-signed
145           (as defined by -c certfile), then you need to have on the command
146           line the same filename for both the certfile and cafile (as in -c
147           certfile -C certfile) to trigger validation.
148
149       -R root_cafile
150           PEM file containing the set of trusted root CAs that are to be used
151           to validate the server certificate. The -C cafile does not have to
152           be in this list and is "trusted" for the verification.
153           Alternatively, this can point to a directory containing a set of CA
154           PEM files.
155

EXAMPLES

157       ·   Example
158
159           coap-client coap://coap.me
160
161       Query the resource / from server coap.me (using the GET method).
162
163       ·   Example
164
165           coap-client -m get coap://[::1]/
166
167       Query the resource / on localhost using the GET method to get back the
168       summary defined attributes.
169
170       ·   Example
171
172           coap-client -m get coap://[::1]/.well-known/core
173
174       Query on the resource .well-known/core on localhost to get back a list
175       of the known resources along with their attribute definitions.
176
177       ·   Example
178
179           echo -n "mode=on" | coap-client -m put \
180           coap://[2001:db8:c001:f00d:221:2eff:ff00:2704]:5683/actuators/leds?color=r -f-
181
182       Send text mode=on to resource actuators/leds?color=r on the endpoint
183       with address 2001:db8:c001:f00d:221:2eff:ff00:2704 and port 5683. Note
184       that the port 5683 is the default port and isn’t actually required in
185       this instance.
186
187       ·   Example
188
189           coap-client -m put coap://[fec0::3]/ck -T 3a -t binary -f to_upload
190
191       Put the contents of file to_upload with content type binary (i.e.
192       application/octet-stream) into resource ck on fec0::3 using a token of
193       3a via the PUT method.
194

FILES

196       There are no configuration files.
197

EXIT STATUS

199       0
200           Success
201
202       1
203           Failure (syntax or usage error; configuration error; document
204           processing failure; unexpected error)
205

BUGS

207       Please report bugs on the mailing list for libcoap:
208       libcoap-developers@lists.sourceforge.net
209

AUTHORS

211       The libcoap project <libcoap-developers@lists.sourceforge.net>
212
213
214
215coap-client 4.2.0                 07/25/2019                    COAP-CLIENT(5)
Impressum