AWS IoT Device Defender  v1.1.1
AWS IoT Device Defender Client Library
Defender_GetTopic

Populate the topic string for a Device Defender operation.

uint16_t bufferLength,
const char * pThingName,
uint16_t thingNameLength,
uint16_t * pOutLength );
Parameters
[in]pBufferThe buffer to write the topic string into.
[in]bufferLengthThe length of the buffer.
[in]pThingNameThe device's thingName as registered with AWS IoT.
[in]thingNameLengthThe length of the thing name.
[in]apiThe desired Device Defender API.
[out]pOutLengthThe length of the topic string written to the buffer.
Returns
DefenderSuccess if the topic string is written to the buffer; DefenderBadParameter if invalid parameters are passed; DefenderBufferTooSmall if the buffer cannot hold the full topic string.

Example

// The following example shows how to use the Defender_GetTopic API to
// generate a topic string for getting a JSON report accepted response.
#define TOPIC_BUFFER_LENGTH ( 256U )
// Every device should have a unique thing name registered with AWS IoT Core.
// This example assumes that the device has a unique serial number which is
// registered as the thing name with AWS IoT Core.
const char * pThingName = GetDeviceSerialNumber();
uint16_t thingNameLength = ( uint16_t )strlen( pThingname );
char topicBuffer[ TOPIC_BUFFER_LENGTH ] = { 0 };
uint16_t topicLength = 0;
status = Defender_GetTopic( &( topicBuffer[ 0 ] ),
TOPIC_BUFFER_LENGTH,
pThingName,
thingNameLength,
&( topicLength ) );
if( status == DefenderSuccess )
{
// The buffer topicBuffer contains the topic string of length
// topicLength for getting a JSON report accepted response. Subscribe
// to this topic using an MQTT client of your choice.
}
DefenderSuccess
@ DefenderSuccess
Definition: defender.h:58
DefenderJsonReportAccepted
@ DefenderJsonReportAccepted
Definition: defender.h:72
Defender_GetTopic
DefenderStatus_t Defender_GetTopic(char *pBuffer, uint16_t bufferLength, const char *pThingName, uint16_t thingNameLength, DefenderTopic_t api, uint16_t *pOutLength)
Populate the topic string for a Device Defender operation.
Definition: defender.c:381
DefenderStatus_t
DefenderStatus_t
Return codes from defender APIs.
Definition: defender.h:56
DefenderTopic_t
DefenderTopic_t
Topic values for subscription requests.
Definition: defender.h:69