AWS IoT Over-the-air Update v3.4.0
Client library for AWS IoT OTA
ota_platform_interface.h
Go to the documentation of this file.
1/*
2 * AWS IoT Over-the-air Update v3.4.0
3 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 *
5 * SPDX-License-Identifier: MIT
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy of
8 * this software and associated documentation files (the "Software"), to deal in
9 * the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11 * the Software, and to permit persons to whom the Software is furnished to do so,
12 * subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
30#ifndef OTA_PLATFORM_INTERFACE
31#define OTA_PLATFORM_INTERFACE
32
33/* *INDENT-OFF* */
34#ifdef __cplusplus
35 extern "C" {
36#endif
37/* *INDENT-ON* */
38
39#include "ota_private.h"
40
69typedef uint32_t OtaPalStatus_t;
70
74typedef uint32_t OtaPalSubStatus_t;
75
80typedef uint32_t OtaPalMainStatus_t;
81#define OtaPalSuccess 0x0U
82#define OtaPalUninitialized 0xe0U
83#define OtaPalOutOfMemory 0xe1U
84#define OtaPalNullFileContext 0xe2U
85#define OtaPalSignatureCheckFailed 0xe3U
86#define OtaPalRxFileCreateFailed 0xe4U
87#define OtaPalRxFileTooLarge 0xe5U
88#define OtaPalBootInfoCreateFailed 0xe6U
89#define OtaPalBadSignerCert 0xe7U
90#define OtaPalBadImageState 0xe8U
91#define OtaPalAbortFailed 0xe9U
92#define OtaPalRejectFailed 0xeaU
93#define OtaPalCommitFailed 0xebU
94#define OtaPalActivateFailed 0xecU
95#define OtaPalFileAbort 0xedU
96#define OtaPalFileClose 0xeeU
111/* @[define_ota_err_code_helpers] */
112#define OTA_PAL_ERR_MASK 0xffffffUL
113#define OTA_PAL_SUB_BITS 24U
114#define OTA_PAL_MAIN_ERR( err ) ( ( OtaPalMainStatus_t ) ( uint32_t ) ( ( uint32_t ) ( err ) >> ( uint32_t ) OTA_PAL_SUB_BITS ) )
115#define OTA_PAL_SUB_ERR( err ) ( ( ( uint32_t ) ( err ) ) & ( ( uint32_t ) OTA_PAL_ERR_MASK ) )
116#define OTA_PAL_COMBINE_ERR( main, sub ) ( ( ( uint32_t ) ( main ) << ( uint32_t ) OTA_PAL_SUB_BITS ) | ( uint32_t ) OTA_PAL_SUB_ERR( sub ) )
117/* @[define_ota_err_code_helpers] */
118
139typedef OtaPalStatus_t ( * OtaPalAbort_t )( OtaFileContext_t * const pFileContext );
140
164typedef OtaPalStatus_t (* OtaPalCreateFileForRx_t)( OtaFileContext_t * const pFileContext );
165
190typedef OtaPalStatus_t ( * OtaPalCloseFile_t )( OtaFileContext_t * const pFileContext );
191
215typedef int16_t ( * OtaPalWriteBlock_t ) ( OtaFileContext_t * const pFileContext,
216 uint32_t offset,
217 uint8_t * const pData,
218 uint32_t blockSize );
219
232typedef OtaPalStatus_t ( * OtaPalActivateNewImage_t )( OtaFileContext_t * const pFileContext );
233
246typedef OtaPalStatus_t ( * OtaPalResetDevice_t ) ( OtaFileContext_t * const pFileContext );
247
270 OtaImageState_t eState );
271
296
301typedef struct OtaPalInterface
302{
303 /* MISRA rule 21.8 prohibits the use of abort from stdlib.h. However, this is merely one of the
304 * OTA platform abstraction layer interfaces, which is used to abort an OTA update. So it's a
305 * false positive. */
306 /* MISRA Ref 21.8.1 [Standard library includes] */
307 /* More details at: https://github.com/aws/ota-for-aws-iot-embedded-sdk/blob/main/MISRA.md#rule-101 */
308 /* coverity[misra_c_2012_rule_21_8_violation] */
318
319/* *INDENT-OFF* */
320#ifdef __cplusplus
321 }
322#endif
323/* *INDENT-ON* */
324
325#endif /* ifndef OTA_PLATFORM_INTERFACE */
uint32_t OtaPalMainStatus_t
The OTA platform interface main status.
Definition: ota_platform_interface.h:80
OtaPalImageState_t
OTA Platform Image State.
Definition: ota_private.h:333
OtaImageState_t
OTA Image states.
Definition: ota_private.h:316
uint32_t OtaPalSubStatus_t
The OTA platform interface sub status.
Definition: ota_platform_interface.h:74
uint32_t OtaPalStatus_t
The OTA platform interface return status. Composed of main and sub status.
Definition: ota_platform_interface.h:69
OtaPalStatus_t(* OtaPalCreateFileForRx_t)(OtaFileContext_t *const pFileContext)
Create a new receive file for the data chunks as they come in.
Definition: ota_platform_interface.h:164
OtaPalStatus_t(* OtaPalCloseFile_t)(OtaFileContext_t *const pFileContext)
Authenticate and close the underlying receive file in the specified OTA context.
Definition: ota_platform_interface.h:190
OtaPalImageState_t(* OtaPalGetPlatformImageState_t)(OtaFileContext_t *const pFileContext)
Get the state of the OTA update image.
Definition: ota_platform_interface.h:295
OtaPalStatus_t(* OtaPalResetDevice_t)(OtaFileContext_t *const pFileContext)
Reset the device.
Definition: ota_platform_interface.h:246
OtaPalStatus_t(* OtaPalActivateNewImage_t)(OtaFileContext_t *const pFileContext)
Activate the newest MCU image received via OTA.
Definition: ota_platform_interface.h:232
OtaPalStatus_t(* OtaPalAbort_t)(OtaFileContext_t *const pFileContext)
Abort an OTA transfer.
Definition: ota_platform_interface.h:139
OtaPalStatus_t(* OtaPalSetPlatformImageState_t)(OtaFileContext_t *const pFileContext, OtaImageState_t eState)
Attempt to set the state of the OTA update image.
Definition: ota_platform_interface.h:269
int16_t(* OtaPalWriteBlock_t)(OtaFileContext_t *const pFileContext, uint32_t offset, uint8_t *const pData, uint32_t blockSize)
Write a block of data to the specified file at the given offset.
Definition: ota_platform_interface.h:215
Macros, enums, variables, and definitions internal to the OTA Agent module and shared by other OTA mo...
OTA File Context Information.
Definition: ota_private.h:384
OTA pal Interface structure.
Definition: ota_platform_interface.h:302
OtaPalSetPlatformImageState_t setPlatformImageState
Set the state of the OTA update image.
Definition: ota_platform_interface.h:315
OtaPalWriteBlock_t writeBlock
Write a block of data to the specified file at the given offset.
Definition: ota_platform_interface.h:312
OtaPalResetDevice_t reset
Reset the device.
Definition: ota_platform_interface.h:314
OtaPalAbort_t abort
Abort an OTA transfer.
Definition: ota_platform_interface.h:309
OtaPalGetPlatformImageState_t getPlatformImageState
Get the state of the OTA update image.
Definition: ota_platform_interface.h:316
OtaPalCreateFileForRx_t createFile
Create a new receive file.
Definition: ota_platform_interface.h:310
OtaPalActivateNewImage_t activate
Activate the file received over-the-air.
Definition: ota_platform_interface.h:313
OtaPalCloseFile_t closeFile
Authenticate and close the receive file.
Definition: ota_platform_interface.h:311