/**
@page shadow_demo AWS IoT Device Shadow
@brief This demo demonstrates usage of the AWS IoT Device Shadow library.
@section shadow_demo_main AWS IoT Device Shadow Demo
@brief Demo application that uses the AWS IoT Device Shadow library, MQTT Client library,
and JSON library to interact with the AWS IoT Device Shadow service.
AWS IoT Device Shadow service supports 2 types of shadows for a Thing; a classic
shadow and multiple named shadows. This demo works with either a classic shadow or
a named shadow depending on the value of demo config SHADOW_NAME. The demo
can be configured as listed below.
1. Classic shadow - Demo config SHADOW_NAME can be defined as
#SHADOW_NAME_CLASSIC to use classic shadow in the demo. This is the default
configuration for the demo.
2. Named shadow - Demo config SHADOW_NAME can be defined as a non empty
C string. This configuration value will be used as the name of the shadow in
the demo.
In this demo, the device is assumed to have the powerOn state, which can be 1 or 0
depending on whether or not the device is powered on. This state is maintained in
the device's classic shadow or a named shadow depending on the demo configuration
SHADOW_NAME. The demo does the following operations:
- Establish an MQTT connection. ( step 1. )
- Attempt to delete the shadow if it exists already. (step 6 ~ step 23)
- Assemble MQTT topic strings for device shadow operations using macros defined
by the Device Shadow library. ( step 24. )
- Subscribe to the MQTT topics for shadow update operations. ( step 26. )
- Publish a desired powerOn state. This causes a device shadow update delta
message to be sent to the device. ( step 29 ~ step 31. )
- Handle the incoming MQTT message in the MQTT event callback and determine
whether the message is related to the device shadow using @ref Shadow_MatchTopicString.
If the message is a device shadow update delta message, set a flag for the
main function to know. The main function will then publish a second message to
update the reported powerOn state. ( step 34 ~ step 39. )
- Handle the incoming MQTT message again in the MQTT event callback and
determine whether the message is related to the device shadow. If the message
is a device shadow update accepted message, verify that it is for the update
operation initiated previously by ensuring that it contains the same
clientToken as sent in the update operation. ( step 34 ~ step 39. )
@image html shadow_demo_main.png width=50%
*/