Go to the documentation of this file.
31 #ifndef _AWS_IOT_OTA_AGENT_H_
32 #define _AWS_IOT_OTA_AGENT_H_
44 #define CONST_STRLEN( s ) ( ( ( uint32_t ) sizeof( s ) ) - 1UL )
47 #define OTA_FILE_SIG_KEY_STR_MAX_LENGTH 32
48 extern const char cOTA_JSON_FileSignatureKey[ OTA_FILE_SIG_KEY_STR_MAX_LENGTH ];
53 #define OTA_DEBUG_LOG_LEVEL 1
54 #if OTA_DEBUG_LOG_LEVEL >= 1
55 #define DEFINE_OTA_METHOD_NAME( name ) \
56 static const char OTA_METHOD_NAME[] = name; \
57 ( void ) OTA_METHOD_NAME;
58 #define OTA_LOG_L1 vLoggingPrintf
60 #define DEFINE_OTA_METHOD_NAME( name )
61 #define OTA_LOG_L1( ... )
63 #if OTA_DEBUG_LOG_LEVEL >= 2
64 #define DEFINE_OTA_METHOD_NAME_L2( name ) \
65 static const char OTA_METHOD_NAME[] = name; \
66 ( void ) OTA_METHOD_NAME;
67 #define OTA_LOG_L2 vLoggingPrintf
69 #define DEFINE_OTA_METHOD_NAME_L2( name )
70 #define OTA_LOG_L2( ... )
72 #if OTA_DEBUG_LOG_LEVEL >= 3
73 #define DEFINE_OTA_METHOD_NAME_L3( name ) \
74 static const char OTA_METHOD_NAME[] = name; \
75 ( void ) OTA_METHOD_NAME;
76 #define OTA_LOG_L3 vLoggingPrintf
78 #define DEFINE_OTA_METHOD_NAME_L3( name )
79 #define OTA_LOG_L3( ... )
98 eOTA_AgentState_NoTransition = -1,
99 eOTA_AgentState_Init = 0,
100 eOTA_AgentState_Ready,
101 eOTA_AgentState_RequestingJob,
102 eOTA_AgentState_WaitingForJob,
103 eOTA_AgentState_CreatingFile,
104 eOTA_AgentState_RequestingFileBlock,
105 eOTA_AgentState_WaitingForFileBlock,
106 eOTA_AgentState_ClosingFile,
107 eOTA_AgentState_Suspended,
108 eOTA_AgentState_ShuttingDown,
109 eOTA_AgentState_Stopped,
121 eOTA_AgentEvent_Start = 0,
122 eOTA_AgentEvent_StartSelfTest,
123 eOTA_AgentEvent_RequestJobDocument,
124 eOTA_AgentEvent_ReceivedJobDocument,
125 eOTA_AgentEvent_CreateFile,
126 eOTA_AgentEvent_RequestFileBlock,
127 eOTA_AgentEvent_ReceivedFileBlock,
128 eOTA_AgentEvent_RequestTimer,
129 eOTA_AgentEvent_CloseFile,
130 eOTA_AgentEvent_Suspend,
131 eOTA_AgentEvent_Resume,
132 eOTA_AgentEvent_UserAbort,
133 eOTA_AgentEvent_Shutdown,
145 eOTA_PAL_ImageState_Unknown = 0,
146 eOTA_PAL_ImageState_PendingCommit,
147 eOTA_PAL_ImageState_Valid,
148 eOTA_PAL_ImageState_Invalid,
157 eOTA_JobParseErr_Unknown = -1,
158 eOTA_JobParseErr_None = 0,
159 eOTA_JobParseErr_BusyWithExistingJob,
160 eOTA_JobParseErr_NullJob,
161 eOTA_JobParseErr_UpdateCurrentJob,
162 eOTA_JobParseErr_ZeroFileSize,
163 eOTA_JobParseErr_NonConformingJobDoc,
164 eOTA_JobParseErr_BadModelInitParams,
165 eOTA_JobParseErr_NoContextAvailable,
166 eOTA_JobParseErr_NoActiveJobs,
361 uint8_t *
const pacData,
362 uint32_t iBlockSize );
386 #define kOTA_MaxSignatureSize 256
401 typedef struct OTA_FileContext
437 void * pvControlClient;
438 const void * pxNetworkInterface;
439 void * pvNetworkCredentials;
484 #define kOTA_Err_Panic 0xfe000000UL
485 #define kOTA_Err_Uninitialized 0xff000000UL
486 #define kOTA_Err_None 0x00000000UL
487 #define kOTA_Err_SignatureCheckFailed 0x01000000UL
488 #define kOTA_Err_BadSignerCert 0x02000000UL
489 #define kOTA_Err_OutOfMemory 0x03000000UL
490 #define kOTA_Err_ActivateFailed 0x04000000UL
491 #define kOTA_Err_CommitFailed 0x05000000UL
492 #define kOTA_Err_RejectFailed 0x06000000UL
493 #define kOTA_Err_AbortFailed 0x07000000UL
494 #define kOTA_Err_PublishFailed 0x08000000UL
495 #define kOTA_Err_BadImageState 0x09000000UL
496 #define kOTA_Err_NoActiveJob 0x0a000000UL
497 #define kOTA_Err_NoFreeContext 0x0b000000UL
498 #define kOTA_Err_HTTPInitFailed 0x0c000000UL
499 #define kOTA_Err_HTTPRequestFailed 0x0d000000UL
500 #define kOTA_Err_FileAbort 0x10000000UL
501 #define kOTA_Err_FileClose 0x11000000UL
502 #define kOTA_Err_RxFileCreateFailed 0x12000000UL
503 #define kOTA_Err_BootInfoCreateFailed 0x13000000UL
504 #define kOTA_Err_RxFileTooLarge 0x14000000UL
505 #define kOTA_Err_NullFilePtr 0x20000000UL
506 #define kOTA_Err_MomentumAbort 0x21000000UL
507 #define kOTA_Err_DowngradeNotAllowed 0x22000000UL
508 #define kOTA_Err_SameFirmwareVersion 0x23000000UL
509 #define kOTA_Err_JobParserError 0x24000000UL
510 #define kOTA_Err_FailedToEncodeCBOR 0x25000000UL
511 #define kOTA_Err_ImageStateMismatch 0x26000000UL
512 #define kOTA_Err_GenericIngestError 0x27000000UL
513 #define kOTA_Err_UserAbort 0x28000000UL
514 #define kOTA_Err_ResetNotSupported 0x29000000UL
515 #define kOTA_Err_TopicTooLarge 0x2a000000UL
516 #define kOTA_Err_SelfTestTimerFailed 0x2b000000UL
517 #define kOTA_Err_EventQueueSendFailed 0x2c000000UL
518 #define kOTA_Err_InvalidDataProtocol 0x2d000000UL
519 #define kOTA_Err_OTAAgentStopped 0x2e000000UL
523 #define kOTA_PAL_ErrMask 0xffffffUL
524 #define kOTA_Main_ErrMask 0xff000000UL
525 #define kOTA_MainErrShiftDownBits 24U
584 const uint8_t * pucThingName,
586 TickType_t xTicksToWait );
608 const uint8_t * pucThingName,
610 TickType_t xTicksToWait );
uint32_t ulFileSize
Definition: aws_iot_ota_agent.h:413
Sig256_t * pxSignature
Definition: aws_iot_ota_agent.h:419
OTA_State_t OTA_GetAgentState(void)
Get the current state of the OTA agent.
OTA_State_t OTA_AgentInit(void *pvConnectionContext, const uint8_t *pucThingName, pxOTACompleteCallback_t xFunc, TickType_t xTicksToWait)
OTA Agent initialization function.
bool bIsInSelfTest
Definition: aws_iot_ota_agent.h:425
uint32_t OTA_GetPacketsProcessed(void)
Get the number of OTA message packets processed by the OTA agent.
uint32_t ulFileAttributes
Definition: aws_iot_ota_agent.h:415
OTA_Err_t OTA_SetImageState(OTA_ImageState_t eState)
Set the state of the current MCU image.
uint32_t OTA_Err_t
OTA Error type.
Definition: aws_iot_ota_agent.h:235
@ eOTA_ImageState_Testing
Definition: aws_iot_ota_agent.h:214
#define kOTA_MaxSignatureSize
Definition: aws_iot_ota_agent.h:386
@ eOTA_JobEvent_Activate
Definition: aws_iot_ota_agent.h:189
OTA_Err_t OTA_CheckForUpdate(void)
Request for the next available OTA job from the job service.
OTA_ImageState_t OTA_GetImageState(void)
Get the state of the currently running MCU image.
OTA_Err_t(* pxOTAPALActivateNewImageCallback_t)(uint32_t ulServerFileID)
OTA new image received callback function typedef.
Definition: aws_iot_ota_agent.h:288
OTA_PAL_ImageState_t(* pxOTAPALGetPlatformImageStateCallback_t)(uint32_t ulServerFileID)
OTA Get Platform Image State callback function typedef.
Definition: aws_iot_ota_agent.h:321
uint8_t * pucProtocols
Definition: aws_iot_ota_agent.h:426
OTA_Err_t(* pxOTAPALAbortCallback_t)(OTA_FileContext_t *const C)
OTA abort callback function typedef.
Definition: aws_iot_ota_agent.h:276
OTA_PAL_ImageState_t
OTA Platform Image State.
Definition: aws_iot_ota_agent.h:144
int32_t lFileHandle
Definition: aws_iot_ota_agent.h:406
void(* pxOTACompleteCallback_t)(OTA_JobEvent_t eEvent)
OTA update complete callback function typedef.
Definition: aws_iot_ota_agent.h:265
uint32_t OTA_GetPacketsQueued(void)
Get the number of OTA message packets queued by the OTA agent.
OTA_JobEvent_t
OTA Job callback events.
Definition: aws_iot_ota_agent.h:188
OTA_Err_t OTA_ActivateNewImage(void)
Activate the newest MCU image received via OTA.
OTA_State_t
OTA Agent states.
Definition: aws_iot_ota_agent.h:97
uint8_t * pucFile
Definition: aws_iot_ota_agent.h:411
OTA_JobParseErr_t
OTA job document parser error codes.
Definition: aws_iot_ota_agent.h:156
@ eOTA_ImageState_Accepted
Definition: aws_iot_ota_agent.h:215
OTA_Event_t
OTA Agent Events.
Definition: aws_iot_ota_agent.h:120
@ eOTA_ImageState_Aborted
Definition: aws_iot_ota_agent.h:217
@ eOTA_JobEvent_Fail
Definition: aws_iot_ota_agent.h:190
OTA PAL callback structure.
Definition: aws_iot_ota_agent.h:447
@ eOTA_JobEvent_StartTest
Definition: aws_iot_ota_agent.h:191
uint32_t ulServerFileID
Definition: aws_iot_ota_agent.h:416
int16_t(* pxOTAPALWriteBlockCallback_t)(OTA_FileContext_t *const C, uint32_t iOffset, uint8_t *const pacData, uint32_t iBlockSize)
OTA Write Block callback function typedef.
Definition: aws_iot_ota_agent.h:359
OTA_State_t OTA_AgentInit_internal(void *pvConnectionContext, const uint8_t *pucThingName, const OTA_PAL_Callbacks_t *pxCallbacks, TickType_t xTicksToWait)
Internal OTA Agent initialization function.
uint8_t * pucJobName
Definition: aws_iot_ota_agent.h:417
OTA_State_t OTA_AgentShutdown(TickType_t xTicksToWait)
Signal to the OTA Agent to shut down.
uint32_t OTA_GetPacketsReceived(void)
Get the number of OTA message packets received by the OTA agent.
uint32_t OTA_GetPacketsDropped(void)
Get the number of OTA message packets dropped by the OTA agent.
OTA_Err_t OTA_Resume(void *pxConnection)
Resume OTA agent operations .
@ eOTA_ImageState_Rejected
Definition: aws_iot_ota_agent.h:216
OTA_JobParseErr_t(* pxOTACustomJobCallback_t)(const char *pcJSON, uint32_t ulMsgLen)
Custom Job callback function typedef.
Definition: aws_iot_ota_agent.h:374
Definition: aws_iot_ota_agent.h:389
@ eOTA_ImageState_Unknown
Definition: aws_iot_ota_agent.h:213
struct OTA_FileContext OTA_FileContext_t
Definition: aws_iot_ota_agent.h:230
OTA_Err_t(* pxOTAPALCloseFileCallback_t)(OTA_FileContext_t *const C)
OTA close file callback function typedef.
Definition: aws_iot_ota_agent.h:299
OTA File Context Information.
Definition: aws_iot_ota_agent.h:402
uint8_t * pucCertFilepath
Definition: aws_iot_ota_agent.h:421
OTA Connection context.
Definition: aws_iot_ota_agent.h:436
uint8_t * pucStreamName
Definition: aws_iot_ota_agent.h:418
uint8_t * pucRxBlockBitmap
Definition: aws_iot_ota_agent.h:420
uint8_t * pucFilePath
Definition: aws_iot_ota_agent.h:403
uint8_t * pucAuthScheme
Definition: aws_iot_ota_agent.h:423
OTA_Err_t OTA_Suspend(void)
Suspend OTA agent operations .
uint8_t * pucUpdateUrlPath
Definition: aws_iot_ota_agent.h:422
OTA_Err_t(* pxOTAPALCreateFileForRxCallback_t)(OTA_FileContext_t *const C)
OTA create file to store received data callback function typedef.
Definition: aws_iot_ota_agent.h:310
uint32_t ulUpdaterVersion
Definition: aws_iot_ota_agent.h:424
uint32_t ulBlocksRemaining
Definition: aws_iot_ota_agent.h:414
OTA_Err_t(* pxOTAPALSetPlatformImageStateCallback_t)(uint32_t ulServerFileID, OTA_ImageState_t eState)
OTA Set Platform Image State callback function typedef.
Definition: aws_iot_ota_agent.h:344
OTA_Err_t(* pxOTAPALResetDeviceCallback_t)(uint32_t ulServerFileID)
OTA Reset Device callback function typedef.
Definition: aws_iot_ota_agent.h:332
OTA_ImageState_t
OTA Image states.
Definition: aws_iot_ota_agent.h:212