mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:12:57 +01:00
examples/cord_ep: use coap_opt_finish()
This commit is contained in:
parent
682c1e9a7d
commit
34e880499e
@ -56,8 +56,9 @@ static ssize_t _handler_dummy(coap_pkt_t *pdu,
|
||||
int16_t val = 23;
|
||||
|
||||
gcoap_resp_init(pdu, buf, len, COAP_CODE_CONTENT);
|
||||
size_t plen = fmt_s16_dec((char *)pdu->payload, val);
|
||||
return gcoap_finish(pdu, plen, COAP_FORMAT_TEXT);
|
||||
size_t resp_len = coap_opt_finish(pdu, COAP_OPT_FINISH_PAYLOAD);
|
||||
resp_len += fmt_s16_dec((char *)pdu->payload, val);
|
||||
return resp_len;
|
||||
}
|
||||
|
||||
static ssize_t _handler_info(coap_pkt_t *pdu,
|
||||
@ -66,9 +67,10 @@ static ssize_t _handler_info(coap_pkt_t *pdu,
|
||||
(void)ctx;
|
||||
|
||||
gcoap_resp_init(pdu, buf, len, COAP_CODE_CONTENT);
|
||||
size_t resp_len = coap_opt_finish(pdu, COAP_OPT_FINISH_PAYLOAD);
|
||||
size_t slen = sizeof("SOME NODE INFOMRATION");
|
||||
memcpy(pdu->payload, "SOME NODE INFOMRATION", slen);
|
||||
return gcoap_finish(pdu, slen, COAP_FORMAT_TEXT);
|
||||
return resp_len + slen;
|
||||
}
|
||||
|
||||
static const coap_resource_t _resources[] = {
|
||||
|
@ -146,7 +146,7 @@ static int _update_remove(unsigned code, gcoap_resp_handler_t handle)
|
||||
return CORD_EP_ERR;
|
||||
}
|
||||
coap_hdr_set_type(pkt.hdr, COAP_TYPE_CON);
|
||||
ssize_t pkt_len = gcoap_finish(&pkt, 0, COAP_FORMAT_NONE);
|
||||
ssize_t pkt_len = coap_opt_finish(&pkt, COAP_OPT_FINISH_NONE);
|
||||
|
||||
/* send request */
|
||||
gcoap_req_send2(buf, pkt_len, &_rd_remote, handle);
|
||||
@ -220,7 +220,7 @@ static int _discover_internal(const sock_udp_ep_t *remote,
|
||||
}
|
||||
coap_hdr_set_type(pkt.hdr, COAP_TYPE_CON);
|
||||
gcoap_add_qstring(&pkt, "rt", "core.rd");
|
||||
size_t pkt_len = gcoap_finish(&pkt, 0, COAP_FORMAT_NONE);
|
||||
size_t pkt_len = coap_opt_finish(&pkt, COAP_OPT_FINISH_NONE);
|
||||
res = gcoap_req_send2(buf, pkt_len, remote, _on_discover);
|
||||
if (res < 0) {
|
||||
return CORD_EP_ERR;
|
||||
|
Loading…
Reference in New Issue
Block a user