Implements the user-facing functions of the Shadow library. More...
Macros | |
#define | SHADOW_OP_UPDATE_ACCEPTED SHADOW_OP_UPDATE SHADOW_SUFFIX_ACCEPTED |
The string representing "/shadow/update/accepted". | |
#define | SHADOW_OP_UPDATE_REJECTED SHADOW_OP_UPDATE SHADOW_SUFFIX_REJECTED |
The string representing "/shadow/update/rejected". | |
#define | SHADOW_OP_UPDATE_DELTA SHADOW_OP_UPDATE SHADOW_SUFFIX_DELTA |
The string representing "/shadow/update/delta". | |
#define | SHADOW_OP_UPDATE_DOCUMENTS SHADOW_OP_UPDATE SHADOW_SUFFIX_DOCUMENTS |
The string representing "/shadow/update/document". | |
#define | SHADOW_OP_DELETE_ACCEPTED SHADOW_OP_DELETE SHADOW_SUFFIX_ACCEPTED |
The string representing "/shadow/delete/accepted". | |
#define | SHADOW_OP_DELETE_REJECTED SHADOW_OP_DELETE SHADOW_SUFFIX_REJECTED |
The string representing "/shadow/delete/accepted". | |
#define | SHADOW_OP_GET_ACCEPTED SHADOW_OP_GET SHADOW_SUFFIX_ACCEPTED |
The string representing "/shadow/get/accepted". | |
#define | SHADOW_OP_GET_REJECTED SHADOW_OP_GET SHADOW_SUFFIX_REJECTED |
The string representing "/shadow/get/accepted". | |
#define | SHADOW_OP_UPDATE_ACCEPTED_LENGTH ( SHADOW_OP_UPDATE_LENGTH + SHADOW_SUFFIX_ACCEPTED_LENGTH ) |
The length of "/shadow/update/accepted". | |
#define | SHADOW_OP_UPDATE_REJECTED_LENGTH ( SHADOW_OP_UPDATE_LENGTH + SHADOW_SUFFIX_REJECTED_LENGTH ) |
The length of "/shadow/update/rejected". | |
#define | SHADOW_OP_UPDATE_DOCUMENTS_LENGTH ( SHADOW_OP_UPDATE_LENGTH + SHADOW_SUFFIX_DOCUMENTS_LENGTH ) |
The length of "/shadow/update/document". | |
#define | SHADOW_OP_UPDATE_DELTA_LENGTH ( SHADOW_OP_UPDATE_LENGTH + SHADOW_SUFFIX_DELTA_LENGTH ) |
The length of "/shadow/update/rejected". | |
#define | SHADOW_OP_GET_ACCEPTED_LENGTH ( SHADOW_OP_GET_LENGTH + SHADOW_SUFFIX_ACCEPTED_LENGTH ) |
The length of "/shadow/get/accepted". | |
#define | SHADOW_OP_GET_REJECTED_LENGTH ( SHADOW_OP_GET_LENGTH + SHADOW_SUFFIX_REJECTED_LENGTH ) |
The length of "/shadow/get/rejected". | |
#define | SHADOW_OP_DELETE_ACCEPTED_LENGTH ( SHADOW_OP_DELETE_LENGTH + SHADOW_SUFFIX_ACCEPTED_LENGTH ) |
The length of "/shadow/get/accepted". | |
#define | SHADOW_OP_DELETE_REJECTED_LENGTH ( SHADOW_OP_DELETE_LENGTH + SHADOW_SUFFIX_REJECTED_LENGTH ) |
The length of "/shadow/delete/rejected". | |
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