Mistake on this page? Email us
fota_component.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_COMPONENT_H_
20 #define __FOTA_COMPONENT_H_
21 
22 #include "fota/fota_base.h"
23 
24 #if defined(MBED_CLOUD_CLIENT_FOTA_ENABLE)
25 
26 #include "fota/fota_component_defs.h"
27 #include "fota/fota_crypto_defs.h"
28 #include "fota/fota_comp_callbacks.h"
29 #include "fota/fota_candidate.h"
30 #include "fota/fota_header_info.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
52 typedef int (*fota_component_curr_fw_read)(uint8_t *buf, size_t offset, size_t size, size_t *num_read);
53 
63 typedef int (*fota_component_curr_fw_get_digest)(uint8_t *buf);
64 
89 typedef struct {
90  uint32_t install_alignment;
91  bool support_delta;
92  bool need_reboot;
93 #if !defined(TARGET_LIKE_LINUX)
94  fota_candidate_iterate_handler_t candidate_iterate_cb;
95 #endif
96  fota_component_verify_install_handler_t component_verify_install_cb;
97  fota_component_curr_fw_read curr_fw_read;
98  fota_component_curr_fw_get_digest curr_fw_get_digest;
99  fota_comp_install_cb_t component_install_cb;
100  fota_comp_verify_cb_t component_verify_cb;
101  fota_comp_finalize_cb_t component_finalize_cb;
102 } fota_component_desc_info_t;
103 
117 int fota_component_add(const fota_component_desc_info_t *comp_desc, const char *comp_name, const char *comp_semver);
118 
130 int fota_component_version_int_to_semver(fota_component_version_t version, char *sem_ver);
131 
132 #ifdef __cplusplus
133 }
134 #endif
135 
136 #endif // defined(MBED_CLOUD_CLIENT_FOTA_ENABLE)
137 #endif // __FOTA_COMPONENT_H_