AWS IoT Device SDK C: Jobs
AWS IoT Jobs library
Return to main page ↑
AwsIotJobs_StartNextAsync

Start the next pending job execution for a Thing and receive an asynchronous notification when the response arrives.

const AwsIotJobsUpdateInfo_t * pUpdateInfo,
uint32_t flags,
const AwsIotJobsCallbackInfo_t * pCallbackInfo,
AwsIotJobsOperation_t * const pStartNextOperation );

This function implements the StartNextPendingJobExecution command of the Jobs API, which gets and starts the next pending job execution for a Thing.

Parameters
[in]pRequestInfoJobs request parameters.
[in]pUpdateInfoJobs update parameters.
[in]flagsFlags which modify the behavior of the Jobs request. See Jobs Function Flags.
[in]pCallbackInfoAsynchronous notification of this function's completion.
[out]pStartNextOperationSet to a handle by which this operation may be referenced after this function returns. This reference is invalidated once the Jobs operation completes.
Returns
This function will return AWS_IOT_JOBS_STATUS_PENDING upon successfully queuing the Jobs operation.
If this function fails before queuing the Jobs operation, it will return one of:
Upon successful completion of the Jobs operation (either through an AwsIotJobsCallbackInfo_t or AwsIotJobs_Wait), the status will be AWS_IOT_JOBS_SUCCESS.
Should the Jobs operation fail, the status will be one of:
See also
AwsIotJobs_StartNextSync for a blocking variant of this function.

Example

#define THING_NAME "Test_device"
#define THING_NAME_LENGTH ( sizeof( THING_NAME ) - 1 )
// Signature of Jobs callback function.
void _jobsCallback( void * pCallbackContext, AwsIotJobsCallbackParam_t * pCallbackParam );
// Set the request info. The update info generally does not need to be
// changed, as its defaults are suitable.
requestInfo.mqttConnection = _mqttConnection;
requestInfo.pThingName = THING_NAME;
requestInfo.thingNameLength = THING_NAME_LENGTH;
// Set the callback function to invoke.
callbackInfo.function = _jobsCallback;
// Queue Jobs START NEXT.
AwsIotJobsError_t startNextResult = AwsIotJobs_StartNextAsync( &requestInfo,
&updateInfo,
0,
&callbackInfo,
&startNextOperation );
// START NEXT should have returned AWS_IOT_JOBS_STATUS_PENDING. The function
// _jobsCallback will be invoked once the Jobs response is received.