Skip to content

Commit 5018dc6

Browse files
authored
Merge pull request #21241 from maribu/sys/net/nanocoap/fix-api-inconsistency
sys/net/nanocoap: fix API inconsistency
2 parents 1aec7f1 + be27eaf commit 5018dc6

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

sys/include/net/nanocoap.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,8 +2278,7 @@ ssize_t coap_payload_put_char(coap_pkt_t *pkt, char c);
22782278
* @param[in] code reply code (e.g., COAP_CODE_204)
22792279
* @param[out] buf buffer to write reply to
22802280
* @param[in] len size of @p buf
2281-
* @param[in] ct content type of payload
2282-
* if ct < 0 this will be ignored
2281+
* @param[in] ct content type of payload or @ref COAP_FORMAT_NONE
22832282
* @param[out] payload Will be set to the start of the payload inside
22842283
* @p buf.
22852284
* May be set to NULL if no payload response is
@@ -2292,8 +2291,7 @@ ssize_t coap_payload_put_char(coap_pkt_t *pkt, char c);
22922291
* @returns -ENOSPC if @p buf too small
22932292
*/
22942293
ssize_t coap_build_reply_header(coap_pkt_t *pkt, unsigned code,
2295-
void *buf, size_t len,
2296-
int ct,
2294+
void *buf, size_t len, uint16_t ct,
22972295
void **payload, size_t *payload_len_max);
22982296

22992297
/**
@@ -2309,7 +2307,7 @@ ssize_t coap_build_reply_header(coap_pkt_t *pkt, unsigned code,
23092307
* @param[in] code reply code (e.g., COAP_CODE_204)
23102308
* @param[out] buf buffer to write reply to
23112309
* @param[in] len size of @p buf
2312-
* @param[in] ct content type of payload
2310+
* @param[in] ct content type of payload or @ref COAP_FORMAT_NONE
23132311
* @param[in] payload ptr to payload
23142312
* @param[in] payload_len length of payload
23152313
*
@@ -2320,7 +2318,7 @@ ssize_t coap_build_reply_header(coap_pkt_t *pkt, unsigned code,
23202318
ssize_t coap_reply_simple(coap_pkt_t *pkt,
23212319
unsigned code,
23222320
uint8_t *buf, size_t len,
2323-
unsigned ct,
2321+
uint16_t ct,
23242322
const void *payload, size_t payload_len);
23252323

23262324
/**

sys/net/application_layer/nanocoap/nanocoap.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ ssize_t coap_tree_handler(coap_pkt_t *pkt, uint8_t *resp_buf, unsigned resp_buf_
578578

579579
ssize_t coap_build_reply_header(coap_pkt_t *pkt, unsigned code,
580580
void *buf, size_t len,
581-
int ct,
581+
uint16_t ct,
582582
void **payload, size_t *payload_len_max)
583583
{
584584
uint8_t *bufpos = buf;
@@ -631,7 +631,7 @@ ssize_t coap_build_reply_header(coap_pkt_t *pkt, unsigned code,
631631
}
632632

633633
if (payload) {
634-
if (ct >= 0) {
634+
if (ct != COAP_FORMAT_NONE) {
635635
bufpos += coap_put_option_ct(bufpos, 0, ct);
636636
}
637637
*bufpos++ = COAP_PAYLOAD_MARKER;
@@ -649,7 +649,7 @@ ssize_t coap_build_reply_header(coap_pkt_t *pkt, unsigned code,
649649
ssize_t coap_reply_simple(coap_pkt_t *pkt,
650650
unsigned code,
651651
uint8_t *buf, size_t len,
652-
unsigned ct,
652+
uint16_t ct,
653653
const void *payload, size_t payload_len)
654654
{
655655
void *payload_start;

0 commit comments

Comments
 (0)