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 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
38 typedef enum {
39  FOTA_CANDIDATE_ITERATE_START,
40  FOTA_CANDIDATE_ITERATE_FRAGMENT,
41  FOTA_CANDIDATE_ITERATE_FINISH,
42 } fota_candidate_iterate_status;
43 
44 // Block checksum (in case of resume and non encrypted blocks)
45 typedef uint16_t fota_candidate_block_checksum_t;
46 
57 typedef struct {
58  fota_candidate_iterate_status status;
59  size_t frag_size;
60  size_t frag_pos;
61  uint8_t *frag_buf;
62  fota_header_info_t *header_info;
63  void *user_ctx;
65 
72 typedef struct {
73  size_t storage_size;
74  size_t storage_start_addr;
76 
83 void fota_candidate_set_config(fota_candidate_config_t *in_fota_candidate_config);
84 
90 const fota_candidate_config_t *fota_candidate_get_config(void);
91 
98 typedef int (*fota_candidate_iterate_handler_t)(fota_candidate_iterate_callback_info *info);
99 
100 #define FOTA_CANDIDATE_SKIP_VALIDATION 0x27
101 
112 int fota_candidate_iterate_image(uint8_t validate, bool force_encrypt, const char *expected_comp_name,
113  uint32_t install_alignment, fota_candidate_iterate_handler_t handler);
114 
124 int fota_candidate_read_candidate_ready_header(size_t *addr, uint32_t bd_read_size, uint32_t bd_prog_size,
125  fota_candidate_ready_header_t *header);
126 
136 int fota_candidate_read_header(size_t *addr, uint32_t bd_read_size, uint32_t bd_prog_size, fota_header_info_t *header);
137 
143 int fota_candidate_erase(void);
144 
145 #ifdef __cplusplus
146 }
147 #endif
148 
149 #endif // defined(MBED_CLOUD_CLIENT_FOTA_ENABLE)
150 
151 #endif // __FOTA_CANDIDATE_H_
Definition: fota_candidate.h:57
Definition: fota_candidate.h:72