Given the topic string of an incoming message, determine whether it is related to a device shadow; if it is, return information about the type of device shadow message, and a pointer to the Thing Name inside of the topic string. See ShadowMessageType_t for the list of message types. Those types correspond to Device Shadow Topics.
uint16_t topicLength,
const char ** pThingName,
uint16_t * pThingNameLength );
ShadowStatus_t
Return codes from Shadow functions.
Definition: shadow.h:94
ShadowMessageType_t
Each of these values describes the type of a shadow message. https://docs.aws.amazon....
Definition: shadow.h:54
ShadowStatus_t Shadow_MatchTopic(const char *pTopic, uint16_t topicLength, ShadowMessageType_t *pMessageType, const char **pThingName, uint16_t *pThingNameLength)
Given the topic string of an incoming message, determine whether it is related to a device shadow; if...
Definition: shadow.c:430
- Note
- When this function returns, the pointer pThingName points at the first character of the <thingName> segment inside of the topic string. Caller is responsible for keeping the memory holding the topic string around while accessing the Thing Name through pThingName.
- Parameters
-
| [in] | pTopic | Pointer to the MQTT topic string. Does not have to be null-terminated. |
| [in] | topicLength | Length of the MQTT topic string. |
| [out] | pMessageType | Pointer to caller-supplied memory for returning the type of the shadow message. |
| [out] | pThingName | Points to the 1st character of Thing Name inside of the topic string, and can be null if caller does not need to know the Thing Name contained in the topic string. |
| [out] | pThingNameLength | Pointer to caller-supplied memory for returning the length of the Thing Name, and can be null if caller does not need to know the Thing Name contained in the topic string. |
- Returns
- One of the following:
- SHADOW_SUCCESS if the message is related to a device shadow;
- An error code defined in ShadowStatus_t if the message is not related to a device shadow, if any input parameter is invalid, or if the function fails to parse the topic string.
Example
#define SHADOW_TOPIC_MAX_LENGTH ( 256U )
ShadowStatus_te shadowStatus = SHADOW_STATUS_SUCCESS;
char * pTopicName;
uint16_t topicNameLength;
topicNameLength,
& messageType,
NULL,
NULL );
if( shadowStatus == SHADOW_STATUS_SUCCESS )
{
}