mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
nanocoap: add coap_build_empty_ack()
This commit is contained in:
parent
2c232dd0d2
commit
c280076594
@ -1956,6 +1956,22 @@ ssize_t coap_build_hdr(coap_hdr_t *hdr, unsigned type, const void *token,
|
||||
ssize_t coap_build_reply(coap_pkt_t *pkt, unsigned code,
|
||||
uint8_t *rbuf, unsigned rlen, unsigned payload_len);
|
||||
|
||||
/**
|
||||
* @brief Build empty reply to CoAP request
|
||||
*
|
||||
* This function can be used to create an empty ACK so that a later, separate
|
||||
* response can be sent independently.
|
||||
*
|
||||
* If the request was non-confirmable, this will generate nothing.
|
||||
*
|
||||
* @param[in] pkt packet to reply to
|
||||
* @param[out] ack buffer to write reply to
|
||||
*
|
||||
* @returns size of reply packet on success
|
||||
* @returns -ENOSPC if @p rbuf too small
|
||||
*/
|
||||
ssize_t coap_build_empty_ack(coap_pkt_t *pkt, coap_hdr_t *ack);
|
||||
|
||||
/**
|
||||
* @brief Handle incoming CoAP request
|
||||
*
|
||||
|
@ -626,6 +626,18 @@ ssize_t coap_reply_simple(coap_pkt_t *pkt,
|
||||
return header_len + payload_len;
|
||||
}
|
||||
|
||||
ssize_t coap_build_empty_ack(coap_pkt_t *pkt, coap_hdr_t *ack)
|
||||
{
|
||||
if (coap_get_type(pkt) != COAP_TYPE_CON) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
coap_build_hdr(ack, COAP_TYPE_ACK, NULL, 0,
|
||||
COAP_CODE_EMPTY, ntohs(pkt->hdr->id));
|
||||
|
||||
return sizeof(*ack);
|
||||
}
|
||||
|
||||
ssize_t coap_build_reply(coap_pkt_t *pkt, unsigned code,
|
||||
uint8_t *rbuf, unsigned rlen, unsigned payload_len)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user