Mistake on this page? Email us
fota_candidate.h
1 // ----------------------------------------------------------------------------
2 // Copyright 2019-2021 Pelion Ltd.
3 //
4 // SPDX-License-Identifier: Apache-2.0
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17 // ----------------------------------------------------------------------------
18 
19 #ifndef __FOTA_CANDIDATE_H_
20 #define __FOTA_CANDIDATE_H_
21 
22 #include "fota/fota_base.h"
23 
24 #if defined(MBED_CLOUD_CLIENT_FOTA_ENABLE)
25 
26 #include "fota/fota_header_info.h"
27 #include "fota/fota_crypto_defs.h"
28 #include "fota/fota_comp_callbacks.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 // Block checksum (in case of resume and non encrypted blocks)
35 typedef uint16_t fota_candidate_block_checksum_t;
36 
47 typedef struct {
48  fota_candidate_iterate_status status;
49  size_t frag_size;
50  size_t frag_pos;
51  uint8_t *frag_buf;
52  fota_header_info_t *header_info;
53  void *user_ctx;
54 } fota_candidate_iterate_callback_info;
55 
62 typedef struct {
63  size_t storage_size;
64  size_t storage_start_addr;
65 } fota_candidate_config_t;
66 
73 void fota_candidate_set_config(fota_candidate_config_t *in_fota_candidate_config);
74 
80 const fota_candidate_config_t *fota_candidate_get_config(void);
81 
89 fota_deprecated typedef int (*fota_candidate_iterate_handler_t)(fota_candidate_iterate_callback_info *info);
90 
91 #define FOTA_CANDIDATE_SKIP_VALIDATION 0x27
92 
103 int fota_candidate_iterate_image_backward_support(uint8_t validate, bool force_encrypt, const char *expected_comp_name,
104  uint32_t install_alignment, fota_candidate_iterate_handler_t handler);
105 
117 int fota_candidate_iterate_image(uint8_t validate, bool force_encrypt, const char *expected_comp_name,
118  uint32_t install_alignment, fota_candidate_iterate_handler_t handler, fota_comp_install_cb_t component_install_cb);
119 
129 int fota_candidate_read_candidate_ready_header(size_t *addr, uint32_t bd_read_size, uint32_t bd_prog_size,
130  fota_candidate_ready_header_t *header);
131 
141 int fota_candidate_read_header(size_t *addr, uint32_t bd_read_size, uint32_t bd_prog_size, fota_header_info_t *header);
142 
148 int fota_candidate_erase(void);
149 
150 #ifdef __cplusplus
151 }
152 #endif
153 
154 #endif // defined(MBED_CLOUD_CLIENT_FOTA_ENABLE)
155 
156 #endif // __FOTA_CANDIDATE_H_