mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-25 06:23:53 +01:00
Merge pull request #20690 from benpicco/nanocoap_get_blockwise_to_buf
nanocoap_sock: add nanocoap_get_blockwise_to_buf()
This commit is contained in:
commit
e62c25a015
@ -633,6 +633,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
|
||||
*
|
||||
|
||||
@ -826,6 +826,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)
|
||||
{
|
||||
sock_udp_t sock;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user