nRF Connect SDK API 3.3.99
Loading...
Searching...
No Matches
downloader.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
19#ifndef __DOWNLOADER_H__
20#define __DOWNLOADER_H__
21
22#include <zephyr/kernel.h>
23#include <zephyr/types.h>
24#include <zephyr/net/coap.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
86
92 const void *buf;
94 size_t len;
95};
96
103
104 union {
106 int error;
109 };
110};
111
130typedef int (*downloader_callback_t)(const struct downloader_evt *event);
131
143
153 const int *sec_tag_list;
163 uint8_t pdn_id;
184 bool cid;
194 int (*auth_cb)(int sock);
199 const char *proxy_uri;
208 const char *if_name;
209};
210
223
235 char hostname[CONFIG_DOWNLOADER_MAX_HOSTNAME_SIZE];
237 char file[CONFIG_DOWNLOADER_MAX_FILENAME_SIZE];
239 size_t file_size;
241 size_t progress;
251 const struct dl_transport *transport;
253 uint8_t transport_internal[CONFIG_DOWNLOADER_TRANSPORT_PARAMS_SIZE];
254
256 struct k_sem event_sem;
258 struct k_mutex mutex;
262 struct k_thread thread;
264 k_tid_t tid;
266 K_KERNEL_STACK_MEMBER(thread_stack, CONFIG_DOWNLOADER_STACK_SIZE);
267};
268
277int downloader_init(struct downloader *dl, struct downloader_cfg *cfg);
278
287
307int downloader_get(struct downloader *dl, const struct downloader_host_cfg *host_cfg,
308 const char *url, size_t from);
309
331 const struct downloader_host_cfg *host_cfg,
332 const char *host, const char *file, size_t from);
333
347
358int downloader_file_size_get(struct downloader *dl, size_t *size);
359
370int downloader_downloaded_size_get(struct downloader *dl, size_t *size);
371
372#ifdef __cplusplus
373}
374#endif
375
376#endif /* __DOWNLOADER_H__ */
377
int downloader_init(struct downloader *dl, struct downloader_cfg *cfg)
Initialize the downloader.
int downloader_cancel(struct downloader *dl)
Cancel file download.
int downloader_get_with_host_and_file(struct downloader *dl, const struct downloader_host_cfg *host_cfg, const char *host, const char *file, size_t from)
Download a file asynchronously with host and file as separate parameters.
int downloader_get(struct downloader *dl, const struct downloader_host_cfg *host_cfg, const char *url, size_t from)
Download a file asynchronously.
int downloader_file_size_get(struct downloader *dl, size_t *size)
Retrieve the size of the file being downloaded, in bytes.
int downloader_deinit(struct downloader *dl)
Deinitialize the downloader.
downloader_state
Downloader internal state.
Definition downloader.h:214
@ DOWNLOADER_IDLE
Definition downloader.h:216
@ DOWNLOADER_DEINITIALIZED
Definition downloader.h:215
@ DOWNLOADER_DOWNLOADING
Definition downloader.h:219
@ DOWNLOADER_CONNECTING
Definition downloader.h:217
@ DOWNLOADER_DEINITIALIZING
Definition downloader.h:221
@ DOWNLOADER_CONNECTED
Definition downloader.h:218
@ DOWNLOADER_STOPPING
Definition downloader.h:220
int(* downloader_callback_t)(const struct downloader_evt *event)
Downloader asynchronous event handler.
Definition downloader.h:130
int downloader_downloaded_size_get(struct downloader *dl, size_t *size)
Retrieve the number of bytes downloaded so far.
downloader_evt_id
Downloader event IDs.
Definition downloader.h:33
@ DOWNLOADER_EVT_DEINITIALIZED
Definition downloader.h:84
@ DOWNLOADER_EVT_STOPPED
Definition downloader.h:82
@ DOWNLOADER_EVT_DONE
Definition downloader.h:80
@ DOWNLOADER_EVT_FRAGMENT
Definition downloader.h:40
@ DOWNLOADER_EVT_ERROR
Definition downloader.h:78
Definition downloader_transport.h:39
downloader_callback_t callback
Definition downloader.h:137
char * buf
Definition downloader.h:139
size_t buf_size
Definition downloader.h:141
Downloader configuration options.
Definition downloader.h:135
enum downloader_evt_id id
Definition downloader.h:102
struct downloader_fragment fragment
Definition downloader.h:108
int error
Definition downloader.h:106
Downloader event.
Definition downloader.h:100
const void * buf
Definition downloader.h:92
size_t len
Definition downloader.h:94
Downloader data fragment.
Definition downloader.h:90
bool keep_connection
Definition downloader.h:179
const char * proxy_uri
Definition downloader.h:199
uint8_t pdn_id
Definition downloader.h:163
const int * sec_tag_list
Definition downloader.h:153
const char * if_name
Definition downloader.h:208
bool cid
Definition downloader.h:184
uint8_t redirects_max
Definition downloader.h:204
size_t range_override
Definition downloader.h:171
int(* auth_cb)(int sock)
Definition downloader.h:194
uint8_t sec_tag_count
Definition downloader.h:158
bool set_native_tls
Definition downloader.h:173
int family
Definition downloader.h:189
Downloader host configuration options.
Definition downloader.h:147
size_t progress
Definition downloader.h:241
const struct dl_transport * transport
Definition downloader.h:251
char file[CONFIG_DOWNLOADER_MAX_FILENAME_SIZE]
Definition downloader.h:237
K_KERNEL_STACK_MEMBER(thread_stack, CONFIG_DOWNLOADER_STACK_SIZE)
k_tid_t tid
Definition downloader.h:264
char hostname[CONFIG_DOWNLOADER_MAX_HOSTNAME_SIZE]
Definition downloader.h:235
struct downloader_host_cfg host_cfg
Definition downloader.h:233
size_t buf_offset
Definition downloader.h:243
bool complete
Definition downloader.h:245
size_t file_size
Definition downloader.h:239
enum downloader_state state
Definition downloader.h:260
struct k_mutex mutex
Definition downloader.h:258
struct k_thread thread
Definition downloader.h:262
struct k_sem event_sem
Definition downloader.h:256
uint8_t transport_internal[CONFIG_DOWNLOADER_TRANSPORT_PARAMS_SIZE]
Definition downloader.h:253
struct downloader_cfg cfg
Definition downloader.h:231
Downloader instance.
Definition downloader.h:229