1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/examples/gcoap
Marian Buschsieweke 82d98ed377
examples, tests: update Makefile.ci for AVR8
Ran dist/tools/insufficient_memory for all AVR8 boards.
2023-12-01 19:37:05 +01:00
..
client.c examples/gcoap: Fix shell parameter validation 2023-01-15 22:20:39 +01:00
gcoap_example.h examples/gcoap: split client and server implementation 2022-01-04 19:04:46 +01:00
main.c examples/gcoap: split client and server implementation 2022-01-04 19:04:46 +01:00
Makefile examples/gcoap: add IPv4 support 2022-10-18 10:59:43 +02:00
Makefile.ci examples, tests: update Makefile.ci for AVR8 2023-12-01 19:37:05 +01:00
Makefile.slip examples,tests: replace deprecated module names by new names 2022-09-16 13:15:46 +02:00
README-slip.md doc: replace ping6 with ping 2021-11-29 17:32:37 +01:00
README.md treewide: replace remaining occurrences of tests/pkg_* 2023-05-06 07:55:03 +02:00
server.c gcoap: make use of coap_request_ctx_t 2022-07-17 14:29:39 +02:00

About

This application provides command line access to gcoap, a high-level API for CoAP messaging. See the CoAP spec for background, and the Modules>Networking>CoAP topic in the source documentation for detailed usage instructions and implementation notes.

We support two setup options for this example:

Native networking

Build with the standard Makefile. Follow the setup instructions for the gnrc_networking example.

SLIP-based border router

Build with Makefile.slip. Follow the setup instructions in README-slip.md, which are based on the SLIP instructions for the gnrc_border_router example. We also plan to provide or reference the ethos/UHCP instructions, but we don't have it working yet.

Example Use

This example uses gcoap as a server on RIOT native. Then we send a request from a libcoap example client on the Linux host.

Verify setup from RIOT terminal

> coap info

Expected response:

CoAP server is listening on port 5683
 CLI requests sent: 0
CoAP open requests: 0

Query from libcoap example client

gcoap does not provide any output to the CoAP terminal when it handles a request. We recommend use of Wireshark to see the request and response. You also can add some debug output in the endpoint function callback.

./coap-client -N -m get -p 5683 coap://[fe80::1843:8eff:fe40:4eaa%tap0]/.well-known/core

Example response:

v:1 t:NON c:GET i:0daa {} [ ]
</cli/stats>

The response shows the endpoint registered by the gcoap CLI example.

Send query to libcoap example server

Start the libcoap example server with the command below.

./coap-server


Below are some example queries to enter into the RIOT CLI. Ports can be omitted. The port defaults to 5683 for the gcoap and to 5684 for the gcoap_dtls example.

  • For IPv6 setup (network interface can be omitted)

    coap get [fe80::d8b8:65ff:feee:121b%6]:5683 /.well-known/core

  • For IPv4 setup

    coap get 192.168.2.135:5683 /.well-known/core

  • When including the module sock_dns for domain resolution

    coap get example.com:5683 /.well-known/core

CLI output:

gcoap_cli: sending msg ID 743, 75 bytes
> gcoap: response Success, code 2.05, 105 bytes
</>;title="General Info";ct=0,</time>;if="clock";rt="Ticks";title="Internal Clock";ct=0;obs,</async>;ct=0

Other available CoAP implementations and applications

RIOT also provides package imports and test applications for other CoAP implementations: