mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
nanocoap_sock: add nanocoap_get_blockwise_to_buf()
This commit is contained in:
parent
19643e2590
commit
c5cfecb311
@ -584,6 +584,29 @@ ssize_t nanocoap_get_blockwise_url_to_buf(const char *url,
|
||||
coap_blksize_t blksize,
|
||||
void *buf, size_t len);
|
||||
|
||||
/**
|
||||
* @brief Performs a blockwise CoAP GET request, store the response
|
||||
* in a buffer.
|
||||
*
|
||||
* This function will fetch the content of the specified resource path via
|
||||
* block-wise-transfer.
|
||||
* The blocks will be re-assembled into @p buf
|
||||
*
|
||||
* @param[in] sock socket to use for the request
|
||||
* @param[in] path pointer to source path
|
||||
* @param[in] blksize sender suggested SZX for the COAP block request
|
||||
* @param[in] buf Target buffer
|
||||
* @param[in] len Target buffer length
|
||||
*
|
||||
* @returns <0 on error
|
||||
* @returns -EINVAL if an invalid url is provided
|
||||
* @returns -ENOBUFS if the provided buffer was too small
|
||||
* @returns size of the response payload on success
|
||||
*/
|
||||
ssize_t nanocoap_get_blockwise_to_buf(nanocoap_sock_t *sock, const char *path,
|
||||
coap_blksize_t blksize,
|
||||
void *buf, size_t len);
|
||||
|
||||
/**
|
||||
* @brief Simple synchronous CoAP request
|
||||
*
|
||||
|
@ -811,6 +811,17 @@ ssize_t nanocoap_get_blockwise_url_to_buf(const char *url,
|
||||
return (res < 0) ? (ssize_t)res : (ssize_t)_buf.len;
|
||||
}
|
||||
|
||||
ssize_t nanocoap_get_blockwise_to_buf(nanocoap_sock_t *sock, const char *path,
|
||||
coap_blksize_t blksize,
|
||||
void *buf, size_t len)
|
||||
{
|
||||
_buf_t _buf = { .ptr = buf, .len = len };
|
||||
|
||||
int res = nanocoap_sock_get_blockwise(sock, path, blksize, _2buf, &_buf);
|
||||
|
||||
return (res < 0) ? (ssize_t)res : (ssize_t)_buf.len;
|
||||
}
|
||||
|
||||
int nanocoap_server(sock_udp_ep_t *local, uint8_t *buf, size_t bufsize)
|
||||
{
|
||||
nanocoap_sock_t sock;
|
||||
|
Loading…
Reference in New Issue
Block a user