Merge pull request #13240 from kb2ma/gcoap/deprecate_add_qstring

net/coap: deprecate gcoap_add_qstring() and update uses
This commit is contained in:
Ken Bannister 2020-03-13 08:04:50 -04:00 committed by GitHub
commit ec2aff4546
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 4 deletions

View File

@ -895,6 +895,9 @@ ssize_t gcoap_encode_link(const coap_resource_t *resource, char *buf,
* To add multiple Uri-Query options, simply call this function multiple times. * To add multiple Uri-Query options, simply call this function multiple times.
* The Uri-Query options will be added in the order those calls. * The Uri-Query options will be added in the order those calls.
* *
* @deprecated Will not be available after the 2020.10 release. Use
* coap_opt_add_uquery() instead.
*
* @param[out] pdu The package that is being build * @param[out] pdu The package that is being build
* @param[in] key Key to add to the query string * @param[in] key Key to add to the query string
* @param[in] val Value to assign to @p key (may be NULL) * @param[in] val Value to assign to @p key (may be NULL)

View File

@ -57,7 +57,7 @@ void cord_common_init(void)
int cord_common_add_qstring(coap_pkt_t *pkt) int cord_common_add_qstring(coap_pkt_t *pkt)
{ {
/* extend the url with some query string options */ /* extend the url with some query string options */
int res = gcoap_add_qstring(pkt, "ep", cord_common_ep); int res = coap_opt_add_uquery(pkt, "ep", cord_common_ep);
if (res < 0) { if (res < 0) {
return res; return res;
} }
@ -66,7 +66,7 @@ int cord_common_add_qstring(coap_pkt_t *pkt)
#if CORD_LT #if CORD_LT
char lt[11]; char lt[11];
lt[fmt_u32_dec(lt, CORD_LT)] = '\0'; lt[fmt_u32_dec(lt, CORD_LT)] = '\0';
res = gcoap_add_qstring(pkt, "lt", lt); res = coap_opt_add_uquery(pkt, "lt", lt);
if (res < 0) { if (res < 0) {
return res; return res;
} }
@ -74,7 +74,7 @@ int cord_common_add_qstring(coap_pkt_t *pkt)
/* [optional] set the domain parameter */ /* [optional] set the domain parameter */
#ifdef CORD_D #ifdef CORD_D
res = gcoap_add_qstring(pkt, "d", CORD_D); res = coap_opt_add_uquery(pkt, "d", CORD_D);
if (res < 0) { if (res < 0) {
return res; return res;
} }

View File

@ -221,7 +221,7 @@ static int _discover_internal(const sock_udp_ep_t *remote,
return CORD_EP_ERR; return CORD_EP_ERR;
} }
coap_hdr_set_type(pkt.hdr, COAP_TYPE_CON); coap_hdr_set_type(pkt.hdr, COAP_TYPE_CON);
gcoap_add_qstring(&pkt, "rt", "core.rd"); coap_opt_add_uquery(&pkt, "rt", "core.rd");
size_t pkt_len = coap_opt_finish(&pkt, COAP_OPT_FINISH_NONE); size_t pkt_len = coap_opt_finish(&pkt, COAP_OPT_FINISH_NONE);
res = gcoap_req_send(buf, pkt_len, remote, _on_discover, NULL); res = gcoap_req_send(buf, pkt_len, remote, _on_discover, NULL);
if (res < 0) { if (res < 0) {