|
| 1 | +## About |
| 2 | + |
| 3 | +This application provides command line access to gcoap, a high-level API for |
| 4 | +CoAP messaging. See the [CoAP spec][1] for background, and the |
| 5 | +Modules>Networking>CoAP topic in the source documentation for detailed usage |
| 6 | +instructions and implementation notes. |
| 7 | + |
| 8 | +We support two setup options for this example: |
| 9 | + |
| 10 | +### Native networking |
| 11 | + |
| 12 | +Build with the standard `Makefile`. Follow the setup [instructions][2] for |
| 13 | +the gnrc_networking example. |
| 14 | + |
| 15 | +### SLIP-based border router |
| 16 | + |
| 17 | +Build with `Makefile.slip`. Follow the setup instructions in README-slip.md, |
| 18 | +which are based on the [SLIP instructions][3] for the gnrc_border_router |
| 19 | +example. We also plan to provide or reference the ethos/UHCP instructions, |
| 20 | +but we don't have it working yet. |
| 21 | + |
| 22 | + |
| 23 | +## Example Use |
| 24 | + |
| 25 | +This example uses gcoap as a server on RIOT native. Then we send a request |
| 26 | +from a libcoap example client on the Linux host. |
| 27 | + |
| 28 | +### Verify setup from RIOT terminal |
| 29 | + |
| 30 | + > coap info |
| 31 | + |
| 32 | +Expected response: |
| 33 | + |
| 34 | + CoAP server is listening on port 5683 |
| 35 | + CLI requests sent: 0 |
| 36 | + CoAP open requests: 0 |
| 37 | + |
| 38 | +### Query from libcoap example client |
| 39 | + |
| 40 | +gcoap does not provide any output to the CoAP terminal when it handles a |
| 41 | +request. We recommend use of Wireshark to see the request and response. You |
| 42 | +also can add some debug output in the endpoint function callback. |
| 43 | + |
| 44 | + ./coap-client -N -m get -p 5683 coap://[fe80::1843:8eff:fe40:4eaa%tap0]/.well-known/core |
| 45 | + |
| 46 | +Example response: |
| 47 | + |
| 48 | + v:1 t:NON c:GET i:0daa {} [ ] |
| 49 | + </cli/stats> |
| 50 | + |
| 51 | +The response shows the endpoint registered by the gcoap CLI example. |
| 52 | + |
| 53 | +### Send query to libcoap example server |
| 54 | + |
| 55 | +Start the libcoap example server with the command below. |
| 56 | + |
| 57 | + ./coap-server |
| 58 | + |
| 59 | +Enter the query below in the RIOT CLI. |
| 60 | + |
| 61 | + > coap get fe80::d8b8:65ff:feee:121b%6 5683 /.well-known/core |
| 62 | + |
| 63 | +CLI output: |
| 64 | + |
| 65 | + gcoap_cli: sending msg ID 743, 75 bytes |
| 66 | + > gcoap: response Success, code 2.05, 105 bytes |
| 67 | + </>;title="General Info";ct=0,</time>;if="clock";rt="Ticks";title="Internal Clock";ct=0;obs,</async>;ct=0 |
| 68 | + |
| 69 | + |
| 70 | +## Other available CoAP implementations and applications |
| 71 | + |
| 72 | +RIOT also provides package imports and test applications for other CoAP |
| 73 | +implementations: |
| 74 | + |
| 75 | +* [Nanocoap](../nanocoap_server): a very lightweight CoAP server based on the |
| 76 | + [nanocoap library](https://github.com/kaspar030/sock/tree/master/nanocoap) |
| 77 | + implementation |
| 78 | + |
| 79 | +* [Microcoap](../../tests/pkg_microcoap): another lightweight CoAP server based |
| 80 | + on the [microcoap library](https://github.com/1248/microcoap) implementation |
| 81 | + |
| 82 | + |
| 83 | +[1]: https://tools.ietf.org/html/rfc7252 "CoAP spec" |
| 84 | +[2]: https://github.com/RIOT-OS/RIOT/tree/master/examples/gnrc_networking "instructions" |
| 85 | +[3]: https://github.com/RIOT-OS/RIOT/tree/master/examples/gnrc_border_router "SLIP instructions" |
0 commit comments