AWS IoT Over-the-air Update  v2.0.0 (Release Candidate)
Client library for AWS IoT OTA
ota_http.c File Reference

Data transfer over HTTP routines. More...

#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "ota.h"
#include "ota_private.h"
#include "ota_http_private.h"

Functions

OtaErr_t initFileTransfer_Http (OtaAgentContext_t *pAgentCtx)
 Initialize file transfer over HTTP. More...
 
OtaErr_t requestDataBlock_Http (OtaAgentContext_t *pAgentCtx)
 Request File block over HTTP. More...
 
OtaErr_t decodeFileBlock_Http (const uint8_t *pMessageBuffer, size_t messageSize, int32_t *pFileId, int32_t *pBlockId, int32_t *pBlockSize, uint8_t **pPayload, size_t *pPayloadSize)
 Stub for decoding the file block. More...
 
OtaErr_t cleanupData_Http (const OtaAgentContext_t *pAgentCtx)
 Cleanup related to OTA data plane over HTTP. More...
 
const char * OTA_HTTP_strerror (OtaHttpStatus_t status)
 Status to string conversion for OTA HTTP interface status. More...
 

Variables

static uint32_t currBlock
 Track the current block for HTTP requests.
 

Detailed Description

Data transfer over HTTP routines.

Function Documentation

◆ initFileTransfer_Http()

OtaErr_t initFileTransfer_Http ( OtaAgentContext_t pAgentCtx)

Initialize file transfer over HTTP.

This function initializes the file transfer after the OTA job is parsed and accepted by initializing the http component with pre-signed url.

Parameters
[in]pAgentCtxThe OTA agent context.
Returns
The OTA error code. See OTA Agent error codes information in ota.h.

◆ requestDataBlock_Http()

OtaErr_t requestDataBlock_Http ( OtaAgentContext_t pAgentCtx)

Request File block over HTTP.

This function is used for requesting a file block over HTTP using the file context.

Parameters
[in]pAgentCtxThe OTA agent context.
Returns
The OTA PAL layer error code combined with the MCU specific error code. See OTA Agent error codes information in ota.h.

◆ decodeFileBlock_Http()

OtaErr_t decodeFileBlock_Http ( const uint8_t *  pMessageBuffer,
size_t  messageSize,
int32_t *  pFileId,
int32_t *  pBlockId,
int32_t *  pBlockSize,
uint8_t **  pPayload,
size_t *  pPayloadSize 
)

Stub for decoding the file block.

File block received over HTTP does not require decoding, only increment the number of blocks received.

Parameters
[in]pMessageBufferThe message to be decoded.
[in]messageSizeThe size of the message in bytes.
[out]pFileIdThe server file ID.
[out]pBlockIdThe file block ID.
[out]pBlockSizeThe file block size.
[out]pPayloadThe payload.
[out]pPayloadSizeThe payload size.
Returns
The OTA PAL layer error code combined with the MCU specific error code. See OTA Agent error codes information in ota.h.

◆ cleanupData_Http()

OtaErr_t cleanupData_Http ( const OtaAgentContext_t pAgentCtx)

Cleanup related to OTA data plane over HTTP.

This function performs cleanup by resetting the number of blocks received and deinit the http component.

Parameters
[in]pAgentCtxThe OTA agent context.
Returns
The OTA error code. See OTA Agent error codes information in ota.h.

◆ OTA_HTTP_strerror()

const char* OTA_HTTP_strerror ( OtaHttpStatus_t  status)

Status to string conversion for OTA HTTP interface status.

Parameters
[in]statusThe status to convert to a string.
Returns
The string representation of the status.