in source/shadow.c [873:925]
ShadowStatus_t Shadow_AssembleTopicString( ShadowTopicStringType_t topicType,
const char * pThingName,
uint8_t thingNameLength,
const char * pShadowName,
uint8_t shadowNameLength,
char * pTopicBuffer,
uint16_t bufferSize,
uint16_t * pOutLength )
{
uint16_t generatedTopicStringLength = 0U;
ShadowStatus_t shadowStatus = validateAssembleTopicParameters( topicType,
pThingName,
thingNameLength,
pShadowName,
shadowNameLength,
pTopicBuffer,
pOutLength );
if( shadowStatus == SHADOW_SUCCESS )
{
generatedTopicStringLength = SHADOW_PREFIX_LENGTH + /* Prefix ("$aws/things/"). */
thingNameLength + /* Thing name. */
( ( shadowNameLength > 0U ) ? /* Handle named or classic shadow */
( SHADOW_NAMED_ROOT_LENGTH + shadowNameLength ) :
SHADOW_CLASSIC_ROOT_LENGTH ) +
getShadowOperationLength( topicType ); /* Shadow operation. */
if( bufferSize < generatedTopicStringLength )
{
shadowStatus = SHADOW_BUFFER_TOO_SMALL;
LogError( ( "Input bufferSize too small, bufferSize %u, required %u.",
( unsigned int ) bufferSize,
( unsigned int ) generatedTopicStringLength ) );
}
}
if( shadowStatus == SHADOW_SUCCESS )
{
/* With everything validated, now create the topic string */
createShadowTopicString( topicType,
pThingName,
thingNameLength,
pShadowName,
shadowNameLength,
pTopicBuffer );
/* Return the generated topic string length to the caller. */
*pOutLength = generatedTopicStringLength;
}
return shadowStatus;
}