Loading...
Searching...
No Matches

Use Uniform Resource Identifiers (URIs) to address remote CoAP resources. More...

Detailed Description

Use Uniform Resource Identifiers (URIs) to address remote CoAP resources.

Module. Specify USEMODULE += unicoap_client_uri in your application's Makefile.

You do not need to import a CoAP driver to use the CoAP URI parser. The path, host, and URI queries will automatically be added as CoAP options to the request. IPv4 and IPv6 address literals are supported. Zone identifiers are supported too.

unicoap_destination_t = unicoap_destination_uri("coap://[2008:db8::1]/foo/bar?a=1&b=2");
A type abstracting over CoAP resource identifiers.
Definition transport.h:421

DNS

To be able to use the Domain Name System (DNS) to resolve names such as example.org with the client API, import RIOT's DNS module (and a DNS implementation).

For example, to send a request to the unicoap_destination_t unicoap_destination_uri("coap://example.org/foo/bar"), import dns and, e.g., sock_dns.

USEMODULE += dns
USEMODULE += sock_dns

Manually parsing a CoAP URI

int unicoap_uri_populate (uri_parser_result_t *parsed, unicoap_endpoint_t *endpoint, unicoap_options_t *options)
 Populates endpoint and CoAP options with URI parser result.
 

Function Documentation

◆ unicoap_uri_populate()

int unicoap_uri_populate ( uri_parser_result_t * parsed,
unicoap_endpoint_t * endpoint,
unicoap_options_t * options )

Populates endpoint and CoAP options with URI parser result.

Parameters
[in,out]parsedParser result (port will be set based on scheme, if unspecified)
[in,out]endpointPre-allocated endpoint
[in,out]optionsPre-initialized options (nullable). If NULL, no options will be extracted from URI
Returns
0 on success
-1 or negative errno on error