mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
examples/cord_epsim: use coap_opt_finish()
This commit is contained in:
parent
a8cbc19241
commit
682c1e9a7d
@ -34,9 +34,11 @@ static ssize_t text_resp(coap_pkt_t *pdu, uint8_t *buf, size_t len,
|
||||
const char *text, unsigned format)
|
||||
{
|
||||
gcoap_resp_init(pdu, buf, len, COAP_CODE_CONTENT);
|
||||
coap_opt_add_format(pdu, format);
|
||||
ssize_t resp_len = coap_opt_finish(pdu, COAP_OPT_FINISH_PAYLOAD);
|
||||
size_t slen = strlen(text);
|
||||
memcpy(pdu->payload, text, slen);
|
||||
return gcoap_finish(pdu, slen, format);
|
||||
return resp_len + slen;
|
||||
}
|
||||
|
||||
static ssize_t handler_info(coap_pkt_t *pdu, uint8_t *buf, size_t len, void *ctx)
|
||||
|
@ -59,7 +59,7 @@ int cord_epsim_register(void)
|
||||
return CORD_EPSIM_ERROR;
|
||||
}
|
||||
/* finish, we don't have any payload */
|
||||
ssize_t len = gcoap_finish(&pkt, 0, COAP_FORMAT_NONE);
|
||||
ssize_t len = coap_opt_finish(&pkt, COAP_OPT_FINISH_NONE);
|
||||
if (gcoap_req_send2(buf, len, &remote, NULL) == 0) {
|
||||
return CORD_EPSIM_ERROR;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user