AWS IoT Over-the-air Update v2.0.0 (Release Candidate)
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 v2.0.0 (Release Candidate)
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
71struct OtaEventContext;
72
76typedef struct OtaEventContext OtaEventContext_t;
77
78struct OtaTimerContext;
79
83typedef struct OtaTimerContext OtaTimerContext_t;
84
88typedef enum
89{
90 OtaRequestTimer = 0,
91 OtaSelfTestTimer,
92 OtaNumOfTimers
94
99typedef enum OtaOsStatus
100{
112
123typedef OtaOsStatus_t ( * OtaInitEvent_t ) ( OtaEventContext_t * pEventCtx );
124
140 const void * pEventMsg,
141 unsigned int timeout );
142
158 void * pEventMsg,
159 uint32_t timeout );
160
173
184typedef void ( * OtaTimerCallback_t )( OtaTimerId_t otaTimerId );
185
202typedef OtaOsStatus_t ( * OtaStartTimer_t ) ( OtaTimerId_t otaTimerId,
203 const char * const pTimerName,
204 const uint32_t timeout,
205 OtaTimerCallback_t callback );
206
217typedef OtaOsStatus_t ( * OtaStopTimer_t ) ( OtaTimerId_t otaTimerId );
218
229typedef OtaOsStatus_t ( * OtaDeleteTimer_t ) ( OtaTimerId_t otaTimerId );
230
242typedef void * ( * OtaMalloc_t ) ( size_t size );
243
256typedef void ( * OtaFree_t ) ( void * ptr );
257
262typedef struct OtaEventInterface
263{
270
275typedef struct OtaTimerInterface
276{
281
286typedef struct OtaMallocInterface
287{
288 /* MISRA rule 21.3 prohibits the use of malloc and free from stdlib.h, however, we're only
289 * defining the interface here. On FreeRTOS this is implemented with pvPortMalloc and vPortFree,
290 * and on Linux it's implemented with standard C malloc and free. This is a false positive. */
291 /* coverity[misra_c_2012_rule_21_3_violation] */
293 /* coverity[misra_c_2012_rule_21_3_violation] */
296
301typedef struct OtaOSInterface
302{
307
308#endif /* ifndef OTA_OS_INTERFACE_H */
OtaOsStatus_t
The OTA OS interface return status.
Definition: ota_os_interface.h:100
@ OtaOsEventQueueSendFailed
Posting event message to the event queue failed.
Definition: ota_os_interface.h:103
@ OtaOsTimerDeleteFailed
Failed to delete the timer.
Definition: ota_os_interface.h:110
@ OtaOsTimerCreateFailed
Failed to create the timer.
Definition: ota_os_interface.h:106
@ OtaOsEventQueueReceiveFailed
Failed to receive from the event queue.
Definition: ota_os_interface.h:104
@ OtaOsTimerStopFailed
Failed to stop the timer.
Definition: ota_os_interface.h:109
@ OtaOsEventQueueCreateFailed
Failed to create the event queue.
Definition: ota_os_interface.h:102
@ OtaOsTimerRestartFailed
Failed to restart the timer.
Definition: ota_os_interface.h:108
@ OtaOsSuccess
OTA OS interface success.
Definition: ota_os_interface.h:101
@ OtaOsTimerStartFailed
Failed to create the timer.
Definition: ota_os_interface.h:107
@ OtaOsEventQueueDeleteFailed
Failed to delete the event queue.
Definition: ota_os_interface.h:105
void(* OtaFree_t)(void *ptr)
Free memory.
Definition: ota_os_interface.h:256
OtaOsStatus_t(* OtaDeleteTimer_t)(OtaTimerId_t otaTimerId)
Delete a timer.
Definition: ota_os_interface.h:229
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:202
struct OtaEventContext OtaEventContext_t
Type definition for Event Context.
Definition: ota_os_interface.h:76
void(* OtaTimerCallback_t)(OtaTimerId_t otaTimerId)
Timer callback.
Definition: ota_os_interface.h:184
void *(* OtaMalloc_t)(size_t size)
Allocate memory.
Definition: ota_os_interface.h:242
OtaOsStatus_t(* OtaDeinitEvent_t)(OtaEventContext_t *pEventCtx)
Deinitialize the OTA Events mechanism.
Definition: ota_os_interface.h:172
OtaOsStatus_t(* OtaSendEvent_t)(OtaEventContext_t *pEventCtx, const void *pEventMsg, unsigned int timeout)
Sends an OTA event.
Definition: ota_os_interface.h:139
OtaOsStatus_t(* OtaInitEvent_t)(OtaEventContext_t *pEventCtx)
Initialize the OTA events.
Definition: ota_os_interface.h:123
OtaOsStatus_t(* OtaReceiveEvent_t)(OtaEventContext_t *pEventCtx, void *pEventMsg, uint32_t timeout)
Receive an OTA event.
Definition: ota_os_interface.h:157
struct OtaTimerContext OtaTimerContext_t
Type definition for Timer Context.
Definition: ota_os_interface.h:83
OtaOsStatus_t(* OtaStopTimer_t)(OtaTimerId_t otaTimerId)
Stop timer.
Definition: ota_os_interface.h:217
OtaTimerId_t
Enumeration for tracking multiple timers.
Definition: ota_os_interface.h:89
Definition: ota_os_interface.h:263
OtaSendEvent_t send
Send data.
Definition: ota_os_interface.h:265
OtaDeinitEvent_t deinit
Deinitialize event.
Definition: ota_os_interface.h:267
OtaEventContext_t * pEventContext
Event context to store event information.
Definition: ota_os_interface.h:268
OtaInitEvent_t init
Initialization event.
Definition: ota_os_interface.h:264
OtaReceiveEvent_t recv
Receive data.
Definition: ota_os_interface.h:266
OTA memory allocation interface.
Definition: ota_os_interface.h:287
OtaFree_t free
OTA memory deallocate interface.
Definition: ota_os_interface.h:294
OtaMalloc_t malloc
OTA memory allocate interface.
Definition: ota_os_interface.h:292
OTA OS Interface.
Definition: ota_os_interface.h:302
OtaMallocInterface_t mem
OTA memory interface.
Definition: ota_os_interface.h:305
OtaEventInterface_t event
OTA Event interface.
Definition: ota_os_interface.h:303
OtaTimerInterface_t timer
OTA Timer interface.
Definition: ota_os_interface.h:304
OTA Retry Timer Interface.
Definition: ota_os_interface.h:276
OtaStartTimer_t start
Timer start state.
Definition: ota_os_interface.h:277
OtaStopTimer_t stop
Timer stop state.
Definition: ota_os_interface.h:278