Merge pull request #15288 from chrysn-pull-requests/gcoap_register_listener-document-single
net/goap: State and check that listeners are added individually
This commit is contained in:
commit
ddc4dad456
@ -690,6 +690,16 @@ kernel_pid_t gcoap_init(void);
|
|||||||
/**
|
/**
|
||||||
* @brief Starts listening for resource paths
|
* @brief Starts listening for resource paths
|
||||||
*
|
*
|
||||||
|
* @pre @p listener is a valid pointer to a single listener (that is,
|
||||||
|
* `listener->next == NULL`)
|
||||||
|
*
|
||||||
|
* @note If you are tempted to register a pre-linked chain of listeners,
|
||||||
|
* consider placing all their resources in the resources array of a
|
||||||
|
* single listener instead. In the few cases where this does not work
|
||||||
|
* (that is, when the resources need a different `link_encoder` or other
|
||||||
|
* fields of the listener struct), they can just be registered
|
||||||
|
* individually.
|
||||||
|
*
|
||||||
* @param[in] listener Listener containing the resources.
|
* @param[in] listener Listener containing the resources.
|
||||||
*/
|
*/
|
||||||
void gcoap_register_listener(gcoap_listener_t *listener);
|
void gcoap_register_listener(gcoap_listener_t *listener);
|
||||||
|
|||||||
@ -702,6 +702,10 @@ kernel_pid_t gcoap_init(void)
|
|||||||
|
|
||||||
void gcoap_register_listener(gcoap_listener_t *listener)
|
void gcoap_register_listener(gcoap_listener_t *listener)
|
||||||
{
|
{
|
||||||
|
/* That item will be overridden, ensure that the user expecting different
|
||||||
|
* behavior will notice this. */
|
||||||
|
assert(listener->next == NULL);
|
||||||
|
|
||||||
if (!listener->link_encoder) {
|
if (!listener->link_encoder) {
|
||||||
listener->link_encoder = gcoap_encode_link;
|
listener->link_encoder = gcoap_encode_link;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user