Skip to content

Commit ea5d544

Browse files
committed
examples/gcoap: upgrade users of deprecated nanocoap APIs
1 parent 93be3cc commit ea5d544

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

examples/networking/coap/gcoap/client.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,16 @@ static void _resp_handler(const gcoap_request_memo_t *memo, coap_pkt_t* pdu,
134134
uri_parser_result_t urip;
135135
uri_parser_process(&urip, _last_req_uri, strlen(_last_req_uri));
136136
if (*_proxy_uri) {
137-
gcoap_req_init(pdu, (uint8_t *)pdu->hdr, CONFIG_GCOAP_PDU_BUF_SIZE,
137+
gcoap_req_init(pdu, pdu->buf, CONFIG_GCOAP_PDU_BUF_SIZE,
138138
COAP_METHOD_GET, NULL);
139139
}
140140
else {
141-
gcoap_req_init(pdu, (uint8_t *)pdu->hdr, CONFIG_GCOAP_PDU_BUF_SIZE,
141+
gcoap_req_init(pdu, pdu->buf, CONFIG_GCOAP_PDU_BUF_SIZE,
142142
COAP_METHOD_GET, urip.path);
143143
}
144144

145145
if (msg_type == COAP_TYPE_ACK) {
146-
coap_hdr_set_type(pdu->hdr, COAP_TYPE_CON);
146+
coap_pkt_set_type(pdu, COAP_TYPE_CON);
147147
}
148148
block.blknum++;
149149
coap_opt_add_block2_control(pdu, &block);
@@ -154,7 +154,7 @@ static void _resp_handler(const gcoap_request_memo_t *memo, coap_pkt_t* pdu,
154154

155155
int len = coap_opt_finish(pdu, COAP_OPT_FINISH_NONE);
156156
gcoap_socket_type_t tl = _get_tl(*_proxy_uri ? _proxy_uri : _last_req_uri);
157-
_send((uint8_t *)pdu->hdr, len, remote, memo->context, tl);
157+
_send(pdu->buf, len, remote, memo->context, tl);
158158
}
159159
else {
160160
puts("--- blockwise complete ---");
@@ -341,7 +341,7 @@ static int _cli_cmd(int argc, char **argv)
341341
}
342342
}
343343

344-
coap_hdr_set_type(pdu.hdr, msg_type);
344+
coap_pkt_set_type(&pdu, msg_type);
345345

346346
size_t paylen = 0;
347347
if (apos < argc) {

examples/networking/coap/gcoap/server.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static void _rtc_notify_observers(void *arg)
123123
}
124124
size_t len;
125125
char str_time[20] = "";
126-
uint8_t buf[sizeof(coap_hdr_t) + COAP_TOKEN_LENGTH_MAX + 1 + sizeof(str_time)];
126+
uint8_t buf[sizeof(coap_udp_hdr_t) + COAP_TOKEN_LENGTH_MAX + 1 + sizeof(str_time)];
127127
coap_pkt_t pdu;
128128
const coap_resource_t *rtc_resource = NULL;
129129
const gcoap_listener_t *listener = NULL;

examples/networking/coap/gcoap_dtls/client.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,16 @@ static void _resp_handler(const gcoap_request_memo_t *memo, coap_pkt_t* pdu,
133133
uri_parser_result_t urip;
134134
uri_parser_process(&urip, _last_req_uri, strlen(_last_req_uri));
135135
if (*_proxy_uri) {
136-
gcoap_req_init(pdu, (uint8_t *)pdu->hdr, CONFIG_GCOAP_PDU_BUF_SIZE,
136+
gcoap_req_init(pdu, pdu->buf, CONFIG_GCOAP_PDU_BUF_SIZE,
137137
COAP_METHOD_GET, NULL);
138138
}
139139
else {
140-
gcoap_req_init(pdu, (uint8_t *)pdu->hdr, CONFIG_GCOAP_PDU_BUF_SIZE,
140+
gcoap_req_init(pdu, pdu->buf, CONFIG_GCOAP_PDU_BUF_SIZE,
141141
COAP_METHOD_GET, urip.path);
142142
}
143143

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

154154
int len = coap_opt_finish(pdu, COAP_OPT_FINISH_NONE);
155155
gcoap_socket_type_t tl = _get_tl(*_proxy_uri ? _proxy_uri : _last_req_uri);
156-
_send((uint8_t *)pdu->hdr, len, remote, memo->context, tl);
156+
_send(pdu->buf, len, remote, memo->context, tl);
157157
}
158158
else {
159159
puts("--- blockwise complete ---");
@@ -340,7 +340,7 @@ int gcoap_cli_cmd(int argc, char **argv)
340340
}
341341
}
342342

343-
coap_hdr_set_type(pdu.hdr, msg_type);
343+
coap_pkt_set_type(&pdu, msg_type);
344344

345345
size_t paylen = 0;
346346
if (apos < argc) {

0 commit comments

Comments
 (0)