nRF Connect SDK API 2.7.99
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
31#define K_THREAD_STACK_MEMBER K_KERNEL_STACK_MEMBER
32
80};
81
83 const void *buf;
84 size_t len;
85};
86
93
94 union {
96 int error;
99 };
100};
101
110 const int *sec_tag_list;
119 uint8_t pdn_id;
131};
132
147 const struct download_client_evt *event);
148
154 struct k_mutex mutex;
155
157 int fd;
158
160 struct sockaddr remote_addr;
161
163 char buf[CONFIG_DOWNLOAD_CLIENT_BUF_SIZE];
165 size_t offset;
166
168 size_t file_size;
170 size_t progress;
171
175 const char *host;
179 const char *file;
182
184 int proto;
185
186 struct {
194 bool ranged;
196
197 struct {
199 struct coap_block_context block_ctx;
200
202 struct coap_pending pending;
204
206 k_tid_t tid;
208 struct k_thread thread;
210 struct k_sem wait_for_download;
211
212 /* Internal thread stack. */
214 CONFIG_DOWNLOAD_CLIENT_STACK_SIZE);
215
218
221
224
225 enum {
232};
233
247
259int download_client_set_host(struct download_client *client, const char *host,
260 const struct download_client_cfg *config);
261
278int download_client_start(struct download_client *client, const char *file,
279 size_t from);
280
291int download_client_file_size_get(struct download_client *client, size_t *size);
292
303int download_client_downloaded_size_get(struct download_client *client, size_t *size);
304
319
348int download_client_get(struct download_client *client, const char *host,
349 const struct download_client_cfg *config, const char *file, size_t from);
350
351#ifdef __cplusplus
352}
353#endif
354
355#endif /* DOWNLOAD_CLIENT_H__ */
356
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.
#define K_THREAD_STACK_MEMBER
Definition: download_client.h:31
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:36
@ DOWNLOAD_CLIENT_EVT_CLOSED
Definition: download_client.h:79
@ DOWNLOAD_CLIENT_EVT_ERROR
Definition: download_client.h:75
@ DOWNLOAD_CLIENT_EVT_FRAGMENT
Definition: download_client.h:41
@ DOWNLOAD_CLIENT_EVT_DONE
Definition: download_client.h:77
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:146
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:119
uint8_t sec_tag_count
Definition: download_client.h:114
int family
Definition: download_client.h:124
size_t frag_size_override
Definition: download_client.h:128
bool set_tls_hostname
Definition: download_client.h:130
const int * sec_tag_list
Definition: download_client.h:110
Download client configuration options.
Definition: download_client.h:105
int error
Definition: download_client.h:96
enum download_client_evt_id id
Definition: download_client.h:92
struct download_fragment fragment
Definition: download_client.h:98
Download client event.
Definition: download_client.h:90
struct download_client::@203 coap
struct k_sem wait_for_download
Definition: download_client.h:210
@ DOWNLOAD_CLIENT_FINISHED
Definition: download_client.h:229
@ DOWNLOAD_CLIENT_CLOSING
Definition: download_client.h:230
@ DOWNLOAD_CLIENT_DOWNLOADING
Definition: download_client.h:228
@ DOWNLOAD_CLIENT_IDLE
Definition: download_client.h:226
@ DOWNLOAD_CLIENT_CONNECTING
Definition: download_client.h:227
const char * host
Definition: download_client.h:175
bool has_header
Definition: download_client.h:190
size_t progress
Definition: download_client.h:170
bool set_native_tls
Definition: download_client.h:220
size_t offset
Definition: download_client.h:165
struct coap_pending pending
Definition: download_client.h:202
k_tid_t tid
Definition: download_client.h:206
struct k_mutex mutex
Definition: download_client.h:154
int proto
Definition: download_client.h:184
struct download_client_cfg config
Definition: download_client.h:181
size_t file_size
Definition: download_client.h:168
struct download_client::@202 http
bool close_when_done
Definition: download_client.h:223
struct k_thread thread
Definition: download_client.h:208
const char * file
Definition: download_client.h:179
char buf[CONFIG_DOWNLOAD_CLIENT_BUF_SIZE]
Definition: download_client.h:163
bool connection_close
Definition: download_client.h:192
struct sockaddr remote_addr
Definition: download_client.h:160
enum download_client::@204 state
int fd
Definition: download_client.h:157
download_client_callback_t callback
Definition: download_client.h:217
struct coap_block_context block_ctx
Definition: download_client.h:199
bool ranged
Definition: download_client.h:194
Download client instance.
Definition: download_client.h:152
const void * buf
Definition: download_client.h:83
size_t len
Definition: download_client.h:84
Definition: download_client.h:82