Implementation of the AWS IoT Device Defender Client Library. More...
Functions | |
static uint16_t | getTopicLength (uint16_t thingNameLength, DefenderTopic_t api) |
Get the topic length for a given defender API. More... | |
static void | writeFormatAndSuffix (char *pBuffer, DefenderTopic_t api) |
Write the format and suffix part for the given defender API to the buffer. More... | |
static DefenderStatus_t | matchPrefix (const char *pRemainingTopic, uint16_t remainingTopicLength) |
Check if the unparsed topic so far starts with the defender prefix. More... | |
static DefenderStatus_t | extractThingNameLength (const char *pRemainingTopic, uint16_t remainingTopicLength, uint16_t *pOutThingNameLength) |
Extract the length of thing name in the unparsed topic so far. More... | |
static DefenderStatus_t | matchBridge (const char *pRemainingTopic, uint16_t remainingTopicLength) |
Check if the unparsed topic so far starts with the defender bridge. More... | |
static DefenderStatus_t | matchApi (const char *pRemainingTopic, uint16_t remainingTopicLength, DefenderTopic_t *pOutApi) |
Check if the unparsed topic so far exactly matches one of the defender api topics. More... | |
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. More... | |
DefenderStatus_t | Defender_MatchTopic (const char *pTopic, uint16_t topicLength, DefenderTopic_t *pOutApi, const char **ppOutThingName, uint16_t *pOutThingNameLength) |
Check if the given topic is one of the Device Defender topics. More... | |
Implementation of the AWS IoT Device Defender Client Library.
|
static |
Get the topic length for a given defender API.
[in] | thingNameLength | The length of the thing name as registered with AWS IoT. |
[in] | api | The defender API value. |
|
static |
Write the format and suffix part for the given defender API to the buffer.
Format: json or cbor. Suffix: /accepted or /rejected or empty.
[in] | pBuffer | The buffer to write the format and suffix part into. |
[in] | api | The defender API value. |
|
static |
Check if the unparsed topic so far starts with the defender prefix.
The defender prefix is "$aws/things/".
[in] | pRemainingTopic | Starting location of the unparsed topic. |
[in] | remainingTopicLength | The length of the unparsed topic. |
|
static |
Extract the length of thing name in the unparsed topic so far.
The end of thing name is marked by a forward slash. A zero length thing name is not valid.
This function extracts the same thing name from the following topic strings:
[in] | pRemainingTopic | Starting location of the unparsed topic. |
[in] | remainingTopicLength | The length of the unparsed topic. |
[out] | pOutThingNameLength | The length of the thing name in the topic string. |
|
static |
Check if the unparsed topic so far starts with the defender bridge.
The defender bridge is "/defender/metrics/".
[in] | pRemainingTopic | Starting location of the unparsed topic. |
[in] | remainingTopicLength | The length of the unparsed topic. |
|
static |
Check if the unparsed topic so far exactly matches one of the defender api topics.
The defender api topics are the following:
The function also outputs the defender API value if a match is found.
[in] | pRemainingTopic | Starting location of the unparsed topic. |
[in] | remainingTopicLength | The length of the unparsed topic. |
[out] | pOutApi | The defender topic API value. |
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.
[in] | pBuffer | The buffer to write the topic string into. |
[in] | bufferLength | The length of the buffer. |
[in] | pThingName | The device's thingName as registered with AWS IoT. |
[in] | thingNameLength | The length of the thing name. |
[in] | api | The desired Device Defender API. |
[out] | pOutLength | The length of the topic string written to the buffer. |
Example
DefenderStatus_t Defender_MatchTopic | ( | const char * | pTopic, |
uint16_t | topicLength, | ||
DefenderTopic_t * | pOutApi, | ||
const char ** | ppOutThingName, | ||
uint16_t * | pOutThingNameLength | ||
) |
Check if the given topic is one of the Device Defender topics.
The function outputs which API the topic is for. It also optionally outputs the starting location and length of the thing name in the given topic.
[in] | pTopic | The topic string to check. |
[in] | topicLength | The length of the topic string. |
[out] | pOutApi | The defender topic API value. |
[out] | ppOutThingName | Optional parameter to output the beginning of the thing name in the topic string. Pass NULL if not needed. |
[out] | pOutThingNameLength | Optional parameter to output the length of the thing name in the topic string. Pass NULL if not needed. |
Example