AWS IoT Over-the-air Update v3.4.0
Client library for AWS IoT OTA
 
Loading...
Searching...
No Matches
ota_cbor.c File Reference

CBOR encode/decode routines for AWS IoT Over-the-Air updates. More...

#include <stdlib.h>
#include "cbor.h"
#include "ota_cbor_private.h"
Include dependency graph for ota_cbor.c:

Macros

#define OTA_CBOR_GETSTREAMREQUEST_ITEM_COUNT   6
 Number of keys in cbor get stream request message.
 

Functions

static CborError checkDataType (CborType expectedType, const CborValue *cborValue)
 Helper function to verify the data type of the value in map.
 
bool OTA_CBOR_Decode_GetStreamResponseMessage (const uint8_t *pMessageBuffer, size_t messageSize, int32_t *pFileId, int32_t *pBlockId, int32_t *pBlockSize, uint8_t *const *pPayload, size_t *pPayloadSize)
 Decode a Get Stream response message from AWS IoT OTA.
 
bool OTA_CBOR_Encode_GetStreamRequestMessage (uint8_t *pMessageBuffer, size_t messageBufferSize, size_t *pEncodedMessageSize, const char *pClientToken, int32_t fileId, int32_t blockSize, int32_t blockOffset, const uint8_t *pBlockBitmap, size_t blockBitmapSize, int32_t numOfBlocksRequested)
 Create an encoded Get Stream Request message for the AWS IoT OTA service. The service allows block count or block bitmap to be requested, but not both.
 

Detailed Description

CBOR encode/decode routines for AWS IoT Over-the-Air updates.

Function Documentation

◆ checkDataType()

static CborError checkDataType ( CborType  expectedType,
const CborValue *  cborValue 
)
static

Helper function to verify the data type of the value in map.

Parameters
[in]expectedTypeData type expected.
[in]cborValueValue to check.
Returns
CborError

◆ OTA_CBOR_Decode_GetStreamResponseMessage()

bool OTA_CBOR_Decode_GetStreamResponseMessage ( const uint8_t *  pMessageBuffer,
size_t  messageSize,
int32_t *  pFileId,
int32_t *  pBlockId,
int32_t *  pBlockSize,
uint8_t *const *  pPayload,
size_t *  pPayloadSize 
)

Decode a Get Stream response message from AWS IoT OTA.

Parameters
[in]pMessageBuffermessage to decode.
[in]messageSizesize of the message to decode.
[out]pFileIdDecoded file id value.
[out]pBlockIdDecoded block id value.
[out]pBlockSizeDecoded block size value.
[out]pPayloadBuffer for the decoded payload.
[in,out]pPayloadSizemaximum size of the buffer as in and actual payload size for the decoded payload as out.
Returns
TRUE when success, otherwise FALSE.

◆ OTA_CBOR_Encode_GetStreamRequestMessage()

bool OTA_CBOR_Encode_GetStreamRequestMessage ( uint8_t *  pMessageBuffer,
size_t  messageBufferSize,
size_t *  pEncodedMessageSize,
const char *  pClientToken,
int32_t  fileId,
int32_t  blockSize,
int32_t  blockOffset,
const uint8_t *  pBlockBitmap,
size_t  blockBitmapSize,
int32_t  numOfBlocksRequested 
)

Create an encoded Get Stream Request message for the AWS IoT OTA service. The service allows block count or block bitmap to be requested, but not both.

Parameters
[in,out]pMessageBufferBuffer to store the encoded message.
[in]messageBufferSizeSize of the buffer to store the encoded message.
[out]pEncodedMessageSizeSize of the final encoded message.
[in]pClientTokenClient token in the encoded message.
[in]fileIdValue of file id in the encoded message.
[in]blockSizeValue of block size in the encoded message.
[in]blockOffsetValue of block offset in the encoded message.
[in]pBlockBitmapbitmap in the encoded message.
[in]blockBitmapSizeSize of the provided bitmap buffer.
[in]numOfBlocksRequestednumber of blocks to request in the encoded message.
Returns
TRUE when success, otherwise FALSE.