Add helpful asterisk comments to the shadow demo. (#409)

* Add helpful asterisk comments to the shadow demo.

* Update FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Device_Shadow_Demo/DemoTasks/ShadowDemoMainExample.c

* Add stuff to the license header for GHA checks.
pull/410/head
SarenaAWS 4 years ago committed by GitHub
parent fdc9d736b3
commit d59a4e4f3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,5 @@
/*
* FreeRTOS Kernel V10.3.0
* FreeRTOS V202011.00
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
@ -19,9 +19,10 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* http://www.FreeRTOS.org
* http://aws.amazon.com/freertos
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*
* 1 tab == 4 spaces!
*/
/*
@ -589,26 +590,35 @@ void prvShadowDemoTask( void * pvParameters )
/* Remove compiler warnings about unused parameters. */
( void ) pvParameters;
/****************************** Connect. ******************************/
demoStatus = xEstablishMqttSession( &xMqttContext,
&xNetworkContext,
&xBuffer,
prvEventCallback );
if( pdFAIL == demoStatus )
if( demoStatus == pdFAIL )
{
/* Log error to indicate connection failure. */
LogError( ( "Failed to connect to MQTT broker." ) );
}
else
if( demoStatus == pdPASS )
{
/* First of all, try to delete any Shadow document in the cloud. */
/* Try to delete any Shadow document in the cloud. This is done to
* ensure possbile previous Shadow documents do not affect the state
* expected in the current demo. */
demoStatus = xPublishToTopic( &xMqttContext,
SHADOW_TOPIC_STRING_DELETE( democonfigTHING_NAME ),
SHADOW_TOPIC_LENGTH_DELETE( THING_NAME_LENGTH ),
pcUpdateDocument,
0U );
}
/********************* Subscribe to Shadow topics. ************************/
/* Then try to subscribe the Shadow topics. */
/* Then try to subscribe shadow topics. */
if( demoStatus == pdPASS )
{
demoStatus = xSubscribeToTopic( &xMqttContext,
@ -630,10 +640,13 @@ void prvShadowDemoTask( void * pvParameters )
SHADOW_TOPIC_LENGTH_UPDATE_REJECTED( THING_NAME_LENGTH ) );
}
/* This demo uses a constant #democonfigTHING_NAME known at compile time therefore we can use macros to
* assemble shadow topic strings.
* If the thing name is known at run time, then we could use the API #Shadow_GetTopicString to
* assemble shadow topic strings, here is the example for /update/delta:
/********************* Publish to Shadow topics. **********************/
/* This demo uses a constant #democonfigTHING_NAME known at compile time
* therefore we can use macros to assemble shadow topic strings.
* If the thing name is known at run time, then we could use the API
* #Shadow_GetTopicString to assemble shadow topic strings, here is the
* example for /update/delta:
*
* For /update/delta:
*
@ -655,8 +668,8 @@ void prvShadowDemoTask( void * pvParameters )
*/
/* Then we publish a desired state to the /update topic. Since we've deleted
* the device shadow at the beginning of the demo, this will cause a delta message
* to be published, which we have subscribed to.
* the device shadow at the beginning of the demo, this will cause a delta
* message to be published, which we have subscribed to.
* In many real applications, the desired state is not published by
* the device itself. But for the purpose of making this demo self-contained,
* we publish one here so that we can receive a delta message later.
@ -721,6 +734,8 @@ void prvShadowDemoTask( void * pvParameters )
}
}
/****************** Unsubscribe from Shadow topics. *******************/
if( demoStatus == pdPASS )
{
LogInfo( ( "Start to unsubscribe shadow topics and disconnect from MQTT. \r\n" ) );
@ -762,7 +777,9 @@ void prvShadowDemoTask( void * pvParameters )
}
}
/* The MQTT session is always disconnected, even there were prior failures. */
/****************************** Disconnect. *******************************/
/* The MQTT session is always disconnected, even if there were prior failures. */
demoStatus = xDisconnectMqttSession( &xMqttContext, &xNetworkContext );
/* This demo performs only Device Shadow operations. If matching the Shadow
@ -781,7 +798,6 @@ void prvShadowDemoTask( void * pvParameters )
{
LogError( ( "Shadow Demo failed." ) );
}
}
/* Delete this task. */
LogInfo( ( "Deleting Shadow Demo task." ) );

Loading…
Cancel
Save