AWS IoT Device SDK C:
Jobs
AWS IoT Jobs library
|
Return to main page ↑ |
User-facing functions of the Jobs library. More...
Go to the source code of this file.
Functions | |
AwsIotJobsError_t | AwsIotJobs_Init (uint32_t mqttTimeoutMs) |
One-time initialization function for the Jobs library. More... | |
void | AwsIotJobs_Cleanup (void) |
One-time deinitialization function for the Jobs library. More... | |
AwsIotJobsError_t | AwsIotJobs_GetPendingAsync (const AwsIotJobsRequestInfo_t *pRequestInfo, uint32_t flags, const AwsIotJobsCallbackInfo_t *pCallbackInfo, AwsIotJobsOperation_t *const pGetPendingOperation) |
Get the list of all pending jobs for a Thing and receive an asynchronous notification when the response arrives. More... | |
AwsIotJobsError_t | AwsIotJobs_GetPendingSync (const AwsIotJobsRequestInfo_t *pRequestInfo, uint32_t flags, uint32_t timeoutMs, AwsIotJobsResponse_t *const pJobsResponse) |
Get the list of all pending jobs for a Thing with a timeout for receiving the response. More... | |
AwsIotJobsError_t | AwsIotJobs_StartNextAsync (const AwsIotJobsRequestInfo_t *pRequestInfo, const AwsIotJobsUpdateInfo_t *pUpdateInfo, uint32_t flags, const AwsIotJobsCallbackInfo_t *pCallbackInfo, AwsIotJobsOperation_t *const pStartNextOperation) |
Start the next pending job execution for a Thing and receive an asynchronous notification when the response arrives. More... | |
AwsIotJobsError_t | AwsIotJobs_StartNextSync (const AwsIotJobsRequestInfo_t *pRequestInfo, const AwsIotJobsUpdateInfo_t *pUpdateInfo, uint32_t flags, uint32_t timeoutMs, AwsIotJobsResponse_t *const pJobsResponse) |
Start the next pending job execution for a Thing with a timeout for receiving the response. More... | |
AwsIotJobsError_t | AwsIotJobs_DescribeAsync (const AwsIotJobsRequestInfo_t *pRequestInfo, int32_t executionNumber, bool includeJobDocument, uint32_t flags, const AwsIotJobsCallbackInfo_t *pCallbackInfo, AwsIotJobsOperation_t *const pDescribeOperation) |
Get detailed information about a job execution and receive an asynchronous notification when the response arrives. More... | |
AwsIotJobsError_t | AwsIotJobs_DescribeSync (const AwsIotJobsRequestInfo_t *pRequestInfo, int32_t executionNumber, bool includeJobDocument, uint32_t flags, uint32_t timeoutMs, AwsIotJobsResponse_t *const pJobsResponse) |
Get detailed information about a job execution with a timeout for receiving the response. More... | |
AwsIotJobsError_t | AwsIotJobs_UpdateAsync (const AwsIotJobsRequestInfo_t *pRequestInfo, const AwsIotJobsUpdateInfo_t *pUpdateInfo, uint32_t flags, const AwsIotJobsCallbackInfo_t *pCallbackInfo, AwsIotJobsOperation_t *const pUpdateOperation) |
Update the status of a job execution and receive an asynchronous notification when the Job update completes. More... | |
AwsIotJobsError_t | AwsIotJobs_UpdateSync (const AwsIotJobsRequestInfo_t *pRequestInfo, const AwsIotJobsUpdateInfo_t *pUpdateInfo, uint32_t flags, uint32_t timeoutMs, AwsIotJobsResponse_t *const pJobsResponse) |
Update the status of a job execution with a timeout for receiving the response. More... | |
AwsIotJobsError_t | AwsIotJobs_Wait (AwsIotJobsOperation_t operation, uint32_t timeoutMs, AwsIotJobsResponse_t *const pJobsResponse) |
Wait for a Jobs operation to complete. More... | |
AwsIotJobsError_t | AwsIotJobs_SetNotifyPendingCallback (IotMqttConnection_t mqttConnection, const char *pThingName, size_t thingNameLength, uint32_t flags, const AwsIotJobsCallbackInfo_t *pNotifyPendingCallback) |
Set a callback to be invoked when the list of pending Jobs changes. More... | |
AwsIotJobsError_t | AwsIotJobs_SetNotifyNextCallback (IotMqttConnection_t mqttConnection, const char *pThingName, size_t thingNameLength, uint32_t flags, const AwsIotJobsCallbackInfo_t *pNotifyNextCallback) |
Set a callback to be invoked when the next pending Job changes. More... | |
AwsIotJobsError_t | AwsIotJobs_RemovePersistentSubscriptions (const AwsIotJobsRequestInfo_t *pRequestInfo, uint32_t flags) |
Remove persistent Jobs operation topic subscriptions. More... | |
const char * | AwsIotJobs_strerror (AwsIotJobsError_t status) |
Returns a string that describes an AwsIotJobsError_t. More... | |
const char * | AwsIotJobs_StateName (AwsIotJobState_t state) |
Returns a string that describes an AwsIotJobState_t. More... | |
User-facing functions of the Jobs library.
AwsIotJobsError_t AwsIotJobs_Init | ( | uint32_t | mqttTimeoutMs | ) |
One-time initialization function for the Jobs library.
This function performs internal setup of the Jobs library. It must be called once (and only once) before calling any other Jobs function. Calling this function more than once without first calling AwsIotJobs_Cleanup may result in a crash.
[in] | mqttTimeoutMs | The amount of time (in milliseconds) that the Jobs library will wait for MQTT operations. Optional; set this to 0 to use AWS_IOT_JOBS_DEFAULT_MQTT_TIMEOUT_MS. |
void AwsIotJobs_Cleanup | ( | void | ) |
One-time deinitialization function for the Jobs library.
This function frees resources taken in AwsIotJobs_Init and deletes any persistent subscriptions. It should be called to clean up the Jobs library. After this function returns, AwsIotJobs_Init must be called again before calling any other Jobs function.
AwsIotJobsError_t AwsIotJobs_GetPendingAsync | ( | const AwsIotJobsRequestInfo_t * | pRequestInfo, |
uint32_t | flags, | ||
const AwsIotJobsCallbackInfo_t * | pCallbackInfo, | ||
AwsIotJobsOperation_t *const | pGetPendingOperation | ||
) |
Get the list of all pending jobs for a Thing and receive an asynchronous notification when the response arrives.
This function implements the GetPendingJobExecutions command of the Jobs API, which gets the list of all Jobs for a Thing that are not in a terminal state. The list of retrieved Jobs is returned as the pResponse
member in AwsIotJobsCallbackParam_t, or through the AwsIotJobsResponse_t parameter of AwsIotJobs_Wait.
[in] | pRequestInfo | Jobs request parameters. |
[in] | flags | Flags which modify the behavior of the Jobs request. See Jobs Function Flags. |
[in] | pCallbackInfo | Asynchronous notification of this function's completion. |
[out] | pGetPendingOperation | Set to a handle by which this operation may be referenced after this function returns. This reference is invalidated once the Jobs operation completes. |
Example
AwsIotJobsError_t AwsIotJobs_GetPendingSync | ( | const AwsIotJobsRequestInfo_t * | pRequestInfo, |
uint32_t | flags, | ||
uint32_t | timeoutMs, | ||
AwsIotJobsResponse_t *const | pJobsResponse | ||
) |
Get the list of all pending jobs for a Thing with a timeout for receiving the response.
This function queues a Jobs GET PENDING, then waits for the result. Internally, this function is a call to AwsIotJobs_GetPendingAsync followed by AwsIotJobs_Wait. See AwsIotJobs_GetPendingAsync for more information on the Jobs GET PENDING command.
[in] | pRequestInfo | Jobs request parameters. |
[in] | flags | Flags which modify the behavior of the Jobs request. See Jobs Function Flags. |
[in] | timeoutMs | If a response is not received within this timeout, this function returns AWS_IOT_JOBS_TIMEOUT. |
[out] | pJobsResponse | The response received from the Jobs service. |
AwsIotJobsError_t AwsIotJobs_StartNextAsync | ( | const AwsIotJobsRequestInfo_t * | pRequestInfo, |
const AwsIotJobsUpdateInfo_t * | pUpdateInfo, | ||
uint32_t | flags, | ||
const AwsIotJobsCallbackInfo_t * | pCallbackInfo, | ||
AwsIotJobsOperation_t *const | pStartNextOperation | ||
) |
Start the next pending job execution for a Thing and receive an asynchronous notification when the response arrives.
This function implements the StartNextPendingJobExecution command of the Jobs API, which gets and starts the next pending job execution for a Thing.
[in] | pRequestInfo | Jobs request parameters. |
[in] | pUpdateInfo | Jobs update parameters. |
[in] | flags | Flags which modify the behavior of the Jobs request. See Jobs Function Flags. |
[in] | pCallbackInfo | Asynchronous notification of this function's completion. |
[out] | pStartNextOperation | Set to a handle by which this operation may be referenced after this function returns. This reference is invalidated once the Jobs operation completes. |
Example
AwsIotJobsError_t AwsIotJobs_StartNextSync | ( | const AwsIotJobsRequestInfo_t * | pRequestInfo, |
const AwsIotJobsUpdateInfo_t * | pUpdateInfo, | ||
uint32_t | flags, | ||
uint32_t | timeoutMs, | ||
AwsIotJobsResponse_t *const | pJobsResponse | ||
) |
Start the next pending job execution for a Thing with a timeout for receiving the response.
This function queues a Jobs START NEXT, then waits for the result. Internally, this function is a call to AwsIotJobs_StartNextAsync followed by AwsIotJobs_Wait. See AwsIotJobs_StartNextAsync for more information on the Jobs START NEXT command.
[in] | pRequestInfo | Jobs request parameters. |
[in] | pUpdateInfo | Jobs update parameters. |
[in] | flags | Flags which modify the behavior of the Jobs request. See Jobs Function Flags. |
[in] | timeoutMs | If a response is not received within this timeout, this function returns AWS_IOT_JOBS_TIMEOUT. |
[out] | pJobsResponse | The response received from the Jobs service. |
AwsIotJobsError_t AwsIotJobs_DescribeAsync | ( | const AwsIotJobsRequestInfo_t * | pRequestInfo, |
int32_t | executionNumber, | ||
bool | includeJobDocument, | ||
uint32_t | flags, | ||
const AwsIotJobsCallbackInfo_t * | pCallbackInfo, | ||
AwsIotJobsOperation_t *const | pDescribeOperation | ||
) |
Get detailed information about a job execution and receive an asynchronous notification when the response arrives.
This function implements the DescribeJobExecution command of the Jobs API, which gets detailed information about a job execution. The description is returned as the pResponse
member in AwsIotJobsCallbackParam_t, or through the AwsIotJobsResponse_t parameter of AwsIotJobs_Wait.
[in] | pRequestInfo | Jobs request parameters. |
[in] | executionNumber | The execution number to describe. Optional; pass AWS_IOT_JOBS_NO_EXECUTION_NUMBER to ignore. |
[in] | includeJobDocument | Whether the response should include the full Job document. |
[in] | flags | Flags which modify the behavior of the Jobs request. See Jobs Function Flags. |
[in] | pCallbackInfo | Asynchronous notification of this function's completion. |
[out] | pDescribeOperation | Set to a handle by which this operation may be referenced after this function returns. This reference is invalidated once the Jobs operation completes. |
Example
AwsIotJobsError_t AwsIotJobs_DescribeSync | ( | const AwsIotJobsRequestInfo_t * | pRequestInfo, |
int32_t | executionNumber, | ||
bool | includeJobDocument, | ||
uint32_t | flags, | ||
uint32_t | timeoutMs, | ||
AwsIotJobsResponse_t *const | pJobsResponse | ||
) |
Get detailed information about a job execution with a timeout for receiving the response.
This function queues a Jobs DESCRIBE, then waits for the result. Internally, this function is a call to AwsIotJobs_DescribeAsync followed by AwsIotJobs_Wait. See AwsIotJobs_DescribeAsync for more information on the Jobs DESCRIBE command.
[in] | pRequestInfo | Jobs request parameters. |
[in] | executionNumber | The execution number to describe. Optional; pass AWS_IOT_JOBS_NO_EXECUTION_NUMBER to ignore. |
[in] | includeJobDocument | Whether the response should include the full Job document. |
[in] | flags | Flags which modify the behavior of the Jobs request. See Jobs Function Flags. |
[in] | timeoutMs | If a response is not received within this timeout, this function returns AWS_IOT_JOBS_TIMEOUT. |
[out] | pJobsResponse | The response received from the Jobs service. |
AwsIotJobsError_t AwsIotJobs_UpdateAsync | ( | const AwsIotJobsRequestInfo_t * | pRequestInfo, |
const AwsIotJobsUpdateInfo_t * | pUpdateInfo, | ||
uint32_t | flags, | ||
const AwsIotJobsCallbackInfo_t * | pCallbackInfo, | ||
AwsIotJobsOperation_t *const | pUpdateOperation | ||
) |
Update the status of a job execution and receive an asynchronous notification when the Job update completes.
This function implements the UpdateJobExecution command of the Jobs API, which updates the status of a Job execution.
[in] | pRequestInfo | Jobs request parameters. |
[in] | pUpdateInfo | Jobs update parameters. |
[in] | flags | Flags which modify the behavior of the Jobs request. See Jobs Function Flags. |
[in] | pCallbackInfo | Asynchronous notification of this function's completion. |
[out] | pUpdateOperation | Set to a handle by which this operation may be referenced after this function returns. This reference is invalidated once the Jobs operation completes. |
Example
AwsIotJobsError_t AwsIotJobs_UpdateSync | ( | const AwsIotJobsRequestInfo_t * | pRequestInfo, |
const AwsIotJobsUpdateInfo_t * | pUpdateInfo, | ||
uint32_t | flags, | ||
uint32_t | timeoutMs, | ||
AwsIotJobsResponse_t *const | pJobsResponse | ||
) |
Update the status of a job execution with a timeout for receiving the response.
This function queues a Jobs UPDATE, then waits for the result. Internally, this function is a call to AwsIotJobs_UpdateAsync followed by AwsIotJobs_Wait. See AwsIotJobs_UpdateAsync for more information on the Jobs UPDATE command.
[in] | pRequestInfo | Jobs request parameters. |
[in] | pUpdateInfo | Jobs update parameters. |
[in] | flags | Flags which modify the behavior of the Jobs request. See Jobs Function Flags. |
[in] | timeoutMs | If a response is not received within this timeout, this function returns AWS_IOT_JOBS_TIMEOUT. |
[out] | pJobsResponse | The response received from the Jobs service. |
AwsIotJobsError_t AwsIotJobs_Wait | ( | AwsIotJobsOperation_t | operation, |
uint32_t | timeoutMs, | ||
AwsIotJobsResponse_t *const | pJobsResponse | ||
) |
Wait for a Jobs operation to complete.
This function blocks to wait for a GET PENDING, START NEXT, DESCRIBE, or UPDATE operation to complete. These operations are by default asynchronous; the function calls queue an operation for processing, and a callback is invoked once the operation is complete.
To use this function, the flag AWS_IOT_JOBS_FLAG_WAITABLE must have been set in the operation's function call. Additionally, this function must always be called with any waitable operation to clean up resources.
Regardless of its return value, this function always clean up resources used by the waitable operation. This means operation
is invalidated as soon as this function returns, even if it returns AWS_IOT_JOBS_TIMEOUT or another error.
[in] | operation | Reference to the Jobs operation to wait for. The flag AWS_IOT_JOBS_FLAG_WAITABLE must have been set for this operation. |
[in] | timeoutMs | How long to wait before returning AWS_IOT_JOBS_TIMEOUT. |
[out] | pJobsResponse | The response received from the Jobs service. |
Example:
AwsIotJobsError_t AwsIotJobs_SetNotifyPendingCallback | ( | IotMqttConnection_t | mqttConnection, |
const char * | pThingName, | ||
size_t | thingNameLength, | ||
uint32_t | flags, | ||
const AwsIotJobsCallbackInfo_t * | pNotifyPendingCallback | ||
) |
Set a callback to be invoked when the list of pending Jobs changes.
The Jobs service publishes a JobExecutionsChanged message to the jobs/notify
topic whenever a Job execution is added to or removed from the list of pending Job executions for a Thing. The message sent is useful for monitoring the list of pending Job executions.
A NOTIFY PENDING callback may be invoked whenever a message is published to jobs/notify
. Each Thing may have up to AWS_IOT_JOBS_NOTIFY_CALLBACKS NOTIFY PENDING callbacks set. This function modifies the NOTIFY PENDING callback for a specific Thing depending on the pNotifyPendingCallback
parameter and the presence of any existing NOTIFY PENDING callback.
pNotifyPendingCallback
is not NULL
, then the existing callback function and parameter are replaced with pNotifyPendingCallback
.pNotifyPendingCallback
is NULL
, then the callback is removed.The member AwsIotJobsCallbackInfo_t::oldFunction must be used to select an already-registered callback function for replacement or removal when AWS_IOT_JOBS_NOTIFY_CALLBACKS is greater than 1
. When multiple callbacks are set, all of them will be invoked when a message is received.
[in] | mqttConnection | The MQTT connection to use for the subscription to jobs/notify . |
[in] | pThingName | The subscription to jobs/notify will be added for this Thing Name. |
[in] | thingNameLength | The length of pThingName . |
[in] | flags | This parameter is for future-compatibility. Currently, flags are not supported for this function and this parameter is ignored. |
[in] | pNotifyPendingCallback | Callback function to invoke for incoming messages. |
Example:
AwsIotJobsError_t AwsIotJobs_SetNotifyNextCallback | ( | IotMqttConnection_t | mqttConnection, |
const char * | pThingName, | ||
size_t | thingNameLength, | ||
uint32_t | flags, | ||
const AwsIotJobsCallbackInfo_t * | pNotifyNextCallback | ||
) |
Set a callback to be invoked when the next pending Job changes.
The Jobs service publishes a NextJobExecutionChanged message to the jobs/notify-next
topic whenever the next Job execution in the list of pending Job executions changes for a Thing. The message sent is useful for being notified of changes to the next Job.
A NOTIFY NEXT callback may be invoked whenever a message is published to jobs/notify-next
. Each Thing may have up to AWS_IOT_JOBS_NOTIFY_CALLBACKS NOTIFY NEXT callbacks set. This function modifies the NOTIFY NEXT callback for a specific Thing depending on the pNotifyNextCallback
parameter and the presence of any existing NOTIFY NEXT callback.
pNotifyNextCallback
is not NULL
, then the existing callback function and parameter are replaced with pNotifyNextCallback
.pNotifyNextCallback
is NULL
, then the callback is removed.The member AwsIotJobsCallbackInfo_t::oldFunction must be used to select an already-registered callback function for replacement or removal when AWS_IOT_JOBS_NOTIFY_CALLBACKS is greater than 1
. When multiple callbacks are set, all of them will be invoked when a message is received.
[in] | mqttConnection | The MQTT connection to use for the subscription to jobs/notify-next . |
[in] | pThingName | The subscription to jobs/notify-next will be added for this Thing Name. |
[in] | thingNameLength | The length of pThingName . |
[in] | flags | This parameter is for future-compatibility. Currently, flags are not supported for this function and this parameter is ignored. |
[in] | pNotifyNextCallback | Callback function to invoke for incoming messages. |
Example:
AwsIotJobsError_t AwsIotJobs_RemovePersistentSubscriptions | ( | const AwsIotJobsRequestInfo_t * | pRequestInfo, |
uint32_t | flags | ||
) |
Remove persistent Jobs operation topic subscriptions.
Passing the flag AWS_IOT_JOBS_FLAG_KEEP_SUBSCRIPTIONS to AwsIotJobs_GetPendingAsync, AwsIotJobs_StartNextAsync, AwsIotJobs_DescribeAsync, AwsIotJobs_UpdateAsync, or their blocking versions causes the Jobs operation topic subscriptions to be maintained for future calls to the same function. If a persistent subscription for a Jobs topic are no longer needed, this function may be used to remove it.
[in] | pRequestInfo | Jobs request info. Only the pThingName, thingNameLength, and mqttConnection members need to be set for this function. |
[in] | flags | Flags that determine which subscriptions to remove. Valid values are the bitwise OR of the following individual flags: |
const char* AwsIotJobs_strerror | ( | AwsIotJobsError_t | status | ) |
Returns a string that describes an AwsIotJobsError_t.
Like POSIX's strerror
, this function returns a string describing a return code. In this case, the return code is a Jobs library error code, status
.
The string returned by this function MUST be treated as read-only: any attempt to modify its contents may result in a crash. Therefore, this function is limited to usage in logging.
[in] | status | The status to describe. |
status
.const char* AwsIotJobs_StateName | ( | AwsIotJobState_t | state | ) |
Returns a string that describes an AwsIotJobState_t.
This function returns a string describing a Job state, state
.
The string returned by this function MUST be treated as read-only: any attempt to modify its contents may result in a crash. Therefore, this function is limited to usage in logging.
[in] | state | The job state to describe. |
state
.