Skip to content

Commit

Permalink
examples/gcoap: upgrade users of deprecated nanocoap APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
maribu committed Jan 23, 2025
1 parent 7458bce commit ca4d34c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions examples/gcoap/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,16 @@ static void _resp_handler(const gcoap_request_memo_t *memo, coap_pkt_t* pdu,
uri_parser_result_t urip;
uri_parser_process(&urip, _last_req_uri, strlen(_last_req_uri));
if (*_proxy_uri) {
gcoap_req_init(pdu, (uint8_t *)pdu->hdr, CONFIG_GCOAP_PDU_BUF_SIZE,
gcoap_req_init(pdu, pdu->buf, CONFIG_GCOAP_PDU_BUF_SIZE,
COAP_METHOD_GET, NULL);
}
else {
gcoap_req_init(pdu, (uint8_t *)pdu->hdr, CONFIG_GCOAP_PDU_BUF_SIZE,
gcoap_req_init(pdu, pdu->buf, CONFIG_GCOAP_PDU_BUF_SIZE,
COAP_METHOD_GET, urip.path);
}

if (msg_type == COAP_TYPE_ACK) {
coap_hdr_set_type(pdu->hdr, COAP_TYPE_CON);
coap_pkt_set_type(pdu, COAP_TYPE_CON);
}
block.blknum++;
coap_opt_add_block2_control(pdu, &block);
Expand All @@ -153,7 +153,7 @@ static void _resp_handler(const gcoap_request_memo_t *memo, coap_pkt_t* pdu,

int len = coap_opt_finish(pdu, COAP_OPT_FINISH_NONE);
gcoap_socket_type_t tl = _get_tl(*_proxy_uri ? _proxy_uri : _last_req_uri);
_send((uint8_t *)pdu->hdr, len, remote, memo->context, tl);
_send(pdu->buf, len, remote, memo->context, tl);
}
else {
puts("--- blockwise complete ---");
Expand Down Expand Up @@ -340,7 +340,7 @@ int gcoap_cli_cmd(int argc, char **argv)
}
}

coap_hdr_set_type(pdu.hdr, msg_type);
coap_pkt_set_type(&pdu, msg_type);

size_t paylen = 0;
if (apos < argc) {
Expand Down
2 changes: 1 addition & 1 deletion examples/gcoap/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static void _rtc_notify_observers(void *arg)
}
size_t len;
char str_time[20] = "";
uint8_t buf[sizeof(coap_hdr_t) + COAP_TOKEN_LENGTH_MAX + 1 + sizeof(str_time)];
uint8_t buf[sizeof(coap_udp_hdr_t) + COAP_TOKEN_LENGTH_MAX + 1 + sizeof(str_time)];
coap_pkt_t pdu;
const coap_resource_t *rtc_resource = NULL;
const gcoap_listener_t *listener = NULL;
Expand Down

0 comments on commit ca4d34c

Please sign in to comment.