AWS IoT Device SDK C:
Shadow
AWS IoT Device Shadow library
|
Return to main page ↑ |
Retrieve a Thing Shadow and receive an asynchronous notification when the Shadow document is received.
This function retrieves the Thing Shadow document currently stored by the Shadow service. If a given Thing has no Shadow and this function is called, the result will be AWS_IOT_SHADOW_NOT_FOUND.
Shadow documents may be large, and their size is not known beforehand. Therefore, this function works best when memory is dynamically allocated. Because the Shadow document is retrieved in an MQTT PUBLISH packet, the MQTT library will allocate a buffer for the Shadow document using IotMqtt_MallocMessage.
The MQTT library may free the buffer for a retrieved Shadow document as soon as the Shadow completion callback returns. Therefore, any data needed later must be copied from the Shadow document. Similarly, if the flag AWS_IOT_SHADOW_FLAG_WAITABLE is given to this function (which indicates that the Shadow document will be needed after the Shadow operation completes), AwsIotShadowDocumentInfo_t.mallocDocument must be provided to allocate a longer-lasting buffer.
[in] | mqttConnection | The MQTT connection to use for Shadow get. |
[in] | pGetInfo | Shadow document parameters. |
[in] | flags | Flags which modify the behavior of this function. See Shadow Function Flags. |
[in] | pCallbackInfo | Asynchronous notification of this function's completion. |
[out] | pGetOperation | Set to a handle by which this operation may be referenced after this function returns. This reference is invalidated once the Shadow get completes. |
Example
See AwsIotShadow_Wait Example 2 for an example of using this function with AWS_IOT_SHADOW_FLAG_WAITABLE and AwsIotShadow_Wait.