nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
download_client.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
20#ifndef DOWNLOAD_CLIENT_H__
21#define DOWNLOAD_CLIENT_H__
22
23#include <zephyr/kernel.h>
24#include <zephyr/types.h>
25#include <zephyr/net/coap.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
78};
79
81 const void *buf;
82 size_t len;
83};
84
91
92 union {
94 int error;
97 };
98};
99
108 const int *sec_tag_list;
117 uint8_t pdn_id;
129};
130
145 const struct download_client_evt *event);
146
152 struct k_mutex mutex;
153
155 int fd;
156
158 struct sockaddr remote_addr;
159
161 char buf[CONFIG_DOWNLOAD_CLIENT_BUF_SIZE];
163 size_t offset;
164
166 size_t file_size;
168 size_t progress;
169
173 const char *host;
177 const char *file;
180
182 int proto;
183
184 struct {
192 bool ranged;
194
195 struct {
197 struct coap_block_context block_ctx;
198
200 struct coap_pending pending;
202
204 k_tid_t tid;
206 struct k_thread thread;
208 struct k_sem wait_for_download;
209
210 /* Internal thread stack. */
212 CONFIG_DOWNLOAD_CLIENT_STACK_SIZE);
213
216
219
222
223 enum {
230};
231
245
257int download_client_set_host(struct download_client *client, const char *host,
258 const struct download_client_cfg *config);
259
276int download_client_start(struct download_client *client, const char *file,
277 size_t from);
278
289int download_client_file_size_get(struct download_client *client, size_t *size);
290
301int download_client_downloaded_size_get(struct download_client *client, size_t *size);
302
317
346int download_client_get(struct download_client *client, const char *host,
347 const struct download_client_cfg *config, const char *file, size_t from);
348
349#ifdef __cplusplus
350}
351#endif
352
353#endif /* DOWNLOAD_CLIENT_H__ */
354
int download_client_get(struct download_client *client, const char *host, const struct download_client_cfg *config, const char *file, size_t from)
Download a file asynchronously.
int download_client_downloaded_size_get(struct download_client *client, size_t *size)
Retrieve the number of bytes downloaded so far.
int download_client_init(struct download_client *client, download_client_callback_t callback)
Initialize the download client.
int download_client_start(struct download_client *client, const char *file, size_t from)
Download a file.
download_client_evt_id
Download client event IDs.
Definition: download_client.h:34
@ DOWNLOAD_CLIENT_EVT_CLOSED
Definition: download_client.h:77
@ DOWNLOAD_CLIENT_EVT_ERROR
Definition: download_client.h:73
@ DOWNLOAD_CLIENT_EVT_FRAGMENT
Definition: download_client.h:39
@ DOWNLOAD_CLIENT_EVT_DONE
Definition: download_client.h:75
int download_client_set_host(struct download_client *client, const char *host, const struct download_client_cfg *config)
Set a target hostname.
int(* download_client_callback_t)(const struct download_client_evt *event)
Download client asynchronous event handler.
Definition: download_client.h:144
int download_client_disconnect(struct download_client *client)
Initiate disconnection.
int download_client_file_size_get(struct download_client *client, size_t *size)
Retrieve the size of the file being downloaded, in bytes.
uint8_t pdn_id
Definition: download_client.h:117
uint8_t sec_tag_count
Definition: download_client.h:112
int family
Definition: download_client.h:122
size_t frag_size_override
Definition: download_client.h:126
bool set_tls_hostname
Definition: download_client.h:128
const int * sec_tag_list
Definition: download_client.h:108
Download client configuration options.
Definition: download_client.h:103
int error
Definition: download_client.h:94
enum download_client_evt_id id
Definition: download_client.h:90
struct download_fragment fragment
Definition: download_client.h:96
Download client event.
Definition: download_client.h:88
struct k_sem wait_for_download
Definition: download_client.h:208
const char * host
Definition: download_client.h:173
bool has_header
Definition: download_client.h:188
size_t progress
Definition: download_client.h:168
bool set_native_tls
Definition: download_client.h:218
size_t offset
Definition: download_client.h:163
struct coap_pending pending
Definition: download_client.h:200
k_tid_t tid
Definition: download_client.h:204
struct k_mutex mutex
Definition: download_client.h:152
int proto
Definition: download_client.h:182
struct download_client::@196 coap
struct download_client_cfg config
Definition: download_client.h:179
size_t file_size
Definition: download_client.h:166
bool close_when_done
Definition: download_client.h:221
struct k_thread thread
Definition: download_client.h:206
const char * file
Definition: download_client.h:177
char buf[CONFIG_DOWNLOAD_CLIENT_BUF_SIZE]
Definition: download_client.h:161
bool connection_close
Definition: download_client.h:190
struct download_client::@195 http
struct sockaddr remote_addr
Definition: download_client.h:158
@ DOWNLOAD_CLIENT_FINISHED
Definition: download_client.h:227
@ DOWNLOAD_CLIENT_CLOSING
Definition: download_client.h:228
@ DOWNLOAD_CLIENT_DOWNLOADING
Definition: download_client.h:226
@ DOWNLOAD_CLIENT_IDLE
Definition: download_client.h:224
@ DOWNLOAD_CLIENT_CONNECTING
Definition: download_client.h:225
int fd
Definition: download_client.h:155
enum download_client::@197 state
download_client_callback_t callback
Definition: download_client.h:215
struct coap_block_context block_ctx
Definition: download_client.h:197
bool ranged
Definition: download_client.h:192
K_THREAD_STACK_MEMBER(thread_stack, CONFIG_DOWNLOAD_CLIENT_STACK_SIZE)
Download client instance.
Definition: download_client.h:150
const void * buf
Definition: download_client.h:81
size_t len
Definition: download_client.h:82
Definition: download_client.h:80