nRF Connect SDK API 0.1.0
|
int download_client_get | ( | struct download_client * | client, |
const char * | host, | ||
const struct download_client_cfg * | config, | ||
const char * | file, | ||
size_t | from | ||
) |
#include <include/net/download_client.h>
Download a file asynchronously.
This initiates an asynchronous connect-download-disconnect sequence to the target host. When only one file is required from a target server, it can be used instead of separate calls to download_client_set_host(), download_client_start() and download_client_disconnect().
Downloads are handled one at a time. If previous download is not finished this returns -EALREADY.
The download is carried out in fragments of up to
embed:rst:inline :kconfig:option:`CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE`
bytes for HTTP, or
embed:rst:inline :kconfig:option:`CONFIG_DOWNLOAD_CLIENT_COAP_BLOCK_SIZE`
bytes for CoAP, which are delivered to the application through DOWNLOAD_CLIENT_EVT_FRAGMENT events.
[in] | client | Client instance. |
[in] | host | URI of the host to connect to. Can include scheme, port number and full file path, defaults to HTTP or HTTPS if no scheme is provided. |
[in] | config | Configuration options. |
[in] | file | File to download or NULL if path is already provided in host parameter. |
[in] | from | Offset from where to resume the download, or zero to download from the beginning. |
int | Zero on success, a negative error code otherwise. |