Files
libcoap/examples/contiki
Jon Shallow afefd95ceb coap_io_process: Fix 1ms busy loop and indefinite sleep
Replace COAP_RUN_BLOCK with COAP_IO_WAIT and COAP_RUN_NOBLOCK with
COAP_IO_NO_WAIT for naming clarity.

Instead of COAP_IO_NO_WAIT being 1, make it -1 to fix 1ms busy loop.
Handle the case when coap_io_prepare_io returns 0 to prevent indefinite
select() wait.

include/coap2/net.h:

Make the timeout_ms parameter uint32_t in coap_io_process*() functions to
make sure special case of COAP_IO_NO_BLOCK is correctly handled on different
architectures.
Update COAP_IO_NO_BLOCK to -1.

src/coap_io.c:

Fix the 1ms busy loop and potential infinite wait in the non epoll case.

man/coap_io.txt.in:

Update documentation to reflect the changes.

examples/coap-server.c:
examples/contiki/server.c:

Update to use COAP_IO WAIT and COAP_IO_NO_WAIT as appropriate.
2020-02-25 22:03:46 +00:00
..

Example of libcoap running on contiki
=====================================

To run the example, do

    $ make
    $ sudo ./server.minimal-net

(and in a second terminal)

    $ sudo ip -6 a a aaaa::1/64 dev tap0

and query `coap://[aaaa::1000]/time?ticks` with any coap tool,
or query `coap://[aaaa::1000]/.well-known/core`

This will

* download contiki from the upstream git sources
* build the server application
* run the server application, creating a virtual network device tap0 (unless
  that exists)
* configure your network interface to make the server accessible.

* return the appropriate response from the server to the client.

The server creates a resource for 'time' with a query 'ticks'.  This is
reported for `.well-known/core`. The work flow for adding more resources does
not differ from regular libcoap usage. If you seem to run out of memory
creating the resources, tweak the number of pre-allocated resources
in `coap_config.h.contiki`.