table of contents
COAP-CLIENT(5) | coap-client Manual | COAP-CLIENT(5) |
NAME¶
coap-client, coap-client-gnutls, coap-client-mbedtls, coap-client-openssl, coap-client-notls - CoAP Client based on libcoap
SYNOPSIS¶
coap-client [-a addr] [-b [num,]size] [-e text] [-f file] [-l loss] [-m method] [-o file] [-p port] [-r] [-s duration] [-t type] [-v num] [-w] [-A type] [-B seconds] [-E oscore_conf_file[,seq_file]] [-G count] [-H hoplimit] [-K interval] [-L value] [-N] [-O num,text] [-P scheme://addr[:port]] [-T token] [-U] [-V num] [-X size] [[-h match_hint_file] [-k key] [-u user]] [[-c certfile] [-j keyfile] [-n] [-C cafile] [-J pkcs11_pin] [-M rpk_file] [-R trust_casfile]] URI
For coap-client versions that use libcoap compiled for different (D)TLS libraries, coap-client-notls, coap-client-gnutls, coap-client-openssl, coap-client-mbedtls or coap-client-tinydtls may be available. Otherwise, coap-client uses the default libcoap (D)TLS support.
DESCRIPTION¶
coap-client is a CoAP client to communicate with 6LoWPAN devices via the protocol CoAP (RFC 7252) using the URI given as argument on the command line. The URI must have the scheme coap, coap+tcp, coaps or coaps+tcp.
coaps and coaps+tcp are only supported when coap-client is built with support for secure (D)TLS communication.
If coaps or coaps+tcp is being used, provided the CoAP server supports PKI and is configured with a certificate and private key, the coap-client does not need to have a Pre-Shared Key (-k) or certificate (-c) configured.
The URI’s host part may be a DNS name, a literal IP address or a Unix domain name. For Unix domain names, %2F is used as the / separator to differentiate between the host and patch definitions. For IPv6 address references, angle brackets are required (c.f. EXAMPLES) to delimit the host portion of the URI.
OPTIONS - GENERAL¶
-a addr
Note: Do not use this option if the interface is likely to be transient - i.e. it is a tunnel interface that may come and go, as this is likely to cause "No such device" errors on transmission.
-b [num,]size
-e text
-f file
-l list
-l loss%
-m method
-o file
-p port
-r
-s duration
-t type
text/plain (plain) application/link-format (link, link-format) application/xml (xml) application/octet-stream (binary, octet-stream) application/exi (exi) application/json (json) application/cbor (cbor)
-v num
-w
-A type
-B seconds
-E oscore_conf_file[,seq_file]
-G count
-H hoplimit
-K interval
-L value
COAP_BLOCK_USE_LIBCOAP 1 COAP_BLOCK_SINGLE_BODY 2 COAP_BLOCK_TRY_Q_BLOCK 4 COAP_BLOCK_USE_M_Q_BLOCK 8 COAP_BLOCK_NO_PREEMPTIVE_RTAG 16
-N
-O num,text
-P scheme://addr[:port]
-T token
-U
-V num
-X size
OPTIONS - PSK¶
(If supported by underlying (D)TLS library)
-h match_hint_file
hint_to_match,use_user,with_key
A line that starts with # is treated as a comment.
Note: -k key and -u user still need to be defined for the default case in case there is no match.
-k key
-u user
OPTIONS - PKI¶
(If supported by underlying (D)TLS library)
Note: If any one of certfile, keyfile or cafile is in PKCS11 URI naming format (pkcs11: prefix), then any remaining non PKCS11 URI file definitions have to be in DER, not PEM, format. Otherwise all of certfile, keyfile or cafile are in PEM format.
-c certfile
-j keyfile
-n
-C cafile
-J pkcs11_pin
-M rpk_file
-R trust_casfile
EXAMPLES¶
coap-client coap://libcoap.net
Query the resource / from server libcoap.net (using the GET method).
coap-client -m get coap://[::1]/
Query the resource / on localhost using the GET method to get back the summary information.
coap-client -m get coap://%2Fsome%2Funix%2Fdomain%2Fpath/time
Query the resource /time on server listening on datagram Unix domain /some/unix/domain/path using the GET method to get back the current time. The %2F is the hex encoding for / and indicates which is the host definition separator and the simple / is for the path definition separator.
coap-client -m get coap://[::1]/.well-known/core
Query on the resource .well-known/core on localhost to get back a list of the known resources along with their attribute definitions.
echo -n "mode=on" | coap-client -m put \ coap://[2001:db8:c001:f00d:221:2eff:ff00:2704]:5683/actuators/leds?color=r -f-
Send text mode=on to resource actuators/leds?color=r on the endpoint with address 2001:db8:c001:f00d:221:2eff:ff00:2704 and port 5683. Note that the port 5683 is the default port and isn’t actually required in this instance.
coap-client -m put coap://[fec0::3]/ck -T 3a -t binary -f to_upload
Put the contents of file to_upload with content type binary (i.e. application/octet-stream) into resource ck on fec0::3 using a token of 3a via the PUT method.
FILES¶
There are no configuration files.
EXIT STATUS¶
0
1
SEE ALSO¶
BUGS¶
Please report bugs on the mailing list for libcoap: libcoap-developers@lists.sourceforge.net or raise an issue on GitHub at https://github.com/obgm/libcoap/issues
AUTHORS¶
The libcoap project <libcoap-developers@lists.sourceforge.net>
04/07/2024 | coap-client 4.3.4 |