FreeRTOS
|
Shadow API configuration, functions, and parameter structs. More...
Go to the source code of this file.
Data Structures | |
struct | ShadowCreateParams |
Parameters to pass into SHADOW_ClientCreate. More... | |
struct | ShadowOperationParams |
Parameters for a Shadow API operation. More... | |
struct | ShadowCallbackParams |
Parameters to SHADOW_RegisterCallbacks. More... | |
Macros | |
#define | eShadowJSMNPart ( -3 ) |
Return values of Shadow API functions. More... | |
#define | eShadowJSMNInval ( -2 ) |
#define | eShadowJSMNNoMem ( -1 ) |
#define | eShadowSuccess ( 0 ) |
#define | eShadowTimeout ( 1 ) |
#define | eShadowFailure ( 2 ) |
#define | eShadowUnknown ( 3 ) |
Typedefs | |
typedef void * | ShadowClientHandle_t |
The handle of a Shadow Client. | |
typedef enum ShadowMQTTClientType | ShadowMQTTClientType_t |
Type of MQTT client in a new Shadow Client. More... | |
typedef struct ShadowCreateParams | ShadowCreateParams_t |
Parameters to pass into SHADOW_ClientCreate. | |
typedef struct ShadowOperationParams | ShadowOperationParams_t |
Parameters for a Shadow API operation. More... | |
typedef BaseType_t(* | ShadowUpdatedCallback_t) (void *pvUserData, const char *const pcThingName, const char *const pcUpdateDocument, uint32_t ulDocumentLength, MQTTBufferHandle_t xBuffer) |
Function signature of a callback function registered for /update/documents. More... | |
typedef void(* | ShadowDeletedCallback_t) (void *pvUserData, const char *const pcThingName) |
Function header of a callback function registered for /delete/accepted. More... | |
typedef BaseType_t(* | ShadowDeltaCallback_t) (void *pvUserData, const char *const pcThingName, const char *const pcDeltaDocument, uint32_t ulDocumentLength, MQTTBufferHandle_t xBuffer) |
Function header of a callback function registered for /update/delta. More... | |
typedef struct ShadowCallbackParams | ShadowCallbackParams_t |
Parameters to SHADOW_RegisterCallbacks. | |
Enumerations | |
enum | ShadowMQTTClientType { eSharedMQTTClient, eDedicatedMQTTClient } |
Type of MQTT client in a new Shadow Client. More... | |
Functions | |
ShadowReturnCode_t | SHADOW_ClientCreate (ShadowClientHandle_t *pxShadowClientHandle, const ShadowCreateParams_t *const pxShadowCreateParams) |
Create a new Shadow Client. More... | |
ShadowReturnCode_t | SHADOW_ClientConnect (ShadowClientHandle_t xShadowClientHandle, MQTTAgentConnectParams_t *const pxConnectParams, TickType_t xTimeoutTicks) |
Connect to the Shadow service. More... | |
ShadowReturnCode_t | SHADOW_ClientDisconnect (ShadowClientHandle_t xShadowClientHandle) |
Disconnect from the Shadow service. More... | |
ShadowReturnCode_t | SHADOW_ClientDelete (ShadowClientHandle_t xShadowClientHandle) |
Free resources used by a Shadow Client. More... | |
ShadowReturnCode_t | SHADOW_Update (ShadowClientHandle_t xShadowClientHandle, ShadowOperationParams_t *const pxUpdateParams, TickType_t xTimeoutTicks) |
Update a Thing Shadow. More... | |
ShadowReturnCode_t | SHADOW_Get (ShadowClientHandle_t xShadowClientHandle, ShadowOperationParams_t *const pxGetParams, TickType_t xTimeoutTicks) |
Get a Thing Shadow from the cloud. More... | |
ShadowReturnCode_t | SHADOW_Delete (ShadowClientHandle_t xShadowClientHandle, ShadowOperationParams_t *const pxDeleteParams, TickType_t xTimeoutTicks) |
Delete a Thing Shadow in the cloud. More... | |
ShadowReturnCode_t | SHADOW_RegisterCallbacks (ShadowClientHandle_t xShadowClientHandle, ShadowCallbackParams_t *const pxCallbackParams, TickType_t xTimeoutTicks) |
Register callback functions. More... | |
ShadowReturnCode_t | SHADOW_ReturnMQTTBuffer (ShadowClientHandle_t xShadowClientHandle, MQTTBufferHandle_t xBufferHandle) |
Return an MQTT Buffer to the MQTT client. More... | |
#define | eShadowRejectedBadRequest ( 400 ) |
Shadow service rejection reasons. | |
#define | eShadowRejectedUnauthorized ( 401 ) |
#define | eShadowRejectedForbidden ( 403 ) |
#define | eShadowRejectedNotFound ( 404 ) |
#define | eShadowRejectedConflict ( 409 ) |
#define | eShadowRejectedPayloadTooLarge ( 413 ) |
#define | eShadowRejectedUnsupportedMediaType ( 415 ) |
#define | eShadowRejectedTooManyRequests ( 429 ) |
#define | eShadowRejectedInternalServerError ( 500 ) |
typedef int16_t | ShadowReturnCode_t |
Shadow API configuration, functions, and parameter structs.
Definition in file aws_shadow.h.
#define eShadowFailure ( 2 ) |
Failure code; signifies that at least one subroutine failed to complete and did not time out.
Definition at line 79 of file aws_shadow.h.
#define eShadowJSMNPart ( -3 ) |
Return values of Shadow API functions.
Negative values indicate jsmn (JSON parser) errors, and 0
indicates success. Positive values indicate other errors. Values in the range of 400
to 500
correspond to Shadow service rejection reasons.
Refer to jsmn.h for jsmn errors.
Refer to http://docs.aws.amazon.com/iot/latest/developerguide/thing-shadow-error-messages.html for Shadow service rejection reasons.
Definition at line 57 of file aws_shadow.h.
#define eShadowSuccess ( 0 ) |
An operation was accepted by the Shadow service, and all subroutines completed successfully.
Definition at line 63 of file aws_shadow.h.
#define eShadowTimeout ( 1 ) |
Timeout signifies that at least one of the API call's subroutines failed to complete within the given time. This error can usually be fixed by increasing the timeout parameter.
eShadowRejectedBadRequest
and print an error message if #shadowENABLE_DEBUG_LOGS is 1
. Definition at line 75 of file aws_shadow.h.
#define eShadowUnknown ( 3 ) |
Indicates neither failure nor success. This value should never be returned by a Shadow API function, but is used internally.
Definition at line 83 of file aws_shadow.h.
typedef void( * ShadowDeletedCallback_t) (void *pvUserData, const char *const pcThingName) |
Function header of a callback function registered for /delete/accepted.
in | Custom user data. |
pcThingName | The Name of the Thing whose Shadow was deleted. |
Definition at line 237 of file aws_shadow.h.
typedef BaseType_t( * ShadowDeltaCallback_t) (void *pvUserData, const char *const pcThingName, const char *const pcDeltaDocument, uint32_t ulDocumentLength, MQTTBufferHandle_t xBuffer) |
Function header of a callback function registered for /update/delta.
in | Custom user data. |
pcThingName | The Thing Name of the delta document. |
pcDeltaDocument | The delta document, a JSON string. |
ulDocumentLength | The length of the delta document. |
xBuffer | The MQTT buffer containing pcDeltaDocument . This buffer must eventually be returned by calling SHADOW_ReturnMQTTBuffer if taken. |
Definition at line 264 of file aws_shadow.h.
typedef enum ShadowMQTTClientType ShadowMQTTClientType_t |
Type of MQTT client in a new Shadow Client.
The possible values of ShadowCreateParams_t.xMQTTClientType; determines whether to initialize a shared or dedicated MQTT client.
typedef struct ShadowOperationParams ShadowOperationParams_t |
Parameters for a Shadow API operation.
Pass this struct as one of the arguments for SHADOW_Update, SHADOW_Get, or SHADOW_Delete.
typedef BaseType_t( * ShadowUpdatedCallback_t) (void *pvUserData, const char *const pcThingName, const char *const pcUpdateDocument, uint32_t ulDocumentLength, MQTTBufferHandle_t xBuffer) |
Function signature of a callback function registered for /update/documents.
in | Custom user data. |
pcThingName | The Thing Name of the updated Shadow. |
pcUpdateDocument | The update document, a JSON string. |
ulDocumentLength | The length of the update document. |
xBuffer | The MQTT buffer containing pcUpdateDocument . This buffer must eventually be returned by calling SHADOW_ReturnMQTTBuffer if taken. |
Definition at line 221 of file aws_shadow.h.
enum ShadowMQTTClientType |
Type of MQTT client in a new Shadow Client.
The possible values of ShadowCreateParams_t.xMQTTClientType; determines whether to initialize a shared or dedicated MQTT client.
Definition at line 107 of file aws_shadow.h.
ShadowReturnCode_t SHADOW_ClientConnect | ( | ShadowClientHandle_t | xShadowClientHandle, |
MQTTAgentConnectParams_t *const | pxConnectParams, | ||
TickType_t | xTimeoutTicks | ||
) |
Connect to the Shadow service.
For a Shadow Client with a dedicated MQTT Client (eDedicatedMQTTClient), calling this function is the only way to connect to the Shadow service. For a Shadow Client with a shared MQTT Client (eSharedMQTTClient), calling this function is equivalent to calling MQTT_AGENT_Connect
with the corresponding shared MQTT Client handle.
[in] | xShadowClientHandle | Handle of Shadow Client to connect. |
[in] | pxConnectParams | Pointer to a TradstoneMQTTConnectParams_t struct. Note: ClientHandle should be at the top of user data passed in pxConnectParams |
[in] | xTimeoutTicks | Number of ticks this function may block before timeout. |
ShadowReturnCode_t SHADOW_ClientCreate | ( | ShadowClientHandle_t * | pxShadowClientHandle, |
const ShadowCreateParams_t *const | pxShadowCreateParams | ||
) |
Create a new Shadow Client.
[out] | pxShadowClientHandle | Output parameter for the handle of the newly-created Shadow Client. Only valid if the return code is eShadowSuccess. |
[in] | pxShadowCreateParams | Pointer to a ShadowCreateParams struct. |
[in] | xTimeoutTicks | Number of ticks this function may block before timeout. |
ShadowReturnCode_t SHADOW_ClientDelete | ( | ShadowClientHandle_t | xShadowClientHandle | ) |
Free resources used by a Shadow Client.
[in] | xShadowClientHandle | Handle of Shadow Client to be deleted. |
ShadowReturnCode_t SHADOW_ClientDisconnect | ( | ShadowClientHandle_t | xShadowClientHandle | ) |
Disconnect from the Shadow service.
For a Shadow Client with a dedicated MQTT Client (eDedicatedMQTTClient), calling this function is the only way to disconnect from the Shadow service. For a Shadow Client with a shared MQTT Client (eSharedMQTTClient), calling this function is equivalent to calling MQTT_AGENT_Disconnect
with the corresponding shared MQTT Client handle.
[in] | xShadowClientHandle | Handle of Shadow Client to disconnect. |
ShadowReturnCode_t SHADOW_Delete | ( | ShadowClientHandle_t | xShadowClientHandle, |
ShadowOperationParams_t *const | pxDeleteParams, | ||
TickType_t | xTimeoutTicks | ||
) |
Delete a Thing Shadow in the cloud.
[in] | xShadowClientHandle | Handle of Shadow Client to use for delete. |
[in] | pxDeleteParams | A pointer to a ShadowOperationParams struct. |
[in] | xTimeoutTicks | Number of ticks this function may block before timeout. |
ShadowReturnCode_t SHADOW_Get | ( | ShadowClientHandle_t | xShadowClientHandle, |
ShadowOperationParams_t *const | pxGetParams, | ||
TickType_t | xTimeoutTicks | ||
) |
Get a Thing Shadow from the cloud.
[in] | xShadowClientHandle | Handle of Shadow Client to use for get. |
pxGetParams | A pointer to a ShadowOperationParams struct. This is used as both an input and output parameter. | |
[in] | xTimeoutTicks | Number of ticks this function may block before timeout. |
xBufferHandle
. ShadowReturnCode_t SHADOW_RegisterCallbacks | ( | ShadowClientHandle_t | xShadowClientHandle, |
ShadowCallbackParams_t *const | pxCallbackParams, | ||
TickType_t | xTimeoutTicks | ||
) |
Register callback functions.
[in] | xShadowClientHandle | Handle of Shadow Client to use for registering callbacks. |
[in] | pxCallbackParams | A pointer to a ShadowCallbackParams struct. |
[in] | xTimeoutTicks | Number of ticks this function may block before timeout. |
1
and attempt to register the next callback. ShadowReturnCode_t SHADOW_ReturnMQTTBuffer | ( | ShadowClientHandle_t | xShadowClientHandle, |
MQTTBufferHandle_t | xBufferHandle | ||
) |
Return an MQTT Buffer to the MQTT client.
For a Shadow Client with a dedicated MQTT Client (eDedicatedMQTTClient), calling this function is the only way to return an MQTT Buffer. For a Shadow Client with a shared MQTT Client (eSharedMQTTClient), calling this function is equivalent to calling MQTT_AGENT_ReturnBuffer
with the corresponding shared MQTT Client handle.
[in] | xShadowClientHandle | Handle of Shadow Client for MQTT Buffer return. |
[in] | xBufferHandle | Handle of MQTT Buffer to return. |
ShadowReturnCode_t SHADOW_Update | ( | ShadowClientHandle_t | xShadowClientHandle, |
ShadowOperationParams_t *const | pxUpdateParams, | ||
TickType_t | xTimeoutTicks | ||
) |
Update a Thing Shadow.
[in] | xShadowClientHandle | Handle of Shadow Client to use for update. |
[in] | pxUpdateParams | A pointer to a ShadowOperationParams struct. |
[in] | xTimeoutTicks | Number of ticks this function may block before timeout. |