nRF Connect SDK API 2.8.0
Loading...
Searching...
No Matches

◆ download_client_get()

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

CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE 

bytes for HTTP, or

CONFIG_DOWNLOAD_CLIENT_COAP_BLOCK_SIZE 

bytes for CoAP, which are delivered to the application through DOWNLOAD_CLIENT_EVT_FRAGMENT events.

Parameters
[in]clientClient instance.
[in]hostURI 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]configConfiguration options.
[in]fileFile to download or NULL if path is already provided in host parameter.
[in]fromOffset from where to resume the download, or zero to download from the beginning.
Return values
intZero on success, a negative error code otherwise.