AWS IoT Embedded C Device SDK
aws_iot_shadow_json_data.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef SRC_SHADOW_AWS_IOT_SHADOW_JSON_DATA_H_
17 #define SRC_SHADOW_AWS_IOT_SHADOW_JSON_DATA_H_
18 
24 #include <stddef.h>
25 
30 typedef struct jsonStruct jsonStruct_t;
34 typedef void (*jsonStructCallback_t)(const char *pJsonValueBuffer, uint32_t valueLength, jsonStruct_t *pJsonStruct_t);
35 
41 typedef enum {
42  SHADOW_JSON_INT32,
43  SHADOW_JSON_INT16,
44  SHADOW_JSON_INT8,
45  SHADOW_JSON_UINT32,
46  SHADOW_JSON_UINT16,
47  SHADOW_JSON_UINT8,
48  SHADOW_JSON_FLOAT,
49  SHADOW_JSON_DOUBLE,
50  SHADOW_JSON_BOOL,
51  SHADOW_JSON_STRING,
52  SHADOW_JSON_OBJECT
54 
58 struct jsonStruct {
59  const char *pKey;
60  void *pData;
63 };
64 
79 IoT_Error_t aws_iot_shadow_init_json_document(char *pJsonDocument, size_t maxSizeOfJsonDocument);
80 
95 IoT_Error_t aws_iot_shadow_add_reported(char *pJsonDocument, size_t maxSizeOfJsonDocument, uint8_t count, ...);
96 
111 IoT_Error_t aws_iot_shadow_add_desired(char *pJsonDocument, size_t maxSizeOfJsonDocument, uint8_t count, ...);
112 
125 IoT_Error_t aws_iot_finalize_json_document(char *pJsonDocument, size_t maxSizeOfJsonDocument);
126 
138 IoT_Error_t aws_iot_fill_with_client_token(char *pBufferToBeUpdatedWithClientToken, size_t maxSizeOfJsonDocument);
139 
140 #endif /* SRC_SHADOW_AWS_IOT_SHADOW_JSON_DATA_H_ */
JsonPrimitiveType type
type of JSON
Definition: aws_iot_shadow_json_data.h:61
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.
Definition: aws_iot_shadow_json_data.h:34
void * pData
pointer to the data (JSON value)
Definition: aws_iot_shadow_json_data.h:60
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.
Definition: aws_iot_shadow_json.c:77
IoT_Error_t
IoT Error enum.
Definition: aws_iot_error.h:36
const char * pKey
JSON key.
Definition: aws_iot_shadow_json_data.h:59
JsonPrimitiveType
All the JSON object types enum.
Definition: aws_iot_shadow_json_data.h:41
This is the struct form of a JSON Key value pair.
Definition: aws_iot_shadow_json_data.h:58
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.
Definition: aws_iot_shadow_json.c:211
IoT_Error_t aws_iot_shadow_init_json_document(char *pJsonDocument, size_t maxSizeOfJsonDocument)
Initialize the JSON document with Shadow expected name/value.
Definition: aws_iot_shadow_json.c:61
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.
Definition: aws_iot_shadow_json.c:138
IoT_Error_t aws_iot_finalize_json_document(char *pJsonDocument, size_t maxSizeOfJsonDocument)
Finalize the JSON document with Shadow expected client Token.
Definition: aws_iot_shadow_json.c:219
jsonStructCallback_t cb
callback to be executed on receiving the Key value pair
Definition: aws_iot_shadow_json_data.h:62