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_client_interface.h"
38 
48 typedef struct {
49  char *pHost;
50  uint16_t port;
51  char *pRootCA;
52  char *pClientCRT;
53  char *pClientKey;
57 
67 typedef struct {
68  char *pMyThingName;
69  char *pMqttClientId;
71 
79 
86 
87 
118 IoT_Error_t aws_iot_shadow_yield(AWS_IoT_Client *pClient, uint32_t timeout);
128 
135 typedef enum {
136  SHADOW_ACK_TIMEOUT, SHADOW_ACK_REJECTED, SHADOW_ACK_ACCEPTED
138 
145 typedef enum {
146  SHADOW_GET, SHADOW_UPDATE, SHADOW_DELETE
148 
149 
162 typedef void (*fpActionCallback_t)(const char *pThingName, ShadowActions_t action, Shadow_Ack_Status_t status,
163  const char *pReceivedJsonDocument, void *pContextData);
164 
188 IoT_Error_t aws_iot_shadow_update(AWS_IoT_Client *pClient, const char *pThingName, char *pJsonString,
189  fpActionCallback_t callback, void *pContextData, uint8_t timeout_seconds, bool isPersistentSubscribe);
190 
205 IoT_Error_t aws_iot_shadow_get(AWS_IoT_Client *pClient, const char *pThingName, fpActionCallback_t callback,
206  void *pContextData, uint8_t timeout_seconds, bool isPersistentSubscribe);
221 IoT_Error_t aws_iot_shadow_delete(AWS_IoT_Client *pClient, const char *pThingName, fpActionCallback_t callback,
222  void *pContextData, uint8_t timeout_seconds, bool isPersistentSubscriptions);
223 
234 
242 
253 
260 
265 
277 
278 #endif //AWS_IOT_SDK_SRC_IOT_SHADOW_H_
char * pMyThingName
Every device has a Thing Shadow and this is the placeholder for name.
Definition: aws_iot_shadow_interface.h:68
IoT_Error_t aws_iot_shadow_delete(AWS_IoT_Client *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:148
IoT_Error_t aws_iot_shadow_connect(AWS_IoT_Client *pClient, ShadowConnectParameters_t *pParams)
Connect to the AWS IoT Thing Shadow service over MQTT.
Definition: aws_iot_shadow.c:82
Shadow Connect parameters.
Definition: aws_iot_shadow_interface.h:67
MQTT Client.
Definition: aws_iot_mqtt_client.h:285
IoT_Error_t aws_iot_shadow_register_delta(AWS_IoT_Client *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:113
uint16_t port
By default the port is 8883.
Definition: aws_iot_shadow_interface.h:50
void(* iot_disconnect_handler)(AWS_IoT_Client *, void *)
Disconnect Callback Handler Type.
Definition: aws_iot_mqtt_client.h:152
const ShadowConnectParameters_t ShadowConnectParametersDefault
This is set to defaults from the configuration file.
Definition: aws_iot_shadow_interface.h:85
IoT_Error_t aws_iot_shadow_disconnect(AWS_IoT_Client *pClient)
Disconnect from the AWS IoT Thing Shadow service over MQTT.
Definition: aws_iot_shadow.c:130
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:42
char * pClientKey
Location of Device private key.
Definition: aws_iot_shadow_interface.h:53
IoT_Error_t aws_iot_shadow_update(AWS_IoT_Client *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:133
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:50
This file is the interface for all the Shadow related JSON functions.
IoT_Error_t
IoT Error enum.
Definition: aws_iot_error.h:36
bool enableAutoReconnect
Set to true to enable auto reconnect.
Definition: aws_iot_shadow_interface.h:54
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:38
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:46
ShadowActions_t
Thing Shadow Action type enum.
Definition: aws_iot_shadow_interface.h:145
Shadow_Ack_Status_t
Thing Shadow Acknowledgment enum.
Definition: aws_iot_shadow_interface.h:135
This is the struct form of a JSON Key value pair.
Definition: aws_iot_shadow_json_data.h:58
IoT_Error_t aws_iot_shadow_set_autoreconnect_status(AWS_IoT_Client *pClient, bool newStatus)
This function is used to enable or disable autoreconnect.
Definition: aws_iot_shadow.c:182
IoT_Error_t aws_iot_shadow_get(AWS_IoT_Client *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:164
IoT_Error_t aws_iot_shadow_yield(AWS_IoT_Client *pClient, uint32_t timeout)
Yield function to let the background tasks of MQTT and Shadow.
Definition: aws_iot_shadow.c:125
char * pHost
This will be unique to a customer and can be retrieved from the console.
Definition: aws_iot_shadow_interface.h:49
IoT_Error_t aws_iot_shadow_init(AWS_IoT_Client *pClient, ShadowInitParameters_t *pParams)
Initialize the Thing Shadow before use.
Definition: aws_iot_shadow.c:54
iot_disconnect_handler disconnectHandler
Callback to be invoked upon connection loss.
Definition: aws_iot_shadow_interface.h:55
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:69
const ShadowInitParameters_t ShadowInitParametersDefault
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:78
char * pRootCA
Location with the Filename of the Root CA.
Definition: aws_iot_shadow_interface.h:51
char * pClientCRT
Location of Device certs signed by AWS IoT service.
Definition: aws_iot_shadow_interface.h:52
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:162
Shadow Initialization parameters.
Definition: aws_iot_shadow_interface.h:48