This allows using and compiling the URL handling functions of sock_util
without a network stack used.
Co-authored-by: benpicco <benpicco@googlemail.com>
- The responsibility for handling matching CoAP No-Response Options
has been split:
- `coap_build_reply()` only needs to report this and return
`-ECANCLED`
- `coap_handle_req()` does generate the empty ACK is needed.
==> As a result, writing CoAP request handlers correctly becomes a
lost easier. Correct error handling to be present is now
sufficient for correct handling of No-Response options.
==> This change is backward compatible with existing code.
- The API doc has been cleaned up and straightened
Co-authored-by: mguetschow <mikolai.guetschow@tu-dresden.de>
For in-band signalling that a content format is not valid / present,
the magic number `COAP_FORMAT_NONE` was introduced and the type
`uint16_t` was used. Some APIs however used different in-band signalling
values and types:
- coap_reply_simple(): No signal available, `unsigned int`
- coap_build_reply_header(): negative values, `int`
(Using `int` would prevent using larger content format numbers on
8-bit and 16-bit archs, where `int` and `int16_t` have the same
range.)
This changes the behavior to consistently use `COAP_FORMAT_NONE` as
"no content format" signal and `uint16_t` as type.
`coap_request_ctx_get_local()` may return `NULL` depending on module
selection. If it does, we cannot pass `NULL` to
`sock_udp_ep_is_multicast()`.
This changes the code assume the request is not received via multicast
when module `sock_aux_local` is not in use.
When the user binds the CoAP server to multiple endpoints (as needed
for using multicast), it is required that `sock_aux_local` is in use
anyway, as otherwise the server may not respond using the endpoint it
received the request on. (That in turn would render the client unable to
correlate the response to the request.)
- Do not reply with a reset message to a reset or an ACK message
- Reply with a reset message when not able to process a CON/NON message
(not even a suitable error reply)
This adds the new `nanocoap_server_observe` module that implements the
server side of the CoAP Observe option. It does require cooperation
from the resource handler to work, though.
Co-Authored-By: mguetschow <mikolai.guetschow@tu-dresden.de>
Co-authored-by: benpicco <benpicco@googlemail.com>
This allows sending a separate response with CoAP Options and adds a
helper to detect duplicate requests, so that resource handlers can
repeat their empty ACK on duplicates.
Calling `coap_get_token()` and `coap_get_token_length()` on an
(mostly) uninitialized `coap_pkt_t` did work so far due to
implementation details matching the expectations, but this is not
backed up by any API contract.
This fixes the API abuse by introducing and using a new API that does
read a token and token length from a CoAP over UDP packet out of a
buffer. This now provides the behavior expected by the caller and
commits to it via API contract.
Co-authored-by: mguetschow <mikolai.guetschow@tu-dresden.de>
Co-authored-by: benpicco <benpicco@googlemail.com>
This reverts commit e3d00682bcad2e0f26ee15b1c73d5da022b18786, which
added a work around for two bugs:
- ztimer triggering too early (fixed in
https://github.com/RIOT-OS/RIOT/pull/20924)
- gnrc_sock_recv() returning when an old "timeout" message is still
in the message queue (fixed in
https://github.com/RIOT-OS/RIOT/pull/21113)
With those bugs fixed, the work around should not longer be needed.