AWS IoT Device SDK C: Shadow
AWS IoT Device Shadow library
Return to main page ↑
AwsIotShadow_DeleteAsync

Delete a Thing Shadow and receive an asynchronous notification when the Delete completes.

const char * pThingName,
size_t thingNameLength,
uint32_t flags,
const AwsIotShadowCallbackInfo_t * pCallbackInfo,
AwsIotShadowOperation_t * const pDeleteOperation );

This function deletes any existing Shadow document for the given Thing Name. If the given Thing has no Shadow and this function is called, the result will be AWS_IOT_SHADOW_NOT_FOUND.

Deleting a Shadow involves sending an MQTT message to AWS IoT and waiting on a response. This message will always be sent at MQTT QoS 0.

Parameters
[in]mqttConnectionThe MQTT connection to use for Shadow delete.
[in]pThingNameThe Thing Name associated with the Shadow to delete.
[in]thingNameLengthThe length of pThingName.
[in]flagsFlags which modify the behavior of this function. See Shadow Function Flags.
[in]pCallbackInfoAsynchronous notification of this function's completion.
[out]pDeleteOperationSet to a handle by which this operation may be referenced after this function returns. This reference is invalidated once the Shadow delete completes.
Returns
This function will return AWS_IOT_SHADOW_STATUS_PENDING upon successfully queuing a Shadow delete.
If this function fails before queuing a Shadow delete, it will return one of:
Upon successful completion of the Shadow delete (either through an AwsIotShadowCallbackInfo_t or AwsIotShadow_Wait), the status will be AWS_IOT_SHADOW_SUCCESS.
Should the Shadow delete fail, the status will be one of:
See also
AwsIotShadow_DeleteSync for a blocking variant of this function.

Example

#define THING_NAME "Test_device"
#define THING_NAME_LENGTH ( sizeof( THING_NAME ) - 1 )
// Shadow operation handle.
// Queue a Shadow delete.
AwsIotShadowError_t deleteResult = AwsIotShadow_DeleteAsync( mqttConnection,
THING_NAME,
NULL,
&deleteOperation );
// Shadow delete should return AWS_IOT_SHADOW_STATUS_PENDING upon success.
if( deleteResult == AWS_IOT_SHADOW_STATUS_PENDING )
{
// Wait for the Shadow delete to complete.
deleteResult = AwsIotShadow_Wait( deleteOperation, 5000 );
// Delete result should be AWS_IOT_SHADOW_SUCCESS upon successfully
// deleting an existing Shadow.
}