Implements the user-facing functions of the Shadow library. More...
Functions | |
static ShadowStatus_t | containsSubString (const char *pString, uint16_t stringLength, const char *pSubString, uint16_t subStringLength) |
Determine if the string contains the substring. More... | |
static ShadowStatus_t | validateThingName (const char *pString, uint16_t stringLength, uint16_t *pThingNameLength) |
Check if the Thing Name is valid. More... | |
static ShadowStatus_t | extractShadowMessageType (const char *pString, uint16_t stringLength, ShadowMessageType_t *pMessageType) |
Extract the Shadow message type from a string. More... | |
static const char * | getShadowOperationString (ShadowTopicStringType_t topicType) |
Get the shadow operation string for a given shadow topic type. More... | |
static uint16_t | getShadowOperationLength (ShadowTopicStringType_t topicType) |
Get the shadow operation string length for a given shadow topic type. More... | |
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 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. More... | |
ShadowStatus_t | Shadow_GetTopicString (ShadowTopicStringType_t topicType, const char *pThingName, uint8_t thingNameLength, char *pTopicBuffer, uint16_t bufferSize, uint16_t *pOutLength) |
Assemble shadow topic string when Thing Name is only known at run time. If the Thing Name is known at compile time, use SHADOW_TOPIC_STRING_* macros instead. More... | |
Implements the user-facing functions of the Shadow library.
|
static |
Determine if the string contains the substring.
[in] | pString | Pointer to the string. |
[in] | stringLength | Length of pString. |
[in] | pSubString | Pointer to the substring. |
[in] | subStringLength | Length of pSubString. |
|
static |
Check if the Thing Name is valid.
[in] | pString | Pointer to the starting of thing name. |
[in] | stringLength | Length of pString. |
[out] | pThingNameLength | Pointer to caller-supplied memory for returning the length of the Thing Name. |
|
static |
Extract the Shadow message type from a string.
[in] | pString | Pointer to the string. |
[in] | stringLength | Length of pString. |
[out] | pMessageType | Pointer to call-supplied memory for returning the type of the shadow message. |
|
static |
Get the shadow operation string for a given shadow topic type.
[in] | topicType | The given shadow topic type. |
|
static |
Get the shadow operation string length for a given shadow topic type.
[in] | topicType | The given shadow topic type. |
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 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.
[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. |
Example
ShadowStatus_t Shadow_GetTopicString | ( | ShadowTopicStringType_t | topicType, |
const char * | pThingName, | ||
uint8_t | thingNameLength, | ||
char * | pTopicBuffer, | ||
uint16_t | bufferSize, | ||
uint16_t * | pOutLength | ||
) |
Assemble shadow topic string when Thing Name is only known at run time. If the Thing Name is known at compile time, use SHADOW_TOPIC_STRING_* macros instead.
[in] | topicType | Indicates what topic will be written into the buffer pointed to by pTopicBuffer. can be one of:
|
[in] | pThingName | Thing Name string. No need to be null terminated. Must not be NULL. |
[in] | thingNameLength | Length of Thing Name string pointed to by pThingName. Must not be zero. |
[out] | pTopicBuffer | Pointer to buffer for returning the topic string. Caller is responsible for supplying memory pointed to by pTopicBuffer. This function does not fill in the terminating null character. The app can supply a buffer that does not have space for holding the null character. |
[in] | bufferSize | Length of pTopicBuffer. This function will return error if bufferSize is less than the length of the assembled topic string. |
[out] | pOutLength | Pointer to caller-supplied memory for returning the length of the topic string. |
Example