Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coap_handler.txt.in: Update documentation for request handler #1230

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions man/coap_handler.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ COAP_REQUEST_PATCH
COAP_REQUEST_IPATCH
----

The method handler function prototype is defined as:
The request handler function prototype is defined as:
[source, c]
----
typedef void (*coap_method_handler_t)(coap_resource_t *resource,
Expand All @@ -84,13 +84,22 @@ typedef void (*coap_method_handler_t)(coap_resource_t *resource,

In _handler_, data from _incoming_pdu_ can be abstracted as described in
*coap_pdu_access*(3) for analysis and then the _handler_ updates
_response_pdu_ as
appropriate as described in *coap_pdu_setup*(3). _response_pdu_ is already
pre-populated with the _incoming_pdu_'s token and the PDU type. If this
handler is called as a result of an unsolicited Observe trigger, then the
_response_pdu_ as appropriate as described in *coap_pdu_setup*(3),
including the response code. If _response_pdu_'s code is not updated, then
_response_pdu_ will not get sent back to the client.

_response_pdu_ is already
pre-populated with the _incoming_pdu_'s token and the PDU type. If
_handler_ is called as a result of an unsolicited Observe trigger, then the
Observe option (and potentially Block2 option) are also added in. The
_response_pdu_'s response code should always be updated.

This _handler_ must not call *coap_send*(3) to send _response_pdu_.
_response_pdu_ gets sent on return from _handler_, assuming the response
code has been updated. If the response code was not updated, then an empty
ACK packet will get sent for CON type requests or nothing for NON type
requests.

*NOTE:* Any data associated with _incoming_pdu_ is no longer be available after
exiting this function as _incoming_pdu_ is deleted. In particular
_incoming_pdu_'s data must not be used if calling
Expand Down