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