49#define TOPIC_BUFFER_SIZE 256U
55#define START_JOB_MSG_LENGTH 147U
61#define UPDATE_JOB_MSG_LENGTH 48U
67#define JOBS_THINGNAME_MAX_LENGTH 128U
73#define JOBS_JOBID_MAX_LENGTH 64U
75#ifndef THINGNAME_MAX_LENGTH
82 #define THINGNAME_MAX_LENGTH JOBS_THINGNAME_MAX_LENGTH
85#ifndef JOBID_MAX_LENGTH
92 #define JOBID_MAX_LENGTH JOBS_JOBID_MAX_LENGTH
95#if ( THINGNAME_MAX_LENGTH > JOBS_THINGNAME_MAX_LENGTH )
96 #error "The value of THINGNAME_MAX_LENGTH exceeds the AWS IoT Jobs Service limit."
99#if ( JOBID_MAX_LENGTH > JOBS_JOBID_MAX_LENGTH )
100 #error "The value of JOBID_MAX_LENGTH exceeds the AWS IoT Jobs Service limit."
108#define JOBS_API_PREFIX "$aws/things/"
109#define JOBS_API_PREFIX_LENGTH ( sizeof( JOBS_API_PREFIX ) - 1U )
111#define JOBS_API_BRIDGE "/jobs/"
112#define JOBS_API_BRIDGE_LENGTH ( sizeof( JOBS_API_BRIDGE ) - 1U )
114#define JOBS_API_SUCCESS "/accepted"
115#define JOBS_API_SUCCESS_LENGTH ( sizeof( JOBS_API_SUCCESS ) - 1U )
117#define JOBS_API_FAILURE "/rejected"
118#define JOBS_API_FAILURE_LENGTH ( sizeof( JOBS_API_FAILURE ) - 1U )
120#define JOBS_API_JOBSCHANGED "notify"
121#define JOBS_API_JOBSCHANGED_LENGTH ( sizeof( JOBS_API_JOBSCHANGED ) - 1U )
123#define JOBS_API_NEXTJOBCHANGED "notify-next"
124#define JOBS_API_NEXTJOBCHANGED_LENGTH ( sizeof( JOBS_API_NEXTJOBCHANGED ) - 1U )
126#define JOBS_API_GETPENDING "get"
127#define JOBS_API_GETPENDING_LENGTH ( sizeof( JOBS_API_GETPENDING ) - 1U )
129#define JOBS_API_STARTNEXT "start-next"
130#define JOBS_API_STARTNEXT_LENGTH ( sizeof( JOBS_API_STARTNEXT ) - 1U )
132#define JOBS_API_DESCRIBE "get"
133#define JOBS_API_DESCRIBE_LENGTH ( sizeof( JOBS_API_DESCRIBE ) - 1U )
135#define JOBS_API_UPDATE "update"
136#define JOBS_API_UPDATE_LENGTH ( sizeof( JOBS_API_UPDATE ) - 1U )
138#define JOBS_API_JOBID_NEXT "$next"
139#define JOBS_API_JOBID_NEXT_LENGTH ( sizeof( JOBS_API_JOBID_NEXT ) - 1U )
141#define JOBS_API_JOBID_NULL ""
142#define JOBS_API_LEVEL_SEPARATOR "/"
144#define JOBS_API_CLIENTTOKEN "{\"clientToken\":\""
145#define JOBS_API_CLIENTTOKEN_LENGTH ( sizeof( JOBS_API_CLIENTTOKEN ) - 1U )
147#define JOBS_API_STATUS "{\"status\":\""
148#define JOBS_API_STATUS_LENGTH ( sizeof( JOBS_API_STATUS ) - 1U )
150#define JOBS_API_EXPECTED_VERSION "\",\"expectedVersion\":\""
151#define JOBS_API_EXPECTED_VERSION_LENGTH ( sizeof( JOBS_API_EXPECTED_VERSION ) - 1U )
153#define JOBS_API_COMMON_LENGTH( thingNameLength ) \
154 ( JOBS_API_PREFIX_LENGTH + ( thingNameLength ) + JOBS_API_BRIDGE_LENGTH )
165#define JOBS_TOPIC_COMMON( thingName, jobId, jobsApi ) \
183#define JOBS_API_SUBSCRIBE_NEXTJOBCHANGED( thingName ) \
184 JOBS_TOPIC_COMMON( thingName, JOBS_API_JOBID_NULL, JOBS_API_NEXTJOBCHANGED )
196#define JOBS_API_SUBSCRIBE_JOBSCHANGED( thingName ) \
197 JOBS_TOPIC_COMMON( thingName, JOBS_API_JOBID_NULL, JOBS_API_JOBSCHANGED )
209#define JOBS_API_PUBLISH_STARTNEXT( thingName ) \
210 JOBS_TOPIC_COMMON( thingName, JOBS_API_JOBID_NULL, JOBS_API_STARTNEXT )
222#define JOBS_API_PUBLISH_GETPENDING( thingName ) \
223 JOBS_TOPIC_COMMON( thingName, JOBS_API_JOBID_NULL, JOBS_API_GETPENDING )
237#define JOBS_API_PUBLISH_DESCRIBENEXTJOB( thingName ) \
238 JOBS_TOPIC_COMMON( thingName, JOBS_API_JOBID_NEXT JOBS_API_LEVEL_SEPARATOR, JOBS_API_DESCRIBE )
245#define JOBS_API_MAX_LENGTH( thingNameLength ) \
246 ( JOBS_API_COMMON_LENGTH( thingNameLength ) + \
247 JOBID_MAX_LENGTH + sizeof( '/' ) + JOBS_API_UPDATE_LENGTH + \
248 JOBS_API_SUCCESS_LENGTH + 1U )
280 JobUpdateStatus_Accepted,
281 JobUpdateStatus_Rejected
302 JobsInvalidTopic = -1,
305 JobsGetPendingSuccess,
306 JobsGetPendingFailed,
307 JobsStartNextSuccess,
380 const char * thingName,
381 uint16_t thingNameLength,
383 size_t * outLength );
498 const char * thingName,
499 uint16_t thingNameLength,
502 uint16_t * outJobIdLength );
566 const char * thingName,
567 uint16_t thingNameLength,
568 size_t * outLength );
632 const char * thingName,
633 uint16_t thingNameLength,
634 size_t * outLength );
676 size_t clientTokenLength,
754 const char * thingName,
755 uint16_t thingNameLength,
757 uint16_t jobIdLength,
758 size_t * outLength );
831 const char * thingName,
832 uint16_t thingNameLength,
834 uint16_t jobIdLength,
835 size_t * outLength );
879 const char * expectedVersion,
880 size_t expectedVersionLength,
918 size_t messageLength,
919 const char ** jobId );
956 size_t messageLength,
957 const char ** jobDoc );
973 const size_t topicLength,
974 const char * thingName,
975 const size_t thingNameLength );
993 const size_t topicLength,
995 const size_t jobIdLength,
996 const char * thingName,
997 const size_t thingNameLength,
JobsTopic_t
Topic values for subscription requests.
Definition: jobs.h:301
JobsStatus_t
Return codes from jobs functions.
Definition: jobs.h:255
@ JobsNoMatch
The buffer does not contain a jobs topic.
Definition: jobs.h:258
@ JobsBufferTooSmall
The buffer write was truncated.
Definition: jobs.h:260
@ JobsSuccess
The buffer was properly written or a match was found.
Definition: jobs.h:257
@ JobsBadParameter
A function parameter was NULL or has an illegal value.
Definition: jobs.h:259
JobCurrentStatus_t
Status codes for jobs.
Definition: jobs.h:267
size_t Jobs_GetJobId(const char *message, size_t messageLength, const char **jobId)
Retrieves the job ID from a given message (if applicable)
Definition: jobs.c:900
size_t Jobs_UpdateMsg(JobCurrentStatus_t status, const char *expectedVersion, size_t expectedVersionLength, char *buffer, size_t bufferSize)
Populate a message string for an UpdateJobExecution request.
Definition: jobs.c:816
JobsStatus_t Jobs_Update(char *buffer, size_t length, const char *thingName, uint16_t thingNameLength, const char *jobId, uint16_t jobIdLength, size_t *outLength)
Populate a topic string for an UpdateJobExecution request.
Definition: jobs.c:781
bool Jobs_IsStartNextAccepted(const char *topic, const size_t topicLength, const char *thingName, const size_t thingNameLength)
Checks if a message comes from the start-next/accepted reserved topic.
Definition: jobs.c:858
JobsStatus_t Jobs_GetPending(char *buffer, size_t length, const char *thingName, uint16_t thingNameLength, size_t *outLength)
Populate a topic string for a GetPendingJobExecutions request.
Definition: jobs.c:657
JobUpdateStatus_t
Status codes for job update status.
Definition: jobs.h:279
bool Jobs_IsJobUpdateStatus(const char *topic, const size_t topicLength, const char *jobId, const size_t jobIdLength, const char *thingName, const size_t thingNameLength, JobUpdateStatus_t expectedStatus)
Checks if a message comes from the update/accepted reserved topic.
Definition: jobs.c:866
size_t Jobs_StartNextMsg(const char *clientToken, size_t clientTokenLength, char *buffer, size_t bufferSize)
Populate a message string for a StartNextPendingJobExecution request.
Definition: jobs.c:718
JobsStatus_t Jobs_StartNext(char *buffer, size_t length, const char *thingName, uint16_t thingNameLength, size_t *outLength)
Populate a topic string for a StartNextPendingJobExecution request.
Definition: jobs.c:690
JobsStatus_t Jobs_Describe(char *buffer, size_t length, const char *thingName, uint16_t thingNameLength, const char *jobId, uint16_t jobIdLength, size_t *outLength)
Populate a topic string for a DescribeJobExecution request.
Definition: jobs.c:740
JobsStatus_t Jobs_MatchTopic(char *topic, size_t length, const char *thingName, uint16_t thingNameLength, JobsTopic_t *outApi, char **outJobId, uint16_t *outJobIdLength)
Output a topic value if a Jobs API topic string is present. Optionally, output a pointer to a jobID w...
Definition: jobs.c:597
size_t Jobs_GetJobDocument(const char *message, size_t messageLength, const char **jobDoc)
Retrieves the job document from a given message (if applicable)
Definition: jobs.c:923
JobsStatus_t Jobs_GetTopic(char *buffer, size_t length, const char *thingName, uint16_t thingNameLength, JobsTopic_t api, size_t *outLength)
Populate a topic string for a subscription request.
Definition: jobs.c:276