This file is the interface for all the Shadow related JSON functions.
#include <stddef.h>
Data Structures | |
struct | jsonStruct |
This is the struct form of a JSON Key value pair. More... | |
Typedefs | |
typedef struct jsonStruct | jsonStruct_t |
This is a static JSON object that could be used in code. More... | |
typedef void(* | jsonStructCallback_t )(const char *pJsonValueBuffer, uint32_t valueLength, jsonStruct_t *pJsonStruct_t) |
Every JSON name value can have a callback. More... | |
Enumerations | |
enum | JsonPrimitiveType { SHADOW_JSON_INT32, SHADOW_JSON_INT16, SHADOW_JSON_INT8, SHADOW_JSON_UINT32, SHADOW_JSON_UINT16, SHADOW_JSON_UINT8, SHADOW_JSON_FLOAT, SHADOW_JSON_DOUBLE, SHADOW_JSON_BOOL, SHADOW_JSON_STRING, SHADOW_JSON_OBJECT } |
All the JSON object types enum. More... | |
Functions | |
IoT_Error_t | aws_iot_fill_with_client_token (char *pBufferToBeUpdatedWithClientToken, size_t maxSizeOfJsonDocument) |
Fill the given buffer with client token for tracking the Repsonse. More... | |
IoT_Error_t | aws_iot_finalize_json_document (char *pJsonDocument, size_t maxSizeOfJsonDocument) |
Finalize the JSON document with Shadow expected client Token. More... | |
IoT_Error_t | aws_iot_shadow_add_desired (char *pJsonDocument, size_t maxSizeOfJsonDocument, uint8_t count,...) |
Add the desired section of the JSON document of jsonStruct_t. More... | |
IoT_Error_t | aws_iot_shadow_add_reported (char *pJsonDocument, size_t maxSizeOfJsonDocument, uint8_t count,...) |
Add the reported section of the JSON document of jsonStruct_t. More... | |
IoT_Error_t | aws_iot_shadow_init_json_document (char *pJsonDocument, size_t maxSizeOfJsonDocument) |
Initialize the JSON document with Shadow expected name/value. More... | |
typedef struct jsonStruct jsonStruct_t |
This is a static JSON object that could be used in code.
typedef void(* jsonStructCallback_t)(const char *pJsonValueBuffer, uint32_t valueLength, jsonStruct_t *pJsonStruct_t) |
Every JSON name value can have a callback.
The callback should follow this signature
enum JsonPrimitiveType |
All the JSON object types enum.
JSON number types need to be split into proper integer / floating point data types and sizes on embedded platforms.
IoT_Error_t aws_iot_fill_with_client_token | ( | char * | pBufferToBeUpdatedWithClientToken, |
size_t | maxSizeOfJsonDocument | ||
) |
Fill the given buffer with client token for tracking the Repsonse.
This function will add the AWS_IOT_MQTT_CLIENT_ID with a sequence number. Every time this function is used the sequence number gets incremented
pBufferToBeUpdatedWithClientToken | buffer to be updated with the client token string |
maxSizeOfJsonDocument | maximum size of the pBufferToBeUpdatedWithClientToken that can be used |
References checkReturnValueOfSnPrintf(), and FillWithClientTokenSize().
IoT_Error_t aws_iot_finalize_json_document | ( | char * | pJsonDocument, |
size_t | maxSizeOfJsonDocument | ||
) |
Finalize the JSON document with Shadow expected client Token.
This function will automatically increment the client token every time this function is called.
pJsonDocument | The JSON Document filled in this char buffer |
maxSizeOfJsonDocument | maximum size of the pJsonDocument that can be used to fill the JSON document |
References checkReturnValueOfSnPrintf(), FillWithClientTokenSize(), NONE_ERROR, NULL, NULL_VALUE_ERROR, SHADOW_CLIENT_TOKEN_STRING, and SHADOW_JSON_ERROR.
IoT_Error_t aws_iot_shadow_add_desired | ( | char * | pJsonDocument, |
size_t | maxSizeOfJsonDocument, | ||
uint8_t | count, | ||
... | |||
) |
Add the desired section of the JSON document of jsonStruct_t.
This is a variadic function and please be careful with the usage. count is the number of jsonStruct_t types that you would like to add in the reported section This function will add "desired":{<all the="" values="" that="" needs="" to="" be="" added>="">}
pJsonDocument | The JSON Document filled in this char buffer |
maxSizeOfJsonDocument | maximum size of the pJsonDocument that can be used to fill the JSON document |
count | total number of arguments(jsonStruct_t object) passed in the arguments |
References checkReturnValueOfSnPrintf(), convertDataToString(), NONE_ERROR, NULL, NULL_VALUE_ERROR, jsonStruct::pData, jsonStruct::pKey, SHADOW_JSON_ERROR, and jsonStruct::type.
IoT_Error_t aws_iot_shadow_add_reported | ( | char * | pJsonDocument, |
size_t | maxSizeOfJsonDocument, | ||
uint8_t | count, | ||
... | |||
) |
Add the reported section of the JSON document of jsonStruct_t.
This is a variadic function and please be careful with the usage. count is the number of jsonStruct_t types that you would like to add in the reported section This function will add "reported":{<all the="" values="" that="" needs="" to="" be="" added>="">}
pJsonDocument | The JSON Document filled in this char buffer |
maxSizeOfJsonDocument | maximum size of the pJsonDocument that can be used to fill the JSON document |
count | total number of arguments(jsonStruct_t object) passed in the arguments |
References checkReturnValueOfSnPrintf(), convertDataToString(), NONE_ERROR, NULL, NULL_VALUE_ERROR, jsonStruct::pData, jsonStruct::pKey, SHADOW_JSON_ERROR, and jsonStruct::type.
IoT_Error_t aws_iot_shadow_init_json_document | ( | char * | pJsonDocument, |
size_t | maxSizeOfJsonDocument | ||
) |
Initialize the JSON document with Shadow expected name/value.
This Function will fill the JSON Buffer with a null terminated string. Internally it uses snprintf This function should always be used First, followed by iot_shadow_add_reported and/or iot_shadow_add_desired. Always finish the call sequence with iot_finalize_json_document
pJsonDocument | The JSON Document filled in this char buffer |
maxSizeOfJsonDocument | maximum size of the pJsonDocument that can be used to fill the JSON document |
References checkReturnValueOfSnPrintf(), NONE_ERROR, NULL, and NULL_VALUE_ERROR.