-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathdfu_target_custom.h
92 lines (80 loc) · 2.61 KB
/
dfu_target_custom.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
/**
* @file dfu_target_custom.h
* @defgroup dfu_target_custom Custom DFU Target
* @{
* @brief Custom DFU (Device Firmware Update) target implementation.
*
* This file contains the function declarations for a custom DFU target implementation.
* It provides function prototypes for identifying, initializing, writing, and finalizing a custom
* firmware update process.
*/
#ifndef DFU_TARGET_CUSTOM_H__
#define DFU_TARGET_CUSTOM_H__
#include <dfu/dfu_target.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Check if the provided buffer contains a custom firmware image.
*
* @param[in] buf Pointer to the buffer containing the potential firmware image.
* @retval true if the buffer contains a valid custom firmware image, false otherwise.
*/
bool dfu_target_custom_identify(const void *const buf);
/**
* @brief Initialize the custom DFU target.
*
* @param[in] file_size Size of the firmware file to be written.
* @param[in] img_num Image number for multi-image DFU.
* @param[in] cb Callback function to be called during the DFU process.
* @retval 0 on success, negative errno code on failure.
*/
int dfu_target_custom_init(size_t file_size, int img_num, dfu_target_callback_t cb);
/**
* @brief Get the current write offset for the custom DFU target.
*
* @param[out] offset Pointer to store the current write offset.
* @retval 0 on success, negative errno code on failure.
*/
int dfu_target_custom_offset_get(size_t *offset);
/**
* @brief Write data to the custom DFU target.
*
* @param[in] buf Pointer to the buffer containing the data to be written.
* @param[in] len Length of the data to be written.
* @retval 0 on success, negative errno code on failure.
*/
int dfu_target_custom_write(const void *const buf, size_t len);
/**
* @brief Release resources and finalize the custom DFU process if successful.
*
* @param[in] successful True if the DFU process was successful, false otherwise.
* @retval 0 on success, negative errno code on failure.
*/
int dfu_target_custom_done(bool successful);
/**
* @brief Schedule an update for the custom DFU target.
*
* @param[in] img_num Image number for multi-image DFU.
* @retval 0 on success, negative errno code on failure.
*/
int dfu_target_custom_schedule_update(int img_num);
/**
* @brief Release resources and erase the download area.
*
* Cancel any ongoing updates.
*
* @retval 0 on success, negative errno code on failure.
*/
int dfu_target_custom_reset(void);
#ifdef __cplusplus
}
#endif
#endif /* DFU_TARGET_SUIT_H__ */
/**@} */