nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
dfu_target.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
7#ifndef DFU_TARGET_H__
8#define DFU_TARGET_H__
9
17#include <zephyr/types.h>
18#include <stdbool.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
50};
51
56};
57
58typedef void (*dfu_target_callback_t)(enum dfu_target_evt_id evt_id);
59
62struct dfu_target {
63 int (*init)(size_t file_size, int img_num, dfu_target_callback_t cb);
64 int (*offset_get)(size_t *offset);
65 int (*write)(const void *const buf, size_t len);
66 int (*done)(bool successful);
67 int (*schedule_update)(int img_num);
68 int (*reset)();
69};
70
82enum dfu_target_image_type dfu_target_img_type(const void *const buf, size_t len);
83
95enum dfu_target_image_type dfu_target_smp_img_type_check(const void *const buf, size_t len);
96
120int dfu_target_init(int img_type, int img_num, size_t file_size, dfu_target_callback_t cb);
121
129int dfu_target_offset_get(size_t *offset);
130
141int dfu_target_write(const void *const buf, size_t len);
142
153int dfu_target_done(bool successful);
154
163
177
178#ifdef __cplusplus
179}
180#endif
181
184#endif /* DFU_TARGET_H__ */
int dfu_target_done(bool successful)
Release the resources that were needed for the current DFU target.
int dfu_target_init(int img_type, int img_num, size_t file_size, dfu_target_callback_t cb)
Initialize the resources needed for the specific image type DFU target.
int dfu_target_reset(void)
Release the resources that were needed for the current DFU target if any and resets the current DFU t...
enum dfu_target_image_type dfu_target_smp_img_type_check(const void *const buf, size_t len)
Find the image type for the buffer of bytes received. Used to validate type for DFU SMP target to ini...
dfu_target_evt_id
Definition: dfu_target.h:52
@ DFU_TARGET_EVT_ERASE_PENDING
Definition: dfu_target.h:53
@ DFU_TARGET_EVT_ERASE_DONE
Definition: dfu_target.h:55
@ DFU_TARGET_EVT_TIMEOUT
Definition: dfu_target.h:54
int dfu_target_write(const void *const buf, size_t len)
Write the given buffer to the initialized DFU target.
void(* dfu_target_callback_t)(enum dfu_target_evt_id evt_id)
Definition: dfu_target.h:58
int dfu_target_schedule_update(int img_num)
Schedule update of one or more images.
enum dfu_target_image_type dfu_target_img_type(const void *const buf, size_t len)
Find the image type for the buffer of bytes received. Used to determine what DFU target to initialize...
int dfu_target_offset_get(size_t *offset)
Get offset of the firmware upgrade.
dfu_target_image_type
DFU image type.
Definition: dfu_target.h:28
@ DFU_TARGET_IMAGE_TYPE_NONE
Definition: dfu_target.h:30
@ DFU_TARGET_IMAGE_TYPE_ANY_APPLICATION
Definition: dfu_target.h:42
@ DFU_TARGET_IMAGE_TYPE_ANY
Definition: dfu_target.h:47
@ DFU_TARGET_IMAGE_TYPE_ANY_MODEM
Definition: dfu_target.h:44
@ DFU_TARGET_IMAGE_TYPE_FULL_MODEM
Definition: dfu_target.h:36
@ DFU_TARGET_IMAGE_TYPE_SMP
Definition: dfu_target.h:38
@ DFU_TARGET_IMAGE_TYPE_MCUBOOT
Definition: dfu_target.h:32
@ DFU_TARGET_IMAGE_TYPE_MODEM_DELTA
Definition: dfu_target.h:34
@ DFU_TARGET_IMAGE_TYPE_SUIT
Definition: dfu_target.h:40
int(* init)(size_t file_size, int img_num, dfu_target_callback_t cb)
Definition: dfu_target.h:63
int(* done)(bool successful)
Definition: dfu_target.h:66
int(* write)(const void *const buf, size_t len)
Definition: dfu_target.h:65
int(* offset_get)(size_t *offset)
Definition: dfu_target.h:64
int(* reset)()
Definition: dfu_target.h:68
int(* schedule_update)(int img_num)
Definition: dfu_target.h:67
Functions which needs to be supported by all DFU targets.
Definition: dfu_target.h:62