#include "aws_iot_shadow_records.h"
#include <string.h>
#include <stdio.h>
#include "AWS_SDK/aws_iot_src/protocol/mqtt/aws_iot_embedded_client_wrapper/timer_interface.h"
#include "AWS_SDK/aws_iot_src/utils/aws_iot_json_utils.h"
#include "AWS_SDK/aws_iot_src/utils/aws_iot_log.h"
#include "aws_iot_shadow_json.h"
#include "aws_iot_config.h"
Data Structures | |
struct | JsonTokenTable_t |
struct | SubscriptionRecord_t |
struct | ToBeReceivedAckRecord_t |
Macros | |
#define | MAX_TOPICS_AT_ANY_GIVEN_TIME 2*MAX_THINGNAME_HANDLED_AT_ANY_GIVEN_TIME |
#define | SUBSCRIBE_SETTLING_TIME 2 |
Enumerations | |
enum | ShadowAckTopicTypes_t { SHADOW_ACCEPTED, SHADOW_REJECTED, SHADOW_ACTION } |
Functions | |
static int | AckStatusCallback (MQTTCallbackParams params) |
void | addToAckWaitList (uint8_t indexAckWaitList, const char *pThingName, ShadowActions_t action, const char *pExtractedClientToken, fpActionCallback_t callback, void *pCallbackContext, uint32_t timeout_seconds) |
static int16_t | findIndexOfSubscriptionList (const char *pTopic) |
bool | getNextFreeIndexOfAckWaitList (uint8_t *pIndex) |
static int16_t | getNextFreeIndexOfSubscriptionList (void) |
void | HandleExpiredResponseCallbacks (void) |
void | incrementSubscriptionCnt (const char *pThingName, ShadowActions_t action, bool isSticky) |
void | initDeltaTokens (void) |
void | initializeRecords (MQTTClient_t *pClient) |
static bool | isAckForMyThingName (const char *pTopicName) |
bool | isSubscriptionPresent (const char *pThingName, ShadowActions_t action) |
IoT_Error_t | publishToShadowAction (const char *pThingName, ShadowActions_t action, const char *pJsonDocumentToBeSent) |
IoT_Error_t | registerJsonTokenOnDelta (jsonStruct_t *pStruct) |
static int | shadow_delta_callback (MQTTCallbackParams params) |
IoT_Error_t | subscribeToShadowActionAcks (const char *pThingName, ShadowActions_t action, bool isSticky) |
static void | topicNameFromThingAndAction (char *pTopic, const char *pThingName, ShadowActions_t action, ShadowAckTopicTypes_t ackType) |
static void | unsubscribeFromAcceptedAndRejected (uint8_t index) |
Variables | |
ToBeReceivedAckRecord_t | AckWaitList [MAX_ACKS_TO_COMEIN_AT_ANY_GIVEN_TIME] |
static bool | deltaTopicSubscribedFlag = false |
char | mqttClientID [MAX_SIZE_OF_UNIQUE_CLIENT_ID_BYTES] |
char | myThingName [MAX_SIZE_OF_THING_NAME] |
MQTTClient_t * | pMqttClient |
char | shadowDeltaTopic [MAX_SHADOW_TOPIC_LENGTH_BYTES] |
bool | shadowDiscardOldDeltaFlag = true |
uint32_t | shadowJsonVersionNum = 0 |
char | shadowRxBuf [SHADOW_MAX_SIZE_OF_RX_BUFFER] |
SubscriptionRecord_t | SubscriptionList [MAX_TOPICS_AT_ANY_GIVEN_TIME] |
static JsonTokenTable_t | tokenTable [MAX_JSON_TOKEN_EXPECTED] |
static uint32_t | tokenTableIndex = 0 |
#define MAX_TOPICS_AT_ANY_GIVEN_TIME 2*MAX_THINGNAME_HANDLED_AT_ANY_GIVEN_TIME |
#define SUBSCRIBE_SETTLING_TIME 2 |
Referenced by subscribeToShadowActionAcks().
|
static |
References ToBeReceivedAckRecord_t::callback, callback, extractClientToken(), extractVersionNumber(), GENERIC_ERROR, i, isAckForMyThingName(), ToBeReceivedAckRecord_t::isFree, isJsonValidAndParse(), MQTTCallbackParams::MessageParams, NONE_ERROR, NULL, MQTTMessageParams::PayloadLen, MQTTMessageParams::pPayload, MQTTCallbackParams::pTopicName, SHADOW_ACK_ACCEPTED, SHADOW_ACK_REJECTED, shadowJsonVersionNum, shadowRxBuf, status, unsubscribeFromAcceptedAndRejected(), and WARN.
Referenced by subscribeToShadowActionAcks().
void addToAckWaitList | ( | uint8_t | indexAckWaitList, |
const char * | pThingName, | ||
ShadowActions_t | action, | ||
const char * | pExtractedClientToken, | ||
fpActionCallback_t | callback, | ||
void * | pCallbackContext, | ||
uint32_t | timeout_seconds | ||
) |
|
static |
References i, and MAX_TOPICS_AT_ANY_GIVEN_TIME.
Referenced by unsubscribeFromAcceptedAndRejected().
bool getNextFreeIndexOfAckWaitList | ( | uint8_t * | pIndex | ) |
Referenced by iot_shadow_action().
|
static |
References i, SubscriptionRecord_t::isFree, and MAX_TOPICS_AT_ANY_GIVEN_TIME.
Referenced by subscribeToShadowActionAcks().
void HandleExpiredResponseCallbacks | ( | void | ) |
References ToBeReceivedAckRecord_t::callback, callback, expired(), i, ToBeReceivedAckRecord_t::isFree, NULL, SHADOW_ACK_TIMEOUT, shadowRxBuf, and unsubscribeFromAcceptedAndRejected().
Referenced by aws_iot_shadow_yield().
void incrementSubscriptionCnt | ( | const char * | pThingName, |
ShadowActions_t | action, | ||
bool | isSticky | ||
) |
References SubscriptionRecord_t::count, i, SubscriptionRecord_t::isSticky, MAX_TOPICS_AT_ANY_GIVEN_TIME, SHADOW_ACCEPTED, SHADOW_REJECTED, and topicNameFromThingAndAction().
Referenced by iot_shadow_action().
void initDeltaTokens | ( | void | ) |
References deltaTopicSubscribedFlag, i, JsonTokenTable_t::isFree, and tokenTableIndex.
Referenced by aws_iot_shadow_init().
void initializeRecords | ( | MQTTClient_t * | pClient | ) |
|
static |
References myThingName, and NULL.
Referenced by AckStatusCallback().
bool isSubscriptionPresent | ( | const char * | pThingName, |
ShadowActions_t | action | ||
) |
References i, MAX_TOPICS_AT_ANY_GIVEN_TIME, SHADOW_ACCEPTED, SHADOW_REJECTED, and topicNameFromThingAndAction().
Referenced by iot_shadow_action().
IoT_Error_t publishToShadowAction | ( | const char * | pThingName, |
ShadowActions_t | action, | ||
const char * | pJsonDocumentToBeSent | ||
) |
References MQTTPublishParams::MessageParams, MQTTMessageParamsDefault, MQTTPublishParamsDefault, NONE_ERROR, MQTTMessageParams::PayloadLen, MQTTMessageParams::pPayload, MQTTPublishParams::pTopic, MQTTClient_t::publish, MQTTMessageParams::qos, QOS_0, SHADOW_ACTION, and topicNameFromThingAndAction().
Referenced by iot_shadow_action().
IoT_Error_t registerJsonTokenOnDelta | ( | jsonStruct_t * | pStruct | ) |
References JsonTokenTable_t::callback, jsonStruct::cb, DEBUG, deltaTopicSubscribedFlag, GENERIC_ERROR, JsonTokenTable_t::isFree, MQTTSubscribeParams::mHandler, myThingName, NONE_ERROR, JsonTokenTable_t::pKey, jsonStruct::pKey, JsonTokenTable_t::pStruct, MQTTSubscribeParams::pTopic, MQTTSubscribeParams::qos, QOS_0, shadow_delta_callback(), shadowDeltaTopic, MQTTClient_t::subscribe, and tokenTableIndex.
Referenced by aws_iot_shadow_register_delta().
|
static |
References JsonTokenTable_t::callback, callback, DEBUG, extractVersionNumber(), GENERIC_ERROR, i, isJsonKeyMatchingAndUpdateValue(), isJsonValidAndParse(), MQTTCallbackParams::MessageParams, NONE_ERROR, NULL, MQTTMessageParams::PayloadLen, MQTTMessageParams::pPayload, shadowDiscardOldDeltaFlag, shadowJsonVersionNum, shadowRxBuf, tokenTableIndex, and WARN.
Referenced by registerJsonTokenOnDelta().
IoT_Error_t subscribeToShadowActionAcks | ( | const char * | pThingName, |
ShadowActions_t | action, | ||
bool | isSticky | ||
) |
References AckStatusCallback(), count, SubscriptionRecord_t::count, countdown(), expired(), getNextFreeIndexOfSubscriptionList(), InitTimer(), SubscriptionRecord_t::isFree, SubscriptionRecord_t::isSticky, MQTTSubscribeParams::mHandler, MQTTSubscribeParamsDefault, NONE_ERROR, MQTTSubscribeParams::pTopic, MQTTSubscribeParams::qos, QOS_0, SHADOW_ACCEPTED, SHADOW_REJECTED, MQTTClient_t::subscribe, SUBSCRIBE_SETTLING_TIME, SubscriptionRecord_t::Topic, topicNameFromThingAndAction(), and MQTTClient_t::unsubscribe.
Referenced by iot_shadow_action().
|
static |
References SHADOW_ACCEPTED, SHADOW_ACTION, SHADOW_DELETE, SHADOW_GET, SHADOW_REJECTED, and SHADOW_UPDATE.
Referenced by incrementSubscriptionCnt(), isSubscriptionPresent(), publishToShadowAction(), subscribeToShadowActionAcks(), and unsubscribeFromAcceptedAndRejected().
|
static |
ToBeReceivedAckRecord_t AckWaitList[MAX_ACKS_TO_COMEIN_AT_ANY_GIVEN_TIME] |
Referenced by initDeltaTokens(), and registerJsonTokenOnDelta().
char mqttClientID[MAX_SIZE_OF_UNIQUE_CLIENT_ID_BYTES] |
Referenced by aws_iot_shadow_connect(), FillWithClientToken(), and FillWithClientTokenSize().
char myThingName[MAX_SIZE_OF_THING_NAME] |
Referenced by aws_iot_shadow_connect(), isAckForMyThingName(), and registerJsonTokenOnDelta().
MQTTClient_t* pMqttClient |
char shadowDeltaTopic[MAX_SHADOW_TOPIC_LENGTH_BYTES] |
Referenced by registerJsonTokenOnDelta().
uint32_t shadowJsonVersionNum = 0 |
char shadowRxBuf[SHADOW_MAX_SIZE_OF_RX_BUFFER] |
Referenced by AckStatusCallback(), HandleExpiredResponseCallbacks(), and shadow_delta_callback().
SubscriptionRecord_t SubscriptionList[MAX_TOPICS_AT_ANY_GIVEN_TIME] |
|
static |
|
static |
Referenced by initDeltaTokens(), registerJsonTokenOnDelta(), and shadow_delta_callback().