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_STATUS_DETAILS "\",\"statusDetails\":"
154#define JOBS_API_STATUS_DETAILS_LENGTH ( sizeof( JOBS_API_STATUS_DETAILS ) - 1U )
156#define JOBS_API_COMMON_LENGTH( thingNameLength ) \
157 ( JOBS_API_PREFIX_LENGTH + ( thingNameLength ) + JOBS_API_BRIDGE_LENGTH )
168#define JOBS_TOPIC_COMMON( thingName, jobId, jobsApi ) \
186#define JOBS_API_SUBSCRIBE_NEXTJOBCHANGED( thingName ) \
187 JOBS_TOPIC_COMMON( thingName, JOBS_API_JOBID_NULL, JOBS_API_NEXTJOBCHANGED )
199#define JOBS_API_SUBSCRIBE_JOBSCHANGED( thingName ) \
200 JOBS_TOPIC_COMMON( thingName, JOBS_API_JOBID_NULL, JOBS_API_JOBSCHANGED )
212#define JOBS_API_PUBLISH_STARTNEXT( thingName ) \
213 JOBS_TOPIC_COMMON( thingName, JOBS_API_JOBID_NULL, JOBS_API_STARTNEXT )
225#define JOBS_API_PUBLISH_GETPENDING( thingName ) \
226 JOBS_TOPIC_COMMON( thingName, JOBS_API_JOBID_NULL, JOBS_API_GETPENDING )
240#define JOBS_API_PUBLISH_DESCRIBENEXTJOB( thingName ) \
241 JOBS_TOPIC_COMMON( thingName, JOBS_API_JOBID_NEXT JOBS_API_LEVEL_SEPARATOR, JOBS_API_DESCRIBE )
248#define JOBS_API_MAX_LENGTH( thingNameLength ) \
249 ( JOBS_API_COMMON_LENGTH( thingNameLength ) + \
250 JOBID_MAX_LENGTH + sizeof( '/' ) + JOBS_API_UPDATE_LENGTH + \
251 JOBS_API_SUCCESS_LENGTH + 1U )
283 JobUpdateStatus_Accepted,
284 JobUpdateStatus_Rejected
305 JobsInvalidTopic = -1,
308 JobsGetPendingSuccess,
309 JobsGetPendingFailed,
310 JobsStartNextSuccess,
409 const char * thingName,
410 uint16_t thingNameLength,
412 size_t * outLength );
527 const char * thingName,
528 uint16_t thingNameLength,
531 uint16_t * outJobIdLength );
595 const char * thingName,
596 uint16_t thingNameLength,
597 size_t * outLength );
661 const char * thingName,
662 uint16_t thingNameLength,
663 size_t * outLength );
705 size_t clientTokenLength,
783 const char * thingName,
784 uint16_t thingNameLength,
786 uint16_t jobIdLength,
787 size_t * outLength );
860 const char * thingName,
861 uint16_t thingNameLength,
863 uint16_t jobIdLength,
864 size_t * outLength );
948 size_t messageLength,
949 const char ** jobId );
986 size_t messageLength,
987 const char ** jobDoc );
1003 const size_t topicLength,
1004 const char * thingName,
1005 const size_t thingNameLength );
1023 const size_t topicLength,
1025 const size_t jobIdLength,
1026 const char * thingName,
1027 const size_t thingNameLength,
JobsTopic_t
Topic values for subscription requests.
Definition: jobs.h:304
JobsStatus_t
Return codes from jobs functions.
Definition: jobs.h:258
@ JobsNoMatch
The buffer does not contain a jobs topic.
Definition: jobs.h:261
@ JobsBufferTooSmall
The buffer write was truncated.
Definition: jobs.h:263
@ JobsSuccess
The buffer was properly written or a match was found.
Definition: jobs.h:260
@ JobsBadParameter
A function parameter was NULL or has an illegal value.
Definition: jobs.h:262
JobCurrentStatus_t
Status codes for jobs.
Definition: jobs.h:270
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:963
size_t Jobs_UpdateMsg(JobsUpdateRequest_t request, char *buffer, size_t bufferSize)
Populate a message string for an UpdateJobExecution request.
Definition: jobs.c:882
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:790
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:921
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:666
JobUpdateStatus_t
Status codes for job update status.
Definition: jobs.h:282
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:929
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:727
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:699
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:749
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:606
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:986
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:285
Structure for Jobs_UpdateMsg request parameters.
Definition: jobs.h:338
size_t expectedVersionLength
Definition: jobs.h:341
size_t statusDetailsLength
Definition: jobs.h:343
const char * statusDetails
Definition: jobs.h:342
JobCurrentStatus_t status
Definition: jobs.h:339
const char * expectedVersion
Definition: jobs.h:340