mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-08 10:32:53 +03:00
In the same way that coap_split_uri() allows coaps:// scheme even if DTLS is not available, it should allow coap+tcp:// and coaps+tcp:// scheme and let other functions check whether TCP/TLS is available or not. examples/client.c: Verify if TCP is supported for scheme coap+tcp://. src/coap_session.c: Verify that the underlying CoAP transport protocol is supported in coap_session_create_client(). Add verify for TCP protocol in coap_new_endpoint(), as well as always check if TLS is supported. src/uri.c: Always allow coap+tcp:// and coaps+tcp:// in coap_split_uri() as a parsed scheme in same way that coaps:// is always allowed. Makefile.libcoap: Include coap_tcp.c to include coap_tcp_is_supported() function. examples/lwip/Makefile: Include coap_tcp.o to include coap_tcp_is_supported() function.
Example of libcoap running on lwIP
==================================
To run the example, do
$ make
$ sudo ./server
(and in a second terminal)
$ sudo ip a a dev tap0 192.168.113.1/24
and query `coap://192.168.113.2/time?ticks` with any coap tool,
or query `coap://[aaaa::1000]/.well-known/core`
This will
* download lwip and lwip-contrib 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 `include/coap/lwippools.h`.