AWS IoT Over-the-air Update  v3.0.0
Client library for AWS IoT OTA
ota_os_interface.h
Go to the documentation of this file.
1 /*
2  * AWS IoT Over-the-air Update v3.0.0
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 
29 #ifndef OTA_OS_INTERFACE_H
30 #define OTA_OS_INTERFACE_H
31 
32 
71 struct OtaEventContext;
72 
76 typedef struct OtaEventContext OtaEventContext_t;
77 
81 typedef enum
82 {
83  OtaRequestTimer = 0,
84  OtaSelfTestTimer,
85  OtaNumOfTimers
86 } OtaTimerId_t;
87 
92 typedef enum OtaOsStatus
93 {
105 
116 typedef OtaOsStatus_t ( * OtaInitEvent_t ) ( OtaEventContext_t * pEventCtx );
117 
132 typedef OtaOsStatus_t ( * OtaSendEvent_t )( OtaEventContext_t * pEventCtx,
133  const void * pEventMsg,
134  unsigned int timeout );
135 
151  void * pEventMsg,
152  uint32_t timeout );
153 
165 typedef OtaOsStatus_t ( * OtaDeinitEvent_t )( OtaEventContext_t * pEventCtx );
166 
177 typedef void ( * OtaTimerCallback_t )( OtaTimerId_t otaTimerId );
178 
195 typedef OtaOsStatus_t ( * OtaStartTimer_t ) ( OtaTimerId_t otaTimerId,
196  const char * const pTimerName,
197  const uint32_t timeout,
198  OtaTimerCallback_t callback );
199 
210 typedef OtaOsStatus_t ( * OtaStopTimer_t ) ( OtaTimerId_t otaTimerId );
211 
222 typedef OtaOsStatus_t ( * OtaDeleteTimer_t ) ( OtaTimerId_t otaTimerId );
223 
235 typedef void * ( * OtaMalloc_t ) ( size_t size );
236 
249 typedef void ( * OtaFree_t ) ( void * ptr );
250 
255 typedef struct OtaEventInterface
256 {
263 
268 typedef struct OtaTimerInterface
269 {
274 
279 typedef struct OtaMallocInterface
280 {
281  /* MISRA rule 21.3 prohibits the use of malloc and free from stdlib.h, however, we're only
282  * defining the interface here. On FreeRTOS this is implemented with pvPortMalloc and vPortFree,
283  * and on Linux it's implemented with standard C malloc and free. This is a false positive. */
284  /* coverity[misra_c_2012_rule_21_3_violation] */
286  /* coverity[misra_c_2012_rule_21_3_violation] */
289 
294 typedef struct OtaOSInterface
295 {
300 
301 #endif /* ifndef OTA_OS_INTERFACE_H */
OtaEventInterface_t
Definition: ota_os_interface.h:256
OtaEventInterface_t::init
OtaInitEvent_t init
Initialization event.
Definition: ota_os_interface.h:257
OtaEventInterface_t::recv
OtaReceiveEvent_t recv
Receive data.
Definition: ota_os_interface.h:259
OtaOsSuccess
@ OtaOsSuccess
OTA OS interface success.
Definition: ota_os_interface.h:94
OtaEventContext_t
struct OtaEventContext OtaEventContext_t
Type definition for Event Context.
Definition: ota_os_interface.h:76
OtaReceiveEvent_t
OtaOsStatus_t(* OtaReceiveEvent_t)(OtaEventContext_t *pEventCtx, void *pEventMsg, uint32_t timeout)
Receive an OTA event.
Definition: ota_os_interface.h:150
OtaTimerCallback_t
void(* OtaTimerCallback_t)(OtaTimerId_t otaTimerId)
Timer callback.
Definition: ota_os_interface.h:177
OtaMallocInterface_t
OTA memory allocation interface.
Definition: ota_os_interface.h:280
OtaMalloc_t
void *(* OtaMalloc_t)(size_t size)
Allocate memory.
Definition: ota_os_interface.h:235
OtaSendEvent_t
OtaOsStatus_t(* OtaSendEvent_t)(OtaEventContext_t *pEventCtx, const void *pEventMsg, unsigned int timeout)
Sends an OTA event.
Definition: ota_os_interface.h:132
OtaOsEventQueueReceiveFailed
@ OtaOsEventQueueReceiveFailed
Failed to receive from the event queue.
Definition: ota_os_interface.h:97
OtaFree_t
void(* OtaFree_t)(void *ptr)
Free memory.
Definition: ota_os_interface.h:249
OtaOSInterface_t::event
OtaEventInterface_t event
OTA Event interface.
Definition: ota_os_interface.h:296
OtaOSInterface_t
OTA OS Interface.
Definition: ota_os_interface.h:295
OtaMallocInterface_t::malloc
OtaMalloc_t malloc
OTA memory allocate interface.
Definition: ota_os_interface.h:285
OtaEventInterface_t::pEventContext
OtaEventContext_t * pEventContext
Event context to store event information.
Definition: ota_os_interface.h:261
OtaDeinitEvent_t
OtaOsStatus_t(* OtaDeinitEvent_t)(OtaEventContext_t *pEventCtx)
Deinitialize the OTA Events mechanism.
Definition: ota_os_interface.h:165
OtaOSInterface_t::timer
OtaTimerInterface_t timer
OTA Timer interface.
Definition: ota_os_interface.h:297
OtaTimerInterface_t::startTimer
OtaStartTimer_t startTimer
Timer start state.
Definition: ota_os_interface.h:270
OtaTimerInterface_t
OTA Retry Timer Interface.
Definition: ota_os_interface.h:269
OtaOsTimerStartFailed
@ OtaOsTimerStartFailed
Failed to create the timer.
Definition: ota_os_interface.h:100
OtaOsTimerStopFailed
@ OtaOsTimerStopFailed
Failed to stop the timer.
Definition: ota_os_interface.h:102
OtaTimerId_t
OtaTimerId_t
Enumeration for tracking multiple timers.
Definition: ota_os_interface.h:82
OtaOsTimerDeleteFailed
@ OtaOsTimerDeleteFailed
Failed to delete the timer.
Definition: ota_os_interface.h:103
OtaEventInterface_t::send
OtaSendEvent_t send
Send data.
Definition: ota_os_interface.h:258
OtaOsStatus_t
OtaOsStatus_t
The OTA OS interface return status.
Definition: ota_os_interface.h:93
OtaEventInterface_t::deinit
OtaDeinitEvent_t deinit
Deinitialize event.
Definition: ota_os_interface.h:260
OtaTimerInterface_t::deleteTimer
OtaDeleteTimer_t deleteTimer
Delete timer.
Definition: ota_os_interface.h:272
OtaOsEventQueueDeleteFailed
@ OtaOsEventQueueDeleteFailed
Failed to delete the event queue.
Definition: ota_os_interface.h:98
OtaOsTimerCreateFailed
@ OtaOsTimerCreateFailed
Failed to create the timer.
Definition: ota_os_interface.h:99
OtaOsEventQueueCreateFailed
@ OtaOsEventQueueCreateFailed
Failed to create the event queue.
Definition: ota_os_interface.h:95
OtaDeleteTimer_t
OtaOsStatus_t(* OtaDeleteTimer_t)(OtaTimerId_t otaTimerId)
Delete a timer.
Definition: ota_os_interface.h:222
OtaOsEventQueueSendFailed
@ OtaOsEventQueueSendFailed
Posting event message to the event queue failed.
Definition: ota_os_interface.h:96
OtaOSInterface_t::mem
OtaMallocInterface_t mem
OTA memory interface.
Definition: ota_os_interface.h:298
OtaOsTimerRestartFailed
@ OtaOsTimerRestartFailed
Failed to restart the timer.
Definition: ota_os_interface.h:101
OtaInitEvent_t
OtaOsStatus_t(* OtaInitEvent_t)(OtaEventContext_t *pEventCtx)
Initialize the OTA events.
Definition: ota_os_interface.h:116
OtaStopTimer_t
OtaOsStatus_t(* OtaStopTimer_t)(OtaTimerId_t otaTimerId)
Stop timer.
Definition: ota_os_interface.h:210
OtaTimerInterface_t::stopTimer
OtaStopTimer_t stopTimer
Timer stop state.
Definition: ota_os_interface.h:271
OtaStartTimer_t
OtaOsStatus_t(* OtaStartTimer_t)(OtaTimerId_t otaTimerId, const char *const pTimerName, const uint32_t timeout, OtaTimerCallback_t callback)
Start timer.
Definition: ota_os_interface.h:195
OtaMallocInterface_t::free
OtaFree_t free
OTA memory deallocate interface.
Definition: ota_os_interface.h:287