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 and OpenSSL 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. If not specified
106           (or 0), 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. If the text
114           begins with 0x, then the hex text is converted to binary data.
115
116       -P addr[:port]
117           Address (and port) for proxy to use (automatically adds Proxy-Uri
118           option to request).
119
120       -T token
121           Include the token to the request.
122
123       -U
124           Never include Uri-Host or Uri-Port options.
125

OPTIONS - PSK

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

OPTIONS - PKI

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

EXAMPLES

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

FILES

197       There are no configuration files.
198

EXIT STATUS

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

BUGS

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

AUTHORS

212       The libcoap project <libcoap-developers@lists.sourceforge.net>
213
214
215
216coap-client 4.2.1                 07/28/2020                    COAP-CLIENT(5)
Impressum