AWS IoT Embedded C Device SDK
aws_iot_shadow_interface.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 #ifndef AWS_IOT_SDK_SRC_IOT_SHADOW_H_
16 #define AWS_IOT_SDK_SRC_IOT_SHADOW_H_
17 
18 
36 #include "aws_iot_mqtt_interface.h"
38 
48 typedef struct {
49  char *pMyThingName;
50  char *pMqttClientId;
51  char *pHost;
52  int port;
53  char *pRootCA;
54  char *pClientCRT;
55  char *pClientKey;
57 
65 
66 
97 IoT_Error_t aws_iot_shadow_yield(MQTTClient_t *pClient, int timeout);
107 
114 typedef enum {
115  SHADOW_ACK_TIMEOUT, SHADOW_ACK_REJECTED, SHADOW_ACK_ACCEPTED
117 
124 typedef enum {
125  SHADOW_GET, SHADOW_UPDATE, SHADOW_DELETE
127 
128 
141 typedef void (*fpActionCallback_t)(const char *pThingName, ShadowActions_t action, Shadow_Ack_Status_t status,
142  const char *pReceivedJsonDocument, void *pContextData);
143 
167 IoT_Error_t aws_iot_shadow_update(MQTTClient_t *pClient, const char *pThingName, char *pJsonString,
168  fpActionCallback_t callback, void *pContextData, uint8_t timeout_seconds, bool isPersistentSubscribe);
169 
184 IoT_Error_t aws_iot_shadow_get(MQTTClient_t *pClient, const char *pThingName, fpActionCallback_t callback,
185  void *pContextData, uint8_t timeout_seconds, bool isPersistentSubscribe);
200 IoT_Error_t aws_iot_shadow_delete(MQTTClient_t *pClient, const char *pThingName, fpActionCallback_t callback,
201  void *pContextData, uint8_t timeout_seconds, bool isPersistentSubscriptions);
202 
213 
241 
242 #endif //AWS_IOT_SDK_SRC_IOT_SHADOW_H_
IoT_Error_t aws_iot_shadow_connect(MQTTClient_t *pClient, ShadowParameters_t *pParams)
Connect to the AWS IoT Thing Shadow service over MQTT.
Definition: aws_iot_shadow.c:63
IoT_Error_t aws_iot_shadow_get(MQTTClient_t *pClient, const char *pThingName, fpActionCallback_t callback, void *pContextData, uint8_t timeout_seconds, bool isPersistentSubscribe)
This function is the one used to perform an Get action to a Thing Name's Shadow.
Definition: aws_iot_shadow.c:158
MQTT Client Type Definition.
Definition: aws_iot_mqtt_interface.h:301
char * pHost
This will be unique to a customer and can be retrieved from the console.
Definition: aws_iot_shadow_interface.h:51
Shadow Connect parameters.
Definition: aws_iot_shadow_interface.h:48
uint32_t aws_iot_shadow_get_last_received_version(void)
Version of a document is received with every accepted/rejected and the SDK keeps track of the last re...
Definition: aws_iot_shadow.c:37
IoT_Error_t aws_iot_shadow_disconnect(MQTTClient_t *pClient)
Disconnect from the AWS IoT Thing Shadow service over MQTT.
Definition: aws_iot_shadow.c:123
void aws_iot_shadow_disable_discard_old_delta_msgs(void)
Disable the ignoring of delta messages with old version number.
Definition: aws_iot_shadow.c:45
This file is the interface for all the Shadow related JSON functions.
IoT_Error_t aws_iot_shadow_delete(MQTTClient_t *pClient, const char *pThingName, fpActionCallback_t callback, void *pContextData, uint8_t timeout_seconds, bool isPersistentSubscriptions)
This function is the one used to perform an Delete action to a Thing Name's Shadow.
Definition: aws_iot_shadow.c:142
IoT_Error_t aws_iot_shadow_register_delta(MQTTClient_t *pClient, jsonStruct_t *pStruct)
This function is used to listen on the delta topic of AWS_IOT_MY_THING_NAME mentioned in the aws_iot_...
Definition: aws_iot_shadow.c:106
IoT_Error_t
IoT Error enum.
Definition: aws_iot_error.h:30
void aws_iot_shadow_reset_last_received_version(void)
Reset the last received version number to zero. This will be useful if the Thing Shadow is deleted an...
Definition: aws_iot_shadow.c:33
void aws_iot_shadow_enable_discard_old_delta_msgs(void)
Enable the ignoring of delta messages with old version number.
Definition: aws_iot_shadow.c:41
IoT_Error_t aws_iot_shadow_yield(MQTTClient_t *pClient, int timeout)
Yield function to let the background tasks of MQTT and Shadow.
Definition: aws_iot_shadow.c:118
IoT_Error_t aws_iot_shadow_init(MQTTClient_t *pClient)
Initialize the Thing Shadow before use.
Definition: aws_iot_shadow.c:49
ShadowActions_t
Thing Shadow Action type enum.
Definition: aws_iot_shadow_interface.h:124
Shadow_Ack_Status_t
Thing Shadow Acknowledgment enum.
Definition: aws_iot_shadow_interface.h:114
This is the struct form of a JSON Key value pair.
Definition: aws_iot_shadow_json_data.h:58
const ShadowParameters_t ShadowParametersDefault
This is set to defaults from the configuration file The certs are set to NULL because they need the p...
Definition: aws_iot_shadow_interface.h:64
char * pClientKey
Location of Device private key.
Definition: aws_iot_shadow_interface.h:55
char * pMyThingName
Every device has a Thing Shadow and this is the placeholder for name.
Definition: aws_iot_shadow_interface.h:49
IoT_Error_t aws_iot_shadow_update(MQTTClient_t *pClient, const char *pThingName, char *pJsonString, fpActionCallback_t callback, void *pContextData, uint8_t timeout_seconds, bool isPersistentSubscribe)
This function is the one used to perform an Update action to a Thing Name's Shadow.
Definition: aws_iot_shadow.c:127
Interface definition for MQTT client.
char * pMqttClientId
Currently the Shadow uses MQTT to connect and it is important to ensure we have unique client id...
Definition: aws_iot_shadow_interface.h:50
int port
By default the port is 8883.
Definition: aws_iot_shadow_interface.h:52
char * pClientCRT
Location of Device certs signed by AWS IoT service.
Definition: aws_iot_shadow_interface.h:54
char * pRootCA
Location with the Filename of the Root CA.
Definition: aws_iot_shadow_interface.h:53
void(* fpActionCallback_t)(const char *pThingName, ShadowActions_t action, Shadow_Ack_Status_t status, const char *pReceivedJsonDocument, void *pContextData)
Function Pointer typedef used as the callback for every action.
Definition: aws_iot_shadow_interface.h:141