Jeon byungchul
/
aws-iot-example
this is fork and i will modify for STM32
Fork of AWS-test by
aws-iot/include/aws_iot_shadow_interface.h@3:1ef624d94403, 2017-08-04 (annotated)
- Committer:
- bcjun@aname.co.kr
- Date:
- Fri Aug 04 15:34:19 2017 +0900
- Revision:
- 3:1ef624d94403
- Parent:
- 0:cd5404401c2f
add esp82660-driver for NUCLEO_F401RE target.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
peyo |
0:cd5404401c2f | 1 | /* |
peyo |
0:cd5404401c2f | 2 | * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
peyo |
0:cd5404401c2f | 3 | * |
peyo |
0:cd5404401c2f | 4 | * Licensed under the Apache License, Version 2.0 (the "License"). |
peyo |
0:cd5404401c2f | 5 | * You may not use this file except in compliance with the License. |
peyo |
0:cd5404401c2f | 6 | * A copy of the License is located at |
peyo |
0:cd5404401c2f | 7 | * |
peyo |
0:cd5404401c2f | 8 | * http://aws.amazon.com/apache2.0 |
peyo |
0:cd5404401c2f | 9 | * |
peyo |
0:cd5404401c2f | 10 | * or in the "license" file accompanying this file. This file is distributed |
peyo |
0:cd5404401c2f | 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
peyo |
0:cd5404401c2f | 12 | * express or implied. See the License for the specific language governing |
peyo |
0:cd5404401c2f | 13 | * permissions and limitations under the License. |
peyo |
0:cd5404401c2f | 14 | */ |
peyo |
0:cd5404401c2f | 15 | #ifndef AWS_IOT_SDK_SRC_IOT_SHADOW_H_ |
peyo |
0:cd5404401c2f | 16 | #define AWS_IOT_SDK_SRC_IOT_SHADOW_H_ |
peyo |
0:cd5404401c2f | 17 | |
peyo |
0:cd5404401c2f | 18 | #ifdef __cplusplus |
peyo |
0:cd5404401c2f | 19 | extern "C" { |
peyo |
0:cd5404401c2f | 20 | #endif |
peyo |
0:cd5404401c2f | 21 | |
peyo |
0:cd5404401c2f | 22 | |
peyo |
0:cd5404401c2f | 23 | /** |
peyo |
0:cd5404401c2f | 24 | * @file aws_iot_shadow_interface.h |
peyo |
0:cd5404401c2f | 25 | * @brief Interface for thing shadow |
peyo |
0:cd5404401c2f | 26 | * |
peyo |
0:cd5404401c2f | 27 | * These are the functions and structs to manage/interact the Thing Shadow(in the cloud). |
peyo |
0:cd5404401c2f | 28 | * This SDK will let you interact with your own thing shadow or any other shadow using its Thing Name. |
peyo |
0:cd5404401c2f | 29 | * There are totally 3 actions a device can perform on the shadow - Get, Update and Delete. |
peyo |
0:cd5404401c2f | 30 | * |
peyo |
0:cd5404401c2f | 31 | * Currently the device should use MQTT/S underneath. In the future this will also support other protocols. As it supports MQTT, the shadow needs to connect and disconnect. |
peyo |
0:cd5404401c2f | 32 | * It will also work on the pub/sub model. On performing any action, the acknowledgment will be received in either accepted or rejected. For Example: |
peyo |
0:cd5404401c2f | 33 | * If we want to perform a GET on the thing shadow the following messages will be sent and received: |
peyo |
0:cd5404401c2f | 34 | * 1. A MQTT Publish on the topic - $aws/things/{thingName}/shadow/get |
peyo |
0:cd5404401c2f | 35 | * 2. Subscribe to MQTT topics - $aws/things/{thingName}/shadow/get/accepted and $aws/things/{thingName}/shadow/get/rejected. |
peyo |
0:cd5404401c2f | 36 | * If the request was successful we will receive the things json document in the accepted topic. |
peyo |
0:cd5404401c2f | 37 | * |
peyo |
0:cd5404401c2f | 38 | * |
peyo |
0:cd5404401c2f | 39 | */ |
peyo |
0:cd5404401c2f | 40 | #include "aws_iot_mqtt_client_interface.h" |
peyo |
0:cd5404401c2f | 41 | #include "aws_iot_shadow_json_data.h" |
peyo |
0:cd5404401c2f | 42 | |
peyo |
0:cd5404401c2f | 43 | /*! |
peyo |
0:cd5404401c2f | 44 | * @brief Shadow Initialization parameters |
peyo |
0:cd5404401c2f | 45 | * |
peyo |
0:cd5404401c2f | 46 | * As the Shadow SDK uses MQTT underneath, it could be connected and disconnected on events to save some battery. |
peyo |
0:cd5404401c2f | 47 | * @note Always use the \c ShadowIniTParametersDefault to initialize this struct |
peyo |
0:cd5404401c2f | 48 | * |
peyo |
0:cd5404401c2f | 49 | * |
peyo |
0:cd5404401c2f | 50 | * |
peyo |
0:cd5404401c2f | 51 | */ |
peyo |
0:cd5404401c2f | 52 | typedef struct { |
peyo |
0:cd5404401c2f | 53 | char *pHost; ///< This will be unique to a customer and can be retrieved from the console |
peyo |
0:cd5404401c2f | 54 | uint16_t port; ///< By default the port is 8883 |
peyo |
0:cd5404401c2f | 55 | char *pRootCA; ///< Location with the Filename of the Root CA |
peyo |
0:cd5404401c2f | 56 | char *pClientCRT; ///< Location of Device certs signed by AWS IoT service |
peyo |
0:cd5404401c2f | 57 | char *pClientKey; ///< Location of Device private key |
peyo |
0:cd5404401c2f | 58 | bool enableAutoReconnect; ///< Set to true to enable auto reconnect |
peyo |
0:cd5404401c2f | 59 | iot_disconnect_handler disconnectHandler; ///< Callback to be invoked upon connection loss. |
peyo |
0:cd5404401c2f | 60 | } ShadowInitParameters_t; |
peyo |
0:cd5404401c2f | 61 | |
peyo |
0:cd5404401c2f | 62 | /*! |
peyo |
0:cd5404401c2f | 63 | * @brief Shadow Connect parameters |
peyo |
0:cd5404401c2f | 64 | * |
peyo |
0:cd5404401c2f | 65 | * As the Shadow SDK uses MQTT underneath, it could be connected and disconnected on events to save some battery. |
peyo |
0:cd5404401c2f | 66 | * @note Always use the \c ShadowConnectParametersDefault to initialize this struct |
peyo |
0:cd5404401c2f | 67 | * |
peyo |
0:cd5404401c2f | 68 | *d |
peyo |
0:cd5404401c2f | 69 | * |
peyo |
0:cd5404401c2f | 70 | */ |
peyo |
0:cd5404401c2f | 71 | typedef struct { |
peyo |
0:cd5404401c2f | 72 | char *pMyThingName; ///< Every device has a Thing Shadow and this is the placeholder for name |
peyo |
0:cd5404401c2f | 73 | char *pMqttClientId; ///< Currently the Shadow uses MQTT to connect and it is important to ensure we have unique client id |
peyo |
0:cd5404401c2f | 74 | uint16_t mqttClientIdLen; ///< Currently the Shadow uses MQTT to connect and it is important to ensure we have unique client id |
peyo |
0:cd5404401c2f | 75 | pApplicationHandler_t deleteActionHandler; ///< Callback to be invoked when Thing shadow for this device is deleted |
peyo |
0:cd5404401c2f | 76 | } ShadowConnectParameters_t; |
peyo |
0:cd5404401c2f | 77 | |
peyo |
0:cd5404401c2f | 78 | /*! |
peyo |
0:cd5404401c2f | 79 | * @brief This is set to defaults from the configuration file |
peyo |
0:cd5404401c2f | 80 | * The certs are set to NULL because they need the path to the file. shadow_sample.c file demonstrates on how to get the relative path |
peyo |
0:cd5404401c2f | 81 | * |
peyo |
0:cd5404401c2f | 82 | * \relates ShadowInitParameters_t |
peyo |
0:cd5404401c2f | 83 | */ |
peyo |
0:cd5404401c2f | 84 | extern const ShadowInitParameters_t ShadowInitParametersDefault; |
peyo |
0:cd5404401c2f | 85 | |
peyo |
0:cd5404401c2f | 86 | /*! |
peyo |
0:cd5404401c2f | 87 | * @brief This is set to defaults from the configuration file |
peyo |
0:cd5404401c2f | 88 | * The length of the client id is initialized as 0. This is due to C language limitations of using constant literals |
peyo |
0:cd5404401c2f | 89 | * only for creating const variables. The client id will be assigned using the value from aws_iot_config.h but the |
peyo |
0:cd5404401c2f | 90 | * length needs to be assigned in code. shadow_sample.c file demonstrates this. |
peyo |
0:cd5404401c2f | 91 | * |
peyo |
0:cd5404401c2f | 92 | * \relates ShadowConnectParameters_t |
peyo |
0:cd5404401c2f | 93 | */ |
peyo |
0:cd5404401c2f | 94 | extern const ShadowConnectParameters_t ShadowConnectParametersDefault; |
peyo |
0:cd5404401c2f | 95 | |
peyo |
0:cd5404401c2f | 96 | |
peyo |
0:cd5404401c2f | 97 | /** |
peyo |
0:cd5404401c2f | 98 | * @brief Initialize the Thing Shadow before use |
peyo |
0:cd5404401c2f | 99 | * |
peyo |
0:cd5404401c2f | 100 | * This function takes care of initializing the internal book-keeping data structures and initializing the IoT client. |
peyo |
0:cd5404401c2f | 101 | * |
peyo |
0:cd5404401c2f | 102 | * @param pClient A new MQTT Client to be used as the protocol layer. Will be initialized with pParams. |
peyo |
0:cd5404401c2f | 103 | * @return An IoT Error Type defining successful/failed Initialization |
peyo |
0:cd5404401c2f | 104 | */ |
peyo |
0:cd5404401c2f | 105 | IoT_Error_t aws_iot_shadow_init(AWS_IoT_Client *pClient, ShadowInitParameters_t *pParams); |
peyo |
0:cd5404401c2f | 106 | |
peyo |
0:cd5404401c2f | 107 | /** |
peyo |
0:cd5404401c2f | 108 | * @brief Connect to the AWS IoT Thing Shadow service over MQTT |
peyo |
0:cd5404401c2f | 109 | * |
peyo |
0:cd5404401c2f | 110 | * This function does the TLSv1.2 handshake and establishes the MQTT connection |
peyo |
0:cd5404401c2f | 111 | * |
peyo |
0:cd5404401c2f | 112 | * @param pClient MQTT Client used as the protocol layer |
peyo |
0:cd5404401c2f | 113 | * @param pParams Shadow Conenction parameters like TLS cert location |
peyo |
0:cd5404401c2f | 114 | * @return An IoT Error Type defining successful/failed Connection |
peyo |
0:cd5404401c2f | 115 | */ |
peyo |
0:cd5404401c2f | 116 | IoT_Error_t aws_iot_shadow_connect(AWS_IoT_Client *pClient, ShadowConnectParameters_t *pParams); |
peyo |
0:cd5404401c2f | 117 | |
peyo |
0:cd5404401c2f | 118 | /** |
peyo |
0:cd5404401c2f | 119 | * @brief Yield function to let the background tasks of MQTT and Shadow |
peyo |
0:cd5404401c2f | 120 | * |
peyo |
0:cd5404401c2f | 121 | * This function could be use in a separate thread waiting for the incoming messages, ensuring the connection is kept alive with the AWS Service. |
peyo |
0:cd5404401c2f | 122 | * It also ensures the expired requests of Shadow actions are cleared and Timeout callback is executed. |
peyo |
0:cd5404401c2f | 123 | * @note All callbacks ever used in the SDK will be executed in the context of this function. |
peyo |
0:cd5404401c2f | 124 | * |
peyo |
0:cd5404401c2f | 125 | * @param pClient MQTT Client used as the protocol layer |
peyo |
0:cd5404401c2f | 126 | * @param timeout in milliseconds, This is the maximum time the yield function will wait for a message and/or read the messages from the TLS buffer |
peyo |
0:cd5404401c2f | 127 | * @return An IoT Error Type defining successful/failed Yield |
peyo |
0:cd5404401c2f | 128 | */ |
peyo |
0:cd5404401c2f | 129 | IoT_Error_t aws_iot_shadow_yield(AWS_IoT_Client *pClient, uint32_t timeout); |
peyo |
0:cd5404401c2f | 130 | |
peyo |
0:cd5404401c2f | 131 | /** |
peyo |
0:cd5404401c2f | 132 | * @brief Disconnect from the AWS IoT Thing Shadow service over MQTT |
peyo |
0:cd5404401c2f | 133 | * |
peyo |
0:cd5404401c2f | 134 | * This will close the underlying TCP connection, MQTT connection will also be closed |
peyo |
0:cd5404401c2f | 135 | * |
peyo |
0:cd5404401c2f | 136 | * @param pClient MQTT Client used as the protocol layer |
peyo |
0:cd5404401c2f | 137 | * @return An IoT Error Type defining successful/failed disconnect status |
peyo |
0:cd5404401c2f | 138 | */ |
peyo |
0:cd5404401c2f | 139 | IoT_Error_t aws_iot_shadow_disconnect(AWS_IoT_Client *pClient); |
peyo |
0:cd5404401c2f | 140 | |
peyo |
0:cd5404401c2f | 141 | /** |
peyo |
0:cd5404401c2f | 142 | * @brief Thing Shadow Acknowledgment enum |
peyo |
0:cd5404401c2f | 143 | * |
peyo |
0:cd5404401c2f | 144 | * This enum type is use in the callback for the action response |
peyo |
0:cd5404401c2f | 145 | * |
peyo |
0:cd5404401c2f | 146 | */ |
peyo |
0:cd5404401c2f | 147 | typedef enum { |
peyo |
0:cd5404401c2f | 148 | SHADOW_ACK_TIMEOUT, SHADOW_ACK_REJECTED, SHADOW_ACK_ACCEPTED |
peyo |
0:cd5404401c2f | 149 | } Shadow_Ack_Status_t; |
peyo |
0:cd5404401c2f | 150 | |
peyo |
0:cd5404401c2f | 151 | /** |
peyo |
0:cd5404401c2f | 152 | * @brief Thing Shadow Action type enum |
peyo |
0:cd5404401c2f | 153 | * |
peyo |
0:cd5404401c2f | 154 | * This enum type is use in the callback for the action response |
peyo |
0:cd5404401c2f | 155 | * |
peyo |
0:cd5404401c2f | 156 | */ |
peyo |
0:cd5404401c2f | 157 | typedef enum { |
peyo |
0:cd5404401c2f | 158 | SHADOW_GET, SHADOW_UPDATE, SHADOW_DELETE |
peyo |
0:cd5404401c2f | 159 | } ShadowActions_t; |
peyo |
0:cd5404401c2f | 160 | |
peyo |
0:cd5404401c2f | 161 | |
peyo |
0:cd5404401c2f | 162 | /** |
peyo |
0:cd5404401c2f | 163 | * @brief Function Pointer typedef used as the callback for every action |
peyo |
0:cd5404401c2f | 164 | * |
peyo |
0:cd5404401c2f | 165 | * This function will be called from the context of \c aws_iot_shadow_yield() context |
peyo |
0:cd5404401c2f | 166 | * |
peyo |
0:cd5404401c2f | 167 | * @param pThingName Thing Name of the response received |
peyo |
0:cd5404401c2f | 168 | * @param action The response of the action |
peyo |
0:cd5404401c2f | 169 | * @param status Informs if the action was Accepted/Rejected or Timed out |
peyo |
0:cd5404401c2f | 170 | * @param pReceivedJsonDocument Received JSON document |
peyo |
0:cd5404401c2f | 171 | * @param pContextData the void* data passed in during the action call(update, get or delete) |
peyo |
0:cd5404401c2f | 172 | * |
peyo |
0:cd5404401c2f | 173 | */ |
peyo |
0:cd5404401c2f | 174 | typedef void (*fpActionCallback_t)(const char *pThingName, ShadowActions_t action, Shadow_Ack_Status_t status, |
peyo |
0:cd5404401c2f | 175 | const char *pReceivedJsonDocument, void *pContextData); |
peyo |
0:cd5404401c2f | 176 | |
peyo |
0:cd5404401c2f | 177 | /** |
peyo |
0:cd5404401c2f | 178 | * @brief This function is the one used to perform an Update action to a Thing Name's Shadow. |
peyo |
0:cd5404401c2f | 179 | * |
peyo |
0:cd5404401c2f | 180 | * update is one of the most frequently used functionality by a device. In most cases the device may be just reporting few params to update the thing shadow in the cloud |
peyo |
0:cd5404401c2f | 181 | * Update Action if no callback or if the JSON document does not have a client token then will just publish the update and not track it. |
peyo |
0:cd5404401c2f | 182 | * |
peyo |
0:cd5404401c2f | 183 | * @note The update has to subscribe to two topics update/accepted and update/rejected. This function waits 2 seconds to ensure the subscriptions are registered before publishing the update message. |
peyo |
0:cd5404401c2f | 184 | * The following steps are performed on using this function: |
peyo |
0:cd5404401c2f | 185 | * 1. Subscribe to Shadow topics - $aws/things/{thingName}/shadow/update/accepted and $aws/things/{thingName}/shadow/update/rejected |
peyo |
0:cd5404401c2f | 186 | * 2. wait for 2 seconds for the subscription to take effect |
peyo |
0:cd5404401c2f | 187 | * 3. Publish on the update topic - $aws/things/{thingName}/shadow/update |
peyo |
0:cd5404401c2f | 188 | * 4. In the \c aws_iot_shadow_yield() function the response will be handled. In case of timeout or if the response is received, the subscription to shadow response topics are un-subscribed from. |
peyo |
0:cd5404401c2f | 189 | * On the contrary if the persistent subscription is set to true then the un-subscribe will not be done. The topics will always be listened to. |
peyo |
0:cd5404401c2f | 190 | * |
peyo |
0:cd5404401c2f | 191 | * @param pClient MQTT Client used as the protocol layer |
peyo |
0:cd5404401c2f | 192 | * @param pThingName Thing Name of the shadow that needs to be Updated |
peyo |
0:cd5404401c2f | 193 | * @param pJsonString The update action expects a JSON document to send. The JSON String should be a null terminated string. This JSON document should adhere to the AWS IoT Thing Shadow specification. To help in the process of creating this document- SDK provides apis in \c aws_iot_shadow_json_data.h |
peyo |
0:cd5404401c2f | 194 | * @param callback This is the callback that will be used to inform the caller of the response from the AWS IoT Shadow service.Callback could be set to NULL if response is not important |
peyo |
0:cd5404401c2f | 195 | * @param pContextData This is an extra parameter that could be passed along with the callback. It should be set to NULL if not used |
peyo |
0:cd5404401c2f | 196 | * @param timeout_seconds It is the time the SDK will wait for the response on either accepted/rejected before declaring timeout on the action |
peyo |
0:cd5404401c2f | 197 | * @param isPersistentSubscribe As mentioned above, every time if a device updates the same shadow then this should be set to true to avoid repeated subscription and unsubscription. If the Thing Name is one off update then this should be set to false |
peyo |
0:cd5404401c2f | 198 | * @return An IoT Error Type defining successful/failed update action |
peyo |
0:cd5404401c2f | 199 | */ |
peyo |
0:cd5404401c2f | 200 | IoT_Error_t aws_iot_shadow_update(AWS_IoT_Client *pClient, const char *pThingName, char *pJsonString, |
peyo |
0:cd5404401c2f | 201 | fpActionCallback_t callback, void *pContextData, uint8_t timeout_seconds, |
peyo |
0:cd5404401c2f | 202 | bool isPersistentSubscribe); |
peyo |
0:cd5404401c2f | 203 | |
peyo |
0:cd5404401c2f | 204 | /** |
peyo |
0:cd5404401c2f | 205 | * @brief This function is the one used to perform an Get action to a Thing Name's Shadow. |
peyo |
0:cd5404401c2f | 206 | * |
peyo |
0:cd5404401c2f | 207 | * One use of this function is usually to get the config of a device at boot up. |
peyo |
0:cd5404401c2f | 208 | * It is similar to the Update function internally except it does not take a JSON document as the input. The entire JSON document will be sent over the accepted topic |
peyo |
0:cd5404401c2f | 209 | * |
peyo |
0:cd5404401c2f | 210 | * @param pClient MQTT Client used as the protocol layer |
peyo |
0:cd5404401c2f | 211 | * @param pThingName Thing Name of the JSON document that is needed |
peyo |
0:cd5404401c2f | 212 | * @param callback This is the callback that will be used to inform the caller of the response from the AWS IoT Shadow service.Callback could be set to NULL if response is not important |
peyo |
0:cd5404401c2f | 213 | * @param pContextData This is an extra parameter that could be passed along with the callback. It should be set to NULL if not used |
peyo |
0:cd5404401c2f | 214 | * @param timeout_seconds It is the time the SDK will wait for the response on either accepted/rejected before declaring timeout on the action |
peyo |
0:cd5404401c2f | 215 | * @param isPersistentSubscribe As mentioned above, every time if a device gets the same Sahdow (JSON document) then this should be set to true to avoid repeated subscription and un-subscription. If the Thing Name is one off get then this should be set to false |
peyo |
0:cd5404401c2f | 216 | * @return An IoT Error Type defining successful/failed get action |
peyo |
0:cd5404401c2f | 217 | */ |
peyo |
0:cd5404401c2f | 218 | IoT_Error_t aws_iot_shadow_get(AWS_IoT_Client *pClient, const char *pThingName, fpActionCallback_t callback, |
peyo |
0:cd5404401c2f | 219 | void *pContextData, uint8_t timeout_seconds, bool isPersistentSubscribe); |
peyo |
0:cd5404401c2f | 220 | |
peyo |
0:cd5404401c2f | 221 | /** |
peyo |
0:cd5404401c2f | 222 | * @brief This function is the one used to perform an Delete action to a Thing Name's Shadow. |
peyo |
0:cd5404401c2f | 223 | * |
peyo |
0:cd5404401c2f | 224 | * This is not a very common use case for device. It is generally the responsibility of the accompanying app to do the delete. |
peyo |
0:cd5404401c2f | 225 | * It is similar to the Update function internally except it does not take a JSON document as the input. The Thing Shadow referred by the ThingName will be deleted. |
peyo |
0:cd5404401c2f | 226 | * |
peyo |
0:cd5404401c2f | 227 | * @param pClient MQTT Client used as the protocol layer |
peyo |
0:cd5404401c2f | 228 | * @param pThingName Thing Name of the Shadow that should be deleted |
peyo |
0:cd5404401c2f | 229 | * @param callback This is the callback that will be used to inform the caller of the response from the AWS IoT Shadow service.Callback could be set to NULL if response is not important |
peyo |
0:cd5404401c2f | 230 | * @param pContextData This is an extra parameter that could be passed along with the callback. It should be set to NULL if not used |
peyo |
0:cd5404401c2f | 231 | * @param timeout_seconds It is the time the SDK will wait for the response on either accepted/rejected before declaring timeout on the action |
peyo |
0:cd5404401c2f | 232 | * @param isPersistentSubscribe As mentioned above, every time if a device deletes the same Shadow (JSON document) then this should be set to true to avoid repeated subscription and un-subscription. If the Thing Name is one off delete then this should be set to false |
peyo |
0:cd5404401c2f | 233 | * @return An IoT Error Type defining successful/failed delete action |
peyo |
0:cd5404401c2f | 234 | */ |
peyo |
0:cd5404401c2f | 235 | IoT_Error_t aws_iot_shadow_delete(AWS_IoT_Client *pClient, const char *pThingName, fpActionCallback_t callback, |
peyo |
0:cd5404401c2f | 236 | void *pContextData, uint8_t timeout_seconds, bool isPersistentSubscriptions); |
peyo |
0:cd5404401c2f | 237 | |
peyo |
0:cd5404401c2f | 238 | /** |
peyo |
0:cd5404401c2f | 239 | * @brief This function is used to listen on the delta topic of #AWS_IOT_MY_THING_NAME mentioned in the aws_iot_config.h file. |
peyo |
0:cd5404401c2f | 240 | * |
peyo |
0:cd5404401c2f | 241 | * Any time a delta is published the Json document will be delivered to the pStruct->cb. If you don't want the parsing done by the SDK then use the jsonStruct_t key set to "state". A good example of this is displayed in the sample_apps/shadow_console_echo.c |
peyo |
0:cd5404401c2f | 242 | * |
peyo |
0:cd5404401c2f | 243 | * @param pClient MQTT Client used as the protocol layer |
peyo |
0:cd5404401c2f | 244 | * @param pStruct The struct used to parse JSON value |
peyo |
0:cd5404401c2f | 245 | * @return An IoT Error Type defining successful/failed delta registering |
peyo |
0:cd5404401c2f | 246 | */ |
peyo |
0:cd5404401c2f | 247 | IoT_Error_t aws_iot_shadow_register_delta(AWS_IoT_Client *pClient, jsonStruct_t *pStruct); |
peyo |
0:cd5404401c2f | 248 | |
peyo |
0:cd5404401c2f | 249 | /** |
peyo |
0:cd5404401c2f | 250 | * @brief Reset the last received version number to zero. |
peyo |
0:cd5404401c2f | 251 | * This will be useful if the Thing Shadow is deleted and would like to to reset the local version |
peyo |
0:cd5404401c2f | 252 | * @return no return values |
peyo |
0:cd5404401c2f | 253 | * |
peyo |
0:cd5404401c2f | 254 | */ |
peyo |
0:cd5404401c2f | 255 | void aws_iot_shadow_reset_last_received_version(void); |
peyo |
0:cd5404401c2f | 256 | |
peyo |
0:cd5404401c2f | 257 | /** |
peyo |
0:cd5404401c2f | 258 | * @brief Version of a document is received with every accepted/rejected and the SDK keeps track of the last received version of the JSON document of #AWS_IOT_MY_THING_NAME shadow |
peyo |
0:cd5404401c2f | 259 | * |
peyo |
0:cd5404401c2f | 260 | * One exception to this version tracking is that, the SDK will ignore the version from update/accepted topic. Rest of the responses will be scanned to update the version number. |
peyo |
0:cd5404401c2f | 261 | * Accepting version change for update/accepted may cause version conflicts for delta message if the update message is received before the delta. |
peyo |
0:cd5404401c2f | 262 | * |
peyo |
0:cd5404401c2f | 263 | * @return version number of the last received response |
peyo |
0:cd5404401c2f | 264 | * |
peyo |
0:cd5404401c2f | 265 | */ |
peyo |
0:cd5404401c2f | 266 | uint32_t aws_iot_shadow_get_last_received_version(void); |
peyo |
0:cd5404401c2f | 267 | |
peyo |
0:cd5404401c2f | 268 | /** |
peyo |
0:cd5404401c2f | 269 | * @brief Enable the ignoring of delta messages with old version number |
peyo |
0:cd5404401c2f | 270 | * |
peyo |
0:cd5404401c2f | 271 | * As we use MQTT underneath, there could be more than 1 of the same message if we use QoS 0. To avoid getting called for the same message, this functionality should be enabled. All the old message will be ignored |
peyo |
0:cd5404401c2f | 272 | */ |
peyo |
0:cd5404401c2f | 273 | void aws_iot_shadow_enable_discard_old_delta_msgs(void); |
peyo |
0:cd5404401c2f | 274 | |
peyo |
0:cd5404401c2f | 275 | /** |
peyo |
0:cd5404401c2f | 276 | * @brief Disable the ignoring of delta messages with old version number |
peyo |
0:cd5404401c2f | 277 | */ |
peyo |
0:cd5404401c2f | 278 | void aws_iot_shadow_disable_discard_old_delta_msgs(void); |
peyo |
0:cd5404401c2f | 279 | |
peyo |
0:cd5404401c2f | 280 | /** |
peyo |
0:cd5404401c2f | 281 | * @brief This function is used to enable or disable autoreconnect |
peyo |
0:cd5404401c2f | 282 | * |
peyo |
0:cd5404401c2f | 283 | * Any time a disconnect happens the underlying MQTT client attempts to reconnect if this is set to true |
peyo |
0:cd5404401c2f | 284 | * |
peyo |
0:cd5404401c2f | 285 | * @param pClient MQTT Client used as the protocol layer |
peyo |
0:cd5404401c2f | 286 | * @param newStatus The new status to set the autoreconnect option to |
peyo |
0:cd5404401c2f | 287 | * |
peyo |
0:cd5404401c2f | 288 | * @return An IoT Error Type defining successful/failed operation |
peyo |
0:cd5404401c2f | 289 | */ |
peyo |
0:cd5404401c2f | 290 | IoT_Error_t aws_iot_shadow_set_autoreconnect_status(AWS_IoT_Client *pClient, bool newStatus); |
peyo |
0:cd5404401c2f | 291 | |
peyo |
0:cd5404401c2f | 292 | #ifdef __cplusplus |
peyo |
0:cd5404401c2f | 293 | } |
peyo |
0:cd5404401c2f | 294 | #endif |
peyo |
0:cd5404401c2f | 295 | |
peyo |
0:cd5404401c2f | 296 | #endif //AWS_IOT_SDK_SRC_IOT_SHADOW_H_ |