29 #ifndef AWS_IOT_JOBS_INTERNAL_H_ 30 #define AWS_IOT_JOBS_INTERNAL_H_ 33 #include "iot_config.h" 53 #if AWS_IOT_JOBS_ENABLE_ASSERTS == 1 54 #ifndef AwsIotJobs_Assert 55 #ifdef Iot_DefaultAssert 56 #define AwsIotJobs_Assert( expression ) Iot_DefaultAssert( expression ) 58 #error "Asserts are enabled for Jobs, but AwsIotJobs_Assert is not defined" 62 #define AwsIotJobs_Assert( expression ) 66 #ifdef AWS_IOT_LOG_LEVEL_JOBS 67 #define LIBRARY_LOG_LEVEL AWS_IOT_LOG_LEVEL_JOBS 69 #ifdef IOT_LOG_LEVEL_GLOBAL 70 #define LIBRARY_LOG_LEVEL IOT_LOG_LEVEL_GLOBAL 72 #define LIBRARY_LOG_LEVEL IOT_LOG_NONE 76 #define LIBRARY_LOG_NAME ( "Jobs" ) 83 #if IOT_STATIC_MEMORY_ONLY == 1 105 #define AwsIotJobs_MallocString Iot_MallocMessageBuffer 112 #define AwsIotJobs_FreeString Iot_FreeMessageBuffer 128 #ifndef AwsIotJobs_MallocOperation 129 #ifdef Iot_DefaultMalloc 130 #define AwsIotJobs_MallocOperation Iot_DefaultMalloc 132 #error "No malloc function defined for AwsIotJobs_MallocOperation" 136 #ifndef AwsIotJobs_FreeOperation 137 #ifdef Iot_DefaultFree 138 #define AwsIotJobs_FreeOperation Iot_DefaultFree 140 #error "No free function defined for AwsIotJobs_FreeOperation" 144 #ifndef AwsIotJobs_MallocString 145 #ifdef Iot_DefaultMalloc 146 #define AwsIotJobs_MallocString Iot_DefaultMalloc 148 #error "No malloc function defined for AwsIotJobs_MallocString" 152 #ifndef AwsIotJobs_FreeString 153 #ifdef Iot_DefaultFree 154 #define AwsIotJobs_FreeString Iot_DefaultFree 156 #error "No free function defined for AwsIotJobs_FreeString" 160 #ifndef AwsIotJobs_MallocSubscription 161 #ifdef Iot_DefaultMalloc 162 #define AwsIotJobs_MallocSubscription Iot_DefaultMalloc 164 #error "No malloc function defined for AwsIotJobs_MallocSubscription" 168 #ifndef AwsIotJobs_FreeSubscription 169 #ifdef Iot_DefaultFree 170 #define AwsIotJobs_FreeSubscription Iot_DefaultFree 172 #error "No free function defined for AwsIotJobs_FreeSubscription" 183 #ifndef AWS_IOT_JOBS_DEFAULT_MQTT_TIMEOUT_MS 184 #define AWS_IOT_JOBS_DEFAULT_MQTT_TIMEOUT_MS ( 5000 ) 186 #ifndef AWS_IOT_JOBS_NOTIFY_CALLBACKS 187 #define AWS_IOT_JOBS_NOTIFY_CALLBACKS ( 1 ) 196 #define JOBS_OPERATION_COUNT ( 4 ) 204 #define JOBS_CALLBACK_COUNT ( 2 ) 209 #define JOBS_GET_PENDING_OPERATION_STRING "/jobs/get" 214 #define JOBS_GET_PENDING_OPERATION_STRING_LENGTH ( ( uint16_t ) ( sizeof( JOBS_GET_PENDING_OPERATION_STRING ) - 1 ) ) 219 #define JOBS_START_NEXT_OPERATION_STRING "/jobs/start-next" 224 #define JOBS_START_NEXT_OPERATION_STRING_LENGTH ( ( uint16_t ) ( sizeof( JOBS_START_NEXT_OPERATION_STRING ) - 1 ) ) 231 #define JOBS_DESCRIBE_OPERATION_STRING "/get" 236 #define JOBS_DESCRIBE_OPERATION_STRING_LENGTH ( ( uint16_t ) ( sizeof( JOBS_DESCRIBE_OPERATION_STRING ) - 1 ) ) 243 #define JOBS_UPDATE_OPERATION_STRING "/update" 250 #define JOBS_UPDATE_OPERATION_STRING_LENGTH ( ( uint16_t ) ( sizeof( JOBS_UPDATE_OPERATION_STRING ) - 1 ) ) 256 #define JOBS_NOTIFY_PENDING_CALLBACK_STRING "/jobs/notify" 261 #define JOBS_NOTIFY_PENDING_CALLBACK_STRING_LENGTH ( ( uint16_t ) ( sizeof( JOBS_NOTIFY_PENDING_CALLBACK_STRING ) - 1 ) ) 267 #define JOBS_NOTIFY_NEXT_CALLBACK_STRING "/jobs/notify-next" 272 #define JOBS_NOTIFY_NEXT_CALLBACK_STRING_LENGTH ( ( uint16_t ) ( sizeof( JOBS_NOTIFY_NEXT_CALLBACK_STRING ) - 1 ) ) 279 #define JOBS_MAX_ID_LENGTH ( 64 ) 286 #define JOBS_MAX_TIMEOUT ( 10080 ) 297 #define JOBS_MAX_STATUS_DETAILS_LENGTH ( 32768 ) 305 #define JOBS_LONGEST_SUFFIX_LENGTH ( JOBS_MAX_ID_LENGTH + JOBS_UPDATE_OPERATION_STRING_LENGTH + 6 ) 312 typedef enum _jobsOperationType
328 typedef enum _jobsCallbackType
337 typedef union _jsonRequestContents
353 typedef struct _jobsSubscription
380 typedef struct _jobsOperation
408 void * ( *mallocResponse )( size_t );
422 #if LIBRARY_LOG_LEVEL > IOT_LOG_NONE 423 extern const char *
const _pAwsIotJobsOperationNames[];
424 extern const char *
const _pAwsIotJobsCallbackNames[];
486 char ** pTopicBuffer,
487 uint16_t * pOperationTopicLength );
519 size_t thingNameLength,
520 bool createIfNotFound );
569 uint16_t operationTopicLength,
570 AwsIotMqttCallbackFunction_t callback );
624 const char * pResponse,
625 size_t responseLength,
Internal structure representing a single Jobs operation.
Definition: aws_iot_jobs_internal.h:380
uint32_t flags
Flags passed to operation API function.
Definition: aws_iot_jobs_internal.h:386
_jobsSubscription_t * pSubscription
Jobs subscriptions object associated with this operation.
Definition: aws_iot_jobs_internal.h:390
AwsIotJobsError_t _AwsIotJobs_CreateOperation(_jobsOperationType_t type, const AwsIotJobsRequestInfo_t *pRequestInfo, const _jsonRequestContents_t *pRequestContents, uint32_t flags, const AwsIotJobsCallbackInfo_t *pCallbackInfo, _jobsOperation_t **pNewOperation)
Create a record for a new in-progress Jobs operation.
Definition: aws_iot_jobs_operation.c:524
int32_t callbackReferences
Reference counter for Jobs callbacks.
Definition: aws_iot_jobs_internal.h:358
Definition: aws_iot_jobs_internal.h:317
size_t jobIdLength
Length of _jobsOperation_t.pJobId.
Definition: aws_iot_jobs_internal.h:417
IotLink_t link
List link member.
Definition: aws_iot_jobs_internal.h:382
_jobsOperationType_t type
Operation type.
Definition: aws_iot_jobs_internal.h:385
IotListDouble_t _AwsIotJobsPendingOperations
List of active Jobs operations awaiting a response from the Jobs service.
Definition: aws_iot_jobs_operation.c:176
void _AwsIotJobs_DestroySubscription(void *pData)
Free resources used for a Jobs subscription object.
Definition: aws_iot_jobs_subscription.c:258
size_t jobsRequestLength
Length of _jobsOperation_t.pJobsRequest.
Definition: aws_iot_jobs_internal.h:394
Represents a Jobs subscriptions object.
Definition: aws_iot_jobs_internal.h:353
Definition: aws_iot_jobs_internal.h:331
AwsIotJobsError_t _AwsIotJobs_IncrementReferences(_jobsOperation_t *pOperation, char *pTopicBuffer, uint16_t operationTopicLength, AwsIotMqttCallbackFunction_t callback)
Increment the reference count of a Jobs subscriptions object.
Definition: aws_iot_jobs_subscription.c:274
AwsIotJobsError_t
Return codes of Jobs functions.
Definition: aws_iot_jobs_types.h:87
_jobsCallbackType_t
Enumerations representing each of the Jobs callback functions.
Definition: aws_iot_jobs_internal.h:328
void AwsIotJobs_FreeOperation(void *ptr)
Free a _jobsOperation_t. This function should have the same signature as free.
Definition: aws_iot_jobs_static_memory.c:123
AwsIotJobsError_t _AwsIotJobs_ProcessOperation(const AwsIotJobsRequestInfo_t *pRequestInfo, _jobsOperation_t *pOperation)
Process a Jobs operation by sending the necessary MQTT packets.
Definition: aws_iot_jobs_operation.c:747
Common information provided to Jobs requests.
Definition: aws_iot_jobs_types.h:569
AwsIotJobsCallbackInfo_t callback
User-provided callback function and parameter.
Definition: aws_iot_jobs_internal.h:414
struct _mqttConnection * IotMqttConnection_t
IotListDouble_t _AwsIotJobsSubscriptions
List of active Jobs subscriptions objects.
Definition: aws_iot_jobs_subscription.c:66
IotMutex_t _AwsIotJobsSubscriptionsMutex
Protects _AwsIotJobsSubscriptions from concurrent access.
Definition: aws_iot_jobs_subscription.c:71
_jobsOperationType_t
Enumerations representing each of the Jobs library's API functions.
Definition: aws_iot_jobs_internal.h:312
int32_t executionNumber
Execution number.
Definition: aws_iot_jobs_internal.h:343
Definition: aws_iot_jobs_internal.h:330
size_t thingNameLength
Length of Thing Name.
Definition: aws_iot_jobs_internal.h:371
IotLink_t link
List link member.
Definition: aws_iot_jobs_internal.h:355
Definition: aws_iot_jobs_internal.h:318
void _AwsIotJobs_RemoveSubscription(_jobsSubscription_t *pSubscription, _jobsSubscription_t **pRemovedSubscription)
Remove a Jobs subscription object from the subscription list if unreferenced.
Definition: aws_iot_jobs_subscription.c:166
char * pTopicBuffer
Buffer allocated for removing Jobs topics.
Definition: aws_iot_jobs_internal.h:369
size_t jobsResponseLength
Length of _jobsOperation_t.pJobsResponse.
Definition: aws_iot_jobs_internal.h:401
Parameter to _AwsIotJobs_GenerateJsonRequest.
Definition: aws_iot_jobs_internal.h:337
void AwsIotJobs_FreeSubscription(void *ptr)
Free a _jobsSubscription_t. This function should have the same signature as free. ...
Definition: aws_iot_jobs_static_memory.c:157
Information on a user-provided Jobs callback function.
Definition: aws_iot_jobs_types.h:501
Definition: aws_iot_jobs_internal.h:322
Definition: aws_iot_jobs_internal.h:315
Information on a Job update for AwsIotJobs_StartNextAsync and AwsIotJobs_UpdateAsync. These functions modify a Job's state.
Definition: aws_iot_jobs_types.h:666
size_t clientTokenLength
Length of _jobsOperation_t.pClientToken.
Definition: aws_iot_jobs_internal.h:397
AwsIotJobsError_t _AwsIotJobs_GenerateJsonRequest(_jobsOperationType_t type, const AwsIotJobsRequestInfo_t *pRequestInfo, const _jsonRequestContents_t *pRequestContents, _jobsOperation_t *pOperation)
Generates a Jobs JSON request document from an AwsIotJobsRequestInfo_t and an AwsIotJobsUpdateInfo_t...
Definition: aws_iot_jobs_serialize.c:1112
void * AwsIotJobs_MallocSubscription(size_t size)
Allocate a _jobsSubscription_t. This function should have the same signature as malloc.
Definition: aws_iot_jobs_static_memory.c:135
void * AwsIotJobs_MallocOperation(size_t size)
Allocate a _jobsOperation_t. This function should have the same signature as malloc.
Definition: aws_iot_jobs_static_memory.c:100
uint32_t _AwsIotJobsMqttTimeoutMs
Timeout used for MQTT operations.
Definition: aws_iot_jobs_api.c:198
User-facing functions of the Jobs library.
const char * pClientToken
Client token sent with request.
Definition: aws_iot_jobs_internal.h:396
_jobsSubscription_t * _AwsIotJobs_FindSubscription(const char *pThingName, size_t thingNameLength, bool createIfNotFound)
Find a Jobs subscription object. May create a new subscription object and adds it to the subscription...
Definition: aws_iot_jobs_subscription.c:102
Definition: aws_iot_jobs_internal.h:321
const char * pJobsResponse
Response received from the Jobs service.
Definition: aws_iot_jobs_internal.h:400
bool includeJobDocument
Whether the response should include the Job document.
Definition: aws_iot_jobs_internal.h:344
IotSemaphore_t waitSemaphore
Semaphore to be used with AwsIotJobs_Wait.
Definition: aws_iot_jobs_internal.h:413
Definition: aws_iot_jobs_internal.h:316
#define JOBS_OPERATION_COUNT
The number of currently available Jobs operations.
Definition: aws_iot_jobs_internal.h:196
const char * pJobsRequest
JSON document to send to the Jobs service.
Definition: aws_iot_jobs_internal.h:393
AwsIotJobsError_t status
Status of operation.
Definition: aws_iot_jobs_internal.h:387
IotMutex_t _AwsIotJobsPendingOperationsMutex
Protects _AwsIotJobsPendingOperations from concurrent access.
Definition: aws_iot_jobs_operation.c:181
AwsIotJobsError_t _AwsIotJobs_GenerateJobsTopic(_jobsOperationType_t type, const AwsIotJobsRequestInfo_t *pRequestInfo, char **pTopicBuffer, uint16_t *pOperationTopicLength)
Fill a buffer with a Jobs topic.
Definition: aws_iot_jobs_operation.c:666
void _AwsIotJobs_DecrementReferences(_jobsOperation_t *pOperation, char *pTopicBuffer, _jobsSubscription_t **pRemovedSubscription)
Decrement the reference count of a Jobs subscriptions object.
Definition: aws_iot_jobs_subscription.c:364
void _AwsIotJobs_ParseResponse(AwsIotStatus_t status, const char *pResponse, size_t responseLength, _jobsOperation_t *pOperation)
Parse a response received from the Jobs service.
Definition: aws_iot_jobs_serialize.c:1154
const AwsIotJobsUpdateInfo_t * pUpdateInfo
Valid for JOBS_START_NEXT and JOBS_UPDATE.
Definition: aws_iot_jobs_internal.h:339
void _AwsIotJobs_DestroyOperation(void *pData)
Free resources used to record a Jobs operation. This is called when the operation completes...
Definition: aws_iot_jobs_operation.c:636
IotMqttConnection_t mqttConnection
MQTT connection associated with this operation.
Definition: aws_iot_jobs_internal.h:389
#define JOBS_CALLBACK_COUNT
The number of currently available Jobs callbacks.
Definition: aws_iot_jobs_internal.h:204