Client library APIs for the AWS IoT Jobs service. More...
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
Go to the source code of this file.
Macros | |
#define | TOPIC_BUFFER_SIZE 256U |
Size of Topic Buffer. | |
#define | START_JOB_MSG_LENGTH 147U |
Size of Jobs Start Next Message Buffer. | |
#define | UPDATE_JOB_MSG_LENGTH 48U |
Size of Jobs Update Message Buffer. | |
#define | JOBS_THINGNAME_MAX_LENGTH 128U /* per AWS IoT API Reference */ |
Maximum length of a thing name for the AWS IoT Jobs Service. | |
#define | JOBS_JOBID_MAX_LENGTH 64U /* per AWS IoT API Reference */ |
Maximum length of a job ID for the AWS IoT Jobs Service. | |
#define | THINGNAME_MAX_LENGTH JOBS_THINGNAME_MAX_LENGTH |
User defined maximum length of a thing name for the application. | |
#define | JOBID_MAX_LENGTH JOBS_JOBID_MAX_LENGTH |
User defined maximum length of a job ID for the application. | |
#define | JOBS_API_SUBSCRIBE_NEXTJOBCHANGED(thingName) JOBS_TOPIC_COMMON( thingName, JOBS_API_JOBID_NULL, JOBS_API_NEXTJOBCHANGED ) |
Topic string for subscribing to the NextJobExecutionChanged API. | |
#define | JOBS_API_SUBSCRIBE_JOBSCHANGED(thingName) JOBS_TOPIC_COMMON( thingName, JOBS_API_JOBID_NULL, JOBS_API_JOBSCHANGED ) |
Topic string for subscribing to the JobExecutionsChanged API. | |
#define | JOBS_API_PUBLISH_STARTNEXT(thingName) JOBS_TOPIC_COMMON( thingName, JOBS_API_JOBID_NULL, JOBS_API_STARTNEXT ) |
Topic string for publishing to the StartNextPendingJobExecution API. | |
#define | JOBS_API_PUBLISH_GETPENDING(thingName) JOBS_TOPIC_COMMON( thingName, JOBS_API_JOBID_NULL, JOBS_API_GETPENDING ) |
Topic string for publishing to the GetPendingJobExecutions API. | |
#define | JOBS_API_PUBLISH_DESCRIBENEXTJOB(thingName) JOBS_TOPIC_COMMON( thingName, JOBS_API_JOBID_NEXT JOBS_API_LEVEL_SEPARATOR, JOBS_API_DESCRIBE ) |
Topic string for querying the next pending job from the DescribeJobExecution API. | |
#define | JOBS_API_MAX_LENGTH(thingNameLength) |
The size needed to hold the longest topic for a given thing name length. | |
Enumerations | |
enum | JobsStatus_t { JobsError = 0 , JobsSuccess , JobsNoMatch , JobsBadParameter , JobsBufferTooSmall } |
Return codes from jobs functions. More... | |
enum | JobCurrentStatus_t { Queued , InProgress , Failed , Succeeded , Rejected } |
Status codes for jobs. | |
enum | JobUpdateStatus_t { JobUpdateStatus_Accepted , JobUpdateStatus_Rejected } |
Status codes for job update status. | |
enum | JobsTopic_t { JobsInvalidTopic = -1 , JobsJobsChanged , JobsNextJobChanged , JobsGetPendingSuccess , JobsGetPendingFailed , JobsStartNextSuccess , JobsStartNextFailed , JobsDescribeSuccess , JobsDescribeFailed , JobsUpdateSuccess , JobsUpdateFailed , JobsMaxTopic } |
Topic values for subscription requests. More... | |
Functions | |
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. | |
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 within the topic and its length. | |
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. | |
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. | |
size_t | Jobs_StartNextMsg (const char *clientToken, size_t clientTokenLength, char *buffer, size_t bufferSize) |
Populate a message string for a StartNextPendingJobExecution request. | |
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. | |
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. | |
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. | |
size_t | Jobs_GetJobId (const char *message, size_t messageLength, const char **jobId) |
Retrieves the job ID from a given message (if applicable) | |
size_t | Jobs_GetJobDocument (const char *message, size_t messageLength, const char **jobDoc) |
Retrieves the job document from a given message (if applicable) | |
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. | |
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. | |
Client library APIs for the AWS IoT Jobs service.
https://docs.aws.amazon.com/iot/latest/developerguide/jobs-api.html#jobs-mqtt-api
#define THINGNAME_MAX_LENGTH JOBS_THINGNAME_MAX_LENGTH |
User defined maximum length of a thing name for the application.
Default value: JOBS_THINGNAME_MAX_LENGTH
#define JOBID_MAX_LENGTH JOBS_JOBID_MAX_LENGTH |
User defined maximum length of a job ID for the application.
Default value: JOBS_JOBID_MAX_LENGTH
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.
[in] | buffer | The buffer to contain the topic string. |
[in] | length | The size of the buffer. |
[in] | thingName | The device's thingName as registered with AWS IoT. |
[in] | thingNameLength | The length of the thingName. |
[in] | api | The desired Jobs API, e.g., JobsNextJobChanged. |
[out] | outLength | The length of the topic string written to the buffer. |
When all parameters are valid, the topic string is written to the buffer up to one less than the buffer size. The topic is ended with a NUL character.
Example
See jobs.h for docs.
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 within the topic and its length.
[in] | topic | The topic string to check. |
[in] | length | The length of the topic string. |
[in] | thingName | The device's thingName as registered with AWS IoT. |
[in] | thingNameLength | The length of the thingName. |
[out] | outApi | The jobs topic API value if present, e.g., JobsUpdateSuccess. |
[out] | outJobId | The beginning of the jobID in the topic string. |
[out] | outJobIdLength | The length of the jobID in the topic string. |
Example
Output a topic value if a Jobs API topic string is present. Optionally, output a pointer to a jobID within the topic and its length.
See jobs.h for docs.
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.
[in] | buffer | The buffer to contain the topic string. |
[in] | length | The size of the buffer. |
[in] | thingName | The device's thingName as registered with AWS IoT. |
[in] | thingNameLength | The length of the thingName. |
[out] | outLength | The length of the topic string written to the buffer. |
When all parameters are valid, the topic string is written to the buffer up to one less than the buffer size. The topic is ended with a NUL character.
Example
See jobs.h for docs.
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.
[in] | buffer | The buffer to contain the topic string. |
[in] | length | The size of the buffer. |
[in] | thingName | The device's thingName as registered with AWS IoT. |
[in] | thingNameLength | The length of the thingName. |
[out] | outLength | The length of the topic string written to the buffer. |
When all parameters are valid, the topic string is written to the buffer up to one less than the buffer size. The topic is ended with a NUL character.
Example
See jobs.h for docs.
size_t Jobs_StartNextMsg | ( | const char * | clientToken, |
size_t | clientTokenLength, | ||
char * | buffer, | ||
size_t | bufferSize | ||
) |
Populate a message string for a StartNextPendingJobExecution request.
clientToken | The device's token |
clientTokenLength | The expected length of the clientToken |
buffer | The buffer to be written to |
bufferSize | The size of the buffer |
Example
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.
[in] | buffer | The buffer to contain the topic string. |
[in] | length | The size of the buffer. |
[in] | thingName | The device's thingName as registered with AWS IoT. |
[in] | thingNameLength | The length of the thingName. |
[out] | jobId | The ID of the job to describe. |
[out] | jobIdLength | The length of the job ID. |
[out] | outLength | The length of the topic string written to the buffer. |
When all parameters are valid, the topic string is written to the buffer up to one less than the buffer size. The topic is ended with a NUL character.
Example
See jobs.h for docs.
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.
[in] | buffer | The buffer to contain the topic string. |
[in] | length | The size of the buffer. |
[in] | thingName | The device's thingName as registered with AWS IoT. |
[in] | thingNameLength | The length of the thingName. |
[out] | jobId | The ID of the job to describe. |
[out] | jobIdLength | The length of the job ID. |
[out] | outLength | The length of the topic string written to the buffer. |
When all parameters are valid, the topic string is written to the buffer up to one less than the buffer size. The topic is ended with a NUL character.
Example
See jobs.h for docs.
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.
status | Current status of the job |
expectedVersion | The version that is expected |
expectedVersionLength | The length of the expectedVersion string |
buffer | The buffer to be written to |
bufferSize | the size of the buffer |
Example
size_t Jobs_GetJobId | ( | const char * | message, |
size_t | messageLength, | ||
const char ** | jobId | ||
) |
Retrieves the job ID from a given message (if applicable)
message | [In] A JSON formatted message |
messageLength | [In] The length of the message |
jobId | [Out] The job ID |
Example
size_t Jobs_GetJobDocument | ( | const char * | message, |
size_t | messageLength, | ||
const char ** | jobDoc | ||
) |
Retrieves the job document from a given message (if applicable)
message | [In] A JSON formatted message which |
messageLength | [In] The length of the message |
jobDoc | [Out] The job document |
Example
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.
topic | The topic to check against |
topicLength | The expected topic length |
thingName | The device's thingName as registered with AWS IoT. |
thingNameLength | The length of the thingName. |
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.
topic | The topic to check against |
topicLength | The expected topic length |
jobId | Corresponding Job ID which the update was accepted for |
jobIdLength | The Job ID length |
thingName | The device's thingName as registered with AWS IoT. |
thingNameLength | The length of the thingName. |
expectedStatus | The job update status reported by AWS IoT Jobs |