nRF Connect SDK API 2.8.0
Loading...
Searching...
No Matches
dfu_target_stream.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
15#ifndef DFU_TARGET_STREAM_H__
16#define DFU_TARGET_STREAM_H__
17
18#include <stddef.h>
19#include <zephyr/storage/stream_flash.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25struct stream_flash_ctx *dfu_target_stream_get_stream(void);
26
29 /* The identifier of the stream, used for storing settings.*/
30 const char *id;
31
32 /* Flash device that the stream should be written to. */
33 const struct device *fdev;
34
35 /* Buffer used for stream flash writing. The length of the
36 * buffer must be smaller than a page size of `fdev`.
37 */
38 uint8_t *buf;
39
40 /* Length of `buf` */
41 size_t len;
42
43 /* Offset within `fdev` to write the stream to. */
44 size_t offset;
45
46 /* The number of bytes within fdev to use for the stream.
47 * Set to 0 to use all available memory in the device
48 * (starting from `offset`).
49 */
50 size_t size;
51
52 /* Callback invoked upon successful flash write operations. This
53 * can be used to inspect the actual written data.
54 */
55 stream_flash_callback_t cb;
56};
57
66
80int dfu_target_stream_offset_get(size_t *offset);
81
90int dfu_target_stream_write(const uint8_t *buf, size_t len);
91
100int dfu_target_stream_done(bool successful);
101
110
111#ifdef __cplusplus
112}
113#endif
114
115#endif /* DFU_TARGET_STREAM_H__ */
116
int dfu_target_stream_done(bool successful)
Release resources and finalize stream flash write if successful.
int dfu_target_stream_init(const struct dfu_target_stream_init *init)
Initialize dfu target.
struct stream_flash_ctx * dfu_target_stream_get_stream(void)
int dfu_target_stream_write(const uint8_t *buf, size_t len)
Write a chunk of firmware data.
int dfu_target_stream_offset_get(size_t *offset)
Get the offset within the payload of the next byte to download.
int dfu_target_stream_reset(void)
Release resources and erase the download area.
stream_flash_callback_t cb
Definition dfu_target_stream.h:55
const struct device * fdev
Definition dfu_target_stream.h:33
const char * id
Definition dfu_target_stream.h:30
size_t offset
Definition dfu_target_stream.h:44
size_t size
Definition dfu_target_stream.h:50
size_t len
Definition dfu_target_stream.h:41
uint8_t * buf
Definition dfu_target_stream.h:38
DFU target stream initialization structure.
Definition dfu_target_stream.h:28