AWS IoT Over-the-air Update
v2.0.0 (Release Candidate)
Client library for AWS IoT OTA
|
|
Go to the documentation of this file.
47 #define CONST_STRLEN( s ) ( ( ( uint32_t ) sizeof( s ) ) - 1UL )
50 #define OTA_FILE_SIG_KEY_STR_MAX_LENGTH 32
107 typedef enum OtaState
109 OtaAgentStateNoTransition = -1,
110 OtaAgentStateInit = 0,
112 OtaAgentStateRequestingJob,
113 OtaAgentStateWaitingForJob,
114 OtaAgentStateCreatingFile,
115 OtaAgentStateRequestingFileBlock,
116 OtaAgentStateWaitingForFileBlock,
117 OtaAgentStateClosingFile,
118 OtaAgentStateSuspended,
119 OtaAgentStateShuttingDown,
120 OtaAgentStateStopped,
128 typedef enum OtaJobParseErr
130 OtaJobParseErrUnknown = -1,
131 OtaJobParseErrNone = 0,
132 OtaJobParseErrBusyWithExistingJob,
133 OtaJobParseErrNullJob,
134 OtaJobParseErrUpdateCurrentJob,
135 OtaJobParseErrZeroFileSize,
136 OtaJobParseErrNonConformingJobDoc,
137 OtaJobParseErrBadModelInitParams,
138 OtaJobParseErrNoContextAvailable,
139 OtaJobParseErrNoActiveJobs
159 typedef enum OtaJobEvent
202 const void * pData );
227 typedef struct OtaInterface
241 typedef struct OtaAppBuffer
264 typedef struct OtaAgentContext
304 const uint8_t * pThingName,
OtaState_t
OTA Agent states.
Definition: ota.h:108
uint8_t * pStreamName
Name of stream to download the files.
Definition: ota.h:247
@ OtaErrFailedToEncodeCbor
Failed to encode CBOR object for requesting data block from streaming service.
Definition: ota.h:94
uint32_t serverFileID
Definition: ota.h:270
@ OtaErrInitFileTransferFailed
Failed to update the OTA job status.
Definition: ota.h:81
Contains OTA OS Functional Interface statuses, type definitions and structures to store interface rou...
void OTA_EventProcessingTask(void *pUnused)
OTA agent event processing loop.
Definition: ota.c:2815
@ OtaErrNoActiveJob
Attempt to set final image state without an active job.
Definition: ota.h:92
OtaOSInterface_t os
OS interface to store event, timers and memory operations.
Definition: ota.h:229
@ OtaErrRequestFileBlockFailed
Failed to request file block.
Definition: ota.h:82
OTA File Context Information.
Definition: ota_private.h:390
OtaImageState_t
OTA Image states.
Definition: ota_private.h:322
@ OtaJobEventStartTest
OTA job is now in self test, perform user tests.
Definition: ota.h:163
OtaErr_t OTA_SetImageState(OtaImageState_t state)
Set the state of the current MCU image.
Definition: ota.c:3241
@ OtaJobEventSelfTestFailed
OTA self-test failed for current job.
Definition: ota.h:165
#define OTA_JOB_ID_MAX_SIZE
Maximum size of the Job ID.
Definition: ota_private.h:107
OtaErr_t OTA_GetStatistics(OtaAgentStatistics_t *pStatistics)
Get the statistics of OTA message packets.
Definition: ota.c:3164
uint16_t certFilePathSize
Maximum size of the certificate file path.
Definition: ota.h:246
OtaAppCallback_t OtaAppCallback
Definition: ota.h:279
OtaImageState_t imageState
Definition: ota.h:274
OtaState_t OTA_Shutdown(uint32_t ticksToWait)
Signal to the OTA Agent to shut down.
Definition: ota.c:3100
This is the OTA statistics structure to hold useful info.
Definition: ota_private.h:299
uint8_t * pUrl
Presigned url to download files from S3.
Definition: ota.h:253
@ OtaErrUserAbort
User aborted the active OTA.
Definition: ota.h:93
OtaJobEvent_t
OTA Job callback events.
Definition: ota.h:160
uint16_t streamNameSize
Maximum size of the stream name.
Definition: ota.h:248
OtaErr_t
The OTA API return status. OTA agent error codes are in the upper 8 bits of the 32 bit OTA error word...
Definition: ota.h:73
const char * OTA_OsStatus_strerror(OtaOsStatus_t status)
Status code to string conversion for OTA OS status.
Definition: ota.c:3526
@ OtaErrCleanupDataFailed
Failed to clean up the data plane.
Definition: ota.h:84
uint8_t * pAuthScheme
Authentication scheme used to validate download.
Definition: ota.h:255
uint8_t * pCertFilePath
Path to certificate file.
Definition: ota.h:245
OTA OS Interface.
Definition: ota_os_interface.h:302
@ OtaErrSameFirmwareVersion
Firmware version is the same as previous. New firmware could have failed to commit.
Definition: ota.h:90
OtaErr_t OTA_ActivateNewImage(void)
Activate the newest MCU image received via OTA.
Definition: ota.c:3205
uint8_t * pUpdateFilePath
Path to store the files.
Definition: ota.h:243
@ OtaJobEventProcessed
OTA event queued by OTA_SignalEvent is processed.
Definition: ota.h:164
uint8_t * pDecodeMemory
Place to store the decoded files.
Definition: ota.h:249
@ OtaErrAgentStopped
Returned when operations are performed that requires OTA Agent running & its stopped.
Definition: ota.h:78
@ OtaErrFailedToDecodeCbor
Failed to decode CBOR object from streaming service response.
Definition: ota.h:95
@ OtaErrUninitialized
The error code has not yet been set by a logic path.
Definition: ota.h:75
OTA Interface for referencing different components.
Definition: ota.h:228
uint32_t numOfBlocksToReceive
Definition: ota.h:275
OtaErr_t OTA_CheckForUpdate(void)
Request for the next available OTA job from the job service.
Definition: ota.c:3177
The OTA agent is a singleton today. The structure keeps it nice and organized.
Definition: ota.h:265
OtaAgentStatistics_t statistics
Definition: ota.h:276
OTA Event Interface structure.
Definition: ota_mqtt_interface.h:156
uint32_t decodeMemorySize
Maximum size of the decoded files buffer.
Definition: ota.h:250
bool OTA_SignalEvent(const OtaEventMsg_t *const pEventMsg)
Signal event to the OTA Agent task.
Definition: ota.c:2865
Macros, enums, variables, and definitions internal to the OTA Agent module and shared by other OTA mo...
uint16_t urlSize
Maximum size of the URL.
Definition: ota.h:254
Contains OTA HTTP Statuses, function type definitions and http interface structure.
const char * OTA_Err_strerror(OtaErr_t err)
Error code to string conversion for OTA errors.
Definition: ota.c:3368
@ OtaErrNone
No error occurred during the operation.
Definition: ota.h:74
Stores information about the event message.
Definition: ota_private.h:442
@ OtaErrSignalEventFailed
Failed to send event to OTA state machine.
Definition: ota.h:79
OtaErr_t OTA_Suspend(void)
Suspend OTA agent operations .
Definition: ota.c:3306
OtaCustomJobCallback_t customJobCallback
Definition: ota.h:280
OtaOsStatus_t
The OTA OS interface return status.
Definition: ota_os_interface.h:100
OtaState_t OTA_GetState(void)
Get the current state of the OTA agent.
Definition: ota.c:3156
OtaErr_t OTA_Resume(void)
Resume OTA agent operations .
Definition: ota.c:3339
@ OtaErrDowngradeNotAllowed
Firmware version is older than the previous version.
Definition: ota.h:89
uint32_t requestMomentum
Definition: ota.h:277
const char * OTA_PalStatus_strerror(OtaPalMainStatus_t status)
Status code to string conversion for OTA PAL status.
Definition: ota.c:3579
@ OtaErrPanic
Unrecoverable Firmware error. Probably should log error and reboot.
Definition: ota.h:76
OtaJobParseErr_t(* OtaCustomJobCallback_t)(const char *pcJSON, uint32_t ulMsgLen)
Custom Job callback function typedef.
Definition: ota.h:214
uint16_t updateFilePathsize
Maximum size of the file path.
Definition: ota.h:244
uint8_t * pFileBitmap
Bitmap of the parameters received.
Definition: ota.h:251
@ OtaErrJobParserError
An error occurred during job document parsing. See reason sub-code.
Definition: ota.h:86
OtaImageState_t OTA_GetImageState(void)
Get the state of the currently running MCU image.
Definition: ota.c:3295
@ OtaErrActivateFailed
Failed to activate the new image.
Definition: ota.h:96
OtaPalMainStatus_t
The OTA platform interface main status.
Definition: ota_platform_interface.h:73
uint32_t timestampFromJob
Definition: ota.h:273
@ OtaJobEventFail
OTA receive failed. Unable to use this update.
Definition: ota.h:162
uint8_t * pClientTokenFromJob
Definition: ota.h:272
OTA Event Interface structure.
Definition: ota_http_interface.h:130
OtaMqttInterface_t mqtt
MQTT interface that references the publish subscribe methods and callbacks.
Definition: ota.h:230
OtaState_t state
Definition: ota.h:266
OTA pal Interface structure.
Definition: ota_platform_interface.h:292
@ OtaErrImageStateMismatch
The OTA job was in Self Test but the platform image state was not. Possible tampering.
Definition: ota.h:91
OtaInterfaces_t * pOtaInterface
Definition: ota.h:278
uint16_t fileBitmapSize
Maximum size of the bitmap.
Definition: ota.h:252
@ OtaErrInvalidArg
API called with invalid argument.
Definition: ota.h:77
OtaHttpInterface_t http
HTTP interface to request data.
Definition: ota.h:231
Contains OTA MQTT Statuses, function type definitions and mqtt interface structure.
@ OtaErrInvalidDataProtocol
Job does not have a valid protocol for data transfer.
Definition: ota.h:87
uint32_t fileIndex
Definition: ota.h:269
#define otaconfigMAX_THINGNAME_LEN
The maximum allowed length of the thing name used by the OTA agent.
Definition: ota_config_defaults.h:132
@ OtaErrUpdateJobStatusFailed
Failed to update the OTA job status.
Definition: ota.h:85
@ OtaErrCleanupControlFailed
Failed to clean up the control plane.
Definition: ota.h:83
@ OtaErrMomentumAbort
Too many OTA stream requests without any response.
Definition: ota.h:88
uint16_t authSchemeSize
Maximum size of the auth scheme.
Definition: ota.h:256
const char * OTA_JobParse_strerror(OtaJobParseErr_t err)
Error code to string conversion for OTA Job Parsing errors.
Definition: ota.c:3473
OtaJobParseErr_t
OTA job document parser error codes.
Definition: ota.h:129
OtaFileContext_t fileContext
Definition: ota.h:268
const char OTA_JsonFileSignatureKey[OTA_FILE_SIG_KEY_STR_MAX_LENGTH]
The OTA signature algorithm string is specified by the PAL.
@ OtaErrRequestJobFailed
Failed to request the job document.
Definition: ota.h:80
void(* OtaAppCallback_t)(OtaJobEvent_t eEvent, const void *pData)
OTA update complete callback function typedef.
Definition: ota.h:201
OtaPalInterface_t pal
OTA PAL callback structure.
Definition: ota.h:232
@ OtaJobEventActivate
OTA receive is authenticated and ready to activate.
Definition: ota.h:161
OTA Application Buffer size information.
Definition: ota.h:242
#define OTA_FILE_SIG_KEY_STR_MAX_LENGTH
Definition: ota.h:50
OtaErr_t OTA_Init(OtaAppBuffer_t *pOtaBuffer, OtaInterfaces_t *pOtaInterfaces, const uint8_t *pThingName, OtaAppCallback_t OtaAppCallback)
OTA Agent initialization function.
Definition: ota.c:3006