2 * AWS IoT Jobs V1.0.0
\r
3 * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
6 * this software and associated documentation files (the "Software"), to deal in
\r
7 * the Software without restriction, including without limitation the rights to
\r
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
9 * the Software, and to permit persons to whom the Software is furnished to do so,
\r
10 * subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be included in all
\r
13 * copies or substantial portions of the Software.
\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
24 * @file aws_iot_jobs_types.h
\r
25 * @brief Types of the Jobs library.
\r
28 #ifndef AWS_IOT_JOBS_TYPES_H_
\r
29 #define AWS_IOT_JOBS_TYPES_H_
\r
31 /* The config header is always included first. */
\r
32 #include "iot_config.h"
\r
34 /* MQTT types include. */
\r
35 #include "types/iot_mqtt_types.h"
\r
37 /*---------------------------- Jobs handle types ----------------------------*/
\r
40 * @handles{jobs,Jobs library}
\r
44 * @ingroup jobs_datatypes_handles
\r
45 * @brief Opaque handle that references an in-progress Jobs operation.
\r
47 * Set as an output parameter of @ref jobs_function_getpendingasync, @ref jobs_function_startnextasync,
\r
48 * @ref jobs_function_describeasync, and @ref jobs_function_updateasync. These functions send a
\r
49 * message to the Jobs service requesting a Jobs operation; the result of this operation
\r
50 * is unknown until the Jobs service sends a response. Therefore, this handle serves as a
\r
51 * reference to Jobs operations awaiting a response from the Jobs service.
\r
53 * This reference will be valid from the successful return of @ref jobs_function_getpendingasync,
\r
54 * @ref jobs_function_startnextasync, @ref jobs_function_describeasync, and @ref jobs_function_updateasync.
\r
55 * The reference becomes invalid once the [completion callback](@ref AwsIotJobsCallbackInfo_t)
\r
56 * is invoked, or @ref jobs_function_wait returns.
\r
58 * @initializer{AwsIotJobsOperation_t,AWS_IOT_JOBS_OPERATION_INITIALIZER}
\r
60 * @see @ref jobs_function_wait and #AWS_IOT_JOBS_FLAG_WAITABLE for waiting on
\r
61 * a reference; or #AwsIotJobsCallbackInfo_t and #AwsIotJobsCallbackParam_t for an
\r
62 * asynchronous notification of completion.
\r
64 typedef struct _jobsOperation * AwsIotJobsOperation_t;
\r
66 /*-------------------------- Jobs enumerated types --------------------------*/
\r
69 * @enums{jobs,Jobs library}
\r
73 * @ingroup jobs_datatypes_enums
\r
74 * @brief Return codes of [Jobs functions](@ref jobs_functions).
\r
76 * The function @ref jobs_function_strerror can be used to get a return code's
\r
79 * The values between #AWS_IOT_JOBS_INVALID_TOPIC and #AWS_IOT_JOBS_TERMINAL_STATE
\r
80 * may be returned by the Jobs service upon failure of a Jobs operation. See [this page]
\r
81 * (https://docs.aws.amazon.com/iot/latest/developerguide/jobs-api.html#jobs-mqtt-error-response)
\r
82 * for more information.
\r
84 typedef enum AwsIotJobsError
\r
87 * @brief Jobs operation completed successfully.
\r
89 * Functions that may return this value:
\r
90 * - @ref jobs_function_init
\r
91 * - @ref jobs_function_wait
\r
92 * - @ref jobs_function_getpendingsync
\r
93 * - @ref jobs_function_startnextsync
\r
94 * - @ref jobs_function_describesync
\r
95 * - @ref jobs_function_updatesync
\r
96 * - @ref jobs_function_setnotifypendingcallback
\r
97 * - @ref jobs_function_setnotifynextcallback
\r
98 * - @ref jobs_function_removepersistentsubscriptions
\r
100 * Will also be the value of a Jobs operation completion callback's<br>
\r
101 * [AwsIotJobsCallbackParam_t.operation.result](@ref AwsIotJobsCallbackParam_t.result)
\r
104 AWS_IOT_JOBS_SUCCESS = 0,
\r
107 * @brief Jobs operation queued, awaiting result.
\r
109 * Functions that may return this value:
\r
110 * - @ref jobs_function_getpendingasync
\r
111 * - @ref jobs_function_startnextasync
\r
112 * - @ref jobs_function_describeasync
\r
113 * - @ref jobs_function_updateasync
\r
115 AWS_IOT_JOBS_STATUS_PENDING = 1,
\r
118 * @brief Initialization failed.
\r
120 * Functions that may return this value:
\r
121 * - @ref jobs_function_init
\r
123 AWS_IOT_JOBS_INIT_FAILED = 2,
\r
126 * @brief At least one parameter is invalid.
\r
128 * Functions that may return this value:
\r
129 * - @ref jobs_function_getpendingasync and @ref jobs_function_getpendingsync
\r
130 * - @ref jobs_function_startnextasync and @ref jobs_function_startnextsync
\r
131 * - @ref jobs_function_describeasync and @ref jobs_function_describesync
\r
132 * - @ref jobs_function_updateasync and @ref jobs_function_updatesync
\r
133 * - @ref jobs_function_wait
\r
134 * - @ref jobs_function_setnotifypendingcallback
\r
135 * - @ref jobs_function_setnotifynextcallback
\r
136 * - @ref jobs_function_removepersistentsubscriptions
\r
138 AWS_IOT_JOBS_BAD_PARAMETER = 3,
\r
141 * @brief Jobs operation failed because of memory allocation failure.
\r
143 * Functions that may return this value:
\r
144 * - @ref jobs_function_getpendingasync and @ref jobs_function_getpendingsync
\r
145 * - @ref jobs_function_startnextasync and @ref jobs_function_startnextsync
\r
146 * - @ref jobs_function_describeasync and @ref jobs_function_describesync
\r
147 * - @ref jobs_function_updateasync and @ref jobs_function_updatesync
\r
148 * - @ref jobs_function_setnotifypendingcallback
\r
149 * - @ref jobs_function_setnotifynextcallback
\r
151 AWS_IOT_JOBS_NO_MEMORY = 4,
\r
154 * @brief Jobs operation failed because of failure in MQTT library.
\r
156 * Functions that may return this value:
\r
157 * - @ref jobs_function_getpendingasync and @ref jobs_function_getpendingsync
\r
158 * - @ref jobs_function_startnextasync and @ref jobs_function_startnextsync
\r
159 * - @ref jobs_function_describeasync and @ref jobs_function_describesync
\r
160 * - @ref jobs_function_updateasync and @ref jobs_function_updatesync
\r
161 * - @ref jobs_function_setnotifypendingcallback
\r
162 * - @ref jobs_function_setnotifynextcallback
\r
163 * - @ref jobs_function_removepersistentsubscriptions
\r
165 AWS_IOT_JOBS_MQTT_ERROR = 5,
\r
168 * @brief Response received from Jobs service not understood.
\r
170 * Functions that may return this value:
\r
171 * - @ref jobs_function_getpendingsync
\r
172 * - @ref jobs_function_startnextsync
\r
173 * - @ref jobs_function_describesync
\r
174 * - @ref jobs_function_updatesync
\r
175 * - @ref jobs_function_wait
\r
177 * May also be the value of a Jobs operation completion callback's<br>
\r
178 * [AwsIotJobsCallbackParam_t.operation.result](@ref AwsIotJobsCallbackParam_t.result).
\r
180 AWS_IOT_JOBS_BAD_RESPONSE = 7,
\r
183 * @brief A blocking Jobs operation timed out.
\r
185 * Functions that may return this value:
\r
186 * - @ref jobs_function_getpendingsync
\r
187 * - @ref jobs_function_startnextsync
\r
188 * - @ref jobs_function_describesync
\r
189 * - @ref jobs_function_updatesync
\r
190 * - @ref jobs_function_wait
\r
191 * - @ref jobs_function_setnotifypendingcallback
\r
192 * - @ref jobs_function_setnotifynextcallback
\r
194 AWS_IOT_JOBS_TIMEOUT = 8,
\r
197 * @brief An API function was called before @ref jobs_function_init.
\r
199 * Functions that may return this value:
\r
200 * - @ref jobs_function_getpendingasync and @ref jobs_function_getpendingsync
\r
201 * - @ref jobs_function_startnextasync and @ref jobs_function_startnextsync
\r
202 * - @ref jobs_function_describeasync and @ref jobs_function_describesync
\r
203 * - @ref jobs_function_updateasync and @ref jobs_function_updatesync
\r
204 * - @ref jobs_function_wait
\r
205 * - @ref jobs_function_setnotifypendingcallback
\r
206 * - @ref jobs_function_setnotifynextcallback
\r
208 AWS_IOT_JOBS_NOT_INITIALIZED = 11,
\r
211 * @brief Jobs operation failed: A request was sent to an unknown topic.
\r
213 * Functions that may return this value:
\r
214 * - @ref jobs_function_getpendingsync
\r
215 * - @ref jobs_function_startnextsync
\r
216 * - @ref jobs_function_describesync
\r
217 * - @ref jobs_function_updatesync
\r
218 * - @ref jobs_function_wait
\r
220 * May also be the value of a Jobs operation completion callback's<br>
\r
221 * [AwsIotJobsCallbackParam_t.operation.result](@ref AwsIotJobsCallbackParam_t.result).
\r
223 AWS_IOT_JOBS_INVALID_TOPIC = 12,
\r
226 * @brief Jobs operation failed: The contents of the request were not understood.
\r
228 * Jobs requests must be UTF-8 encoded JSON documents.
\r
230 * Functions that may return this value:
\r
231 * - @ref jobs_function_getpendingsync
\r
232 * - @ref jobs_function_startnextsync
\r
233 * - @ref jobs_function_describesync
\r
234 * - @ref jobs_function_updatesync
\r
235 * - @ref jobs_function_wait
\r
237 * May also be the value of a Jobs operation completion callback's<br>
\r
238 * [AwsIotJobsCallbackParam_t.operation.result](@ref AwsIotJobsCallbackParam_t.result).
\r
240 AWS_IOT_JOBS_INVALID_JSON = 13,
\r
243 * @brief Jobs operation failed: The contents of the request were invalid.
\r
245 * Functions that may return this value:
\r
246 * - @ref jobs_function_getpendingsync
\r
247 * - @ref jobs_function_startnextsync
\r
248 * - @ref jobs_function_describesync
\r
249 * - @ref jobs_function_updatesync
\r
250 * - @ref jobs_function_wait
\r
252 * May also be the value of a Jobs operation completion callback's<br>
\r
253 * [AwsIotJobsCallbackParam_t.operation.result](@ref AwsIotJobsCallbackParam_t.result).
\r
255 AWS_IOT_JOBS_INVALID_REQUEST = 14,
\r
258 * @brief Jobs operation failed: An update attempted to change the job execution
\r
259 * to an invalid state.
\r
261 * Functions that may return this value:
\r
262 * - @ref jobs_function_startnextsync
\r
263 * - @ref jobs_function_updatesync
\r
264 * - @ref jobs_function_wait
\r
266 * May also be the value of a Jobs operation completion callback's<br>
\r
267 * [AwsIotJobsCallbackParam_t.operation.result](@ref AwsIotJobsCallbackParam_t.result)
\r
268 * following a call to @ref jobs_function_startnextasync or @ref jobs_function_updateasync.
\r
270 AWS_IOT_JOBS_INVALID_STATE = 15,
\r
273 * @brief Jobs operation failed: The specified job execution does not exist.
\r
275 * * Functions that may return this value:
\r
276 * - @ref jobs_function_describesync
\r
277 * - @ref jobs_function_updatesync
\r
278 * - @ref jobs_function_wait
\r
280 * May also be the value of a Jobs operation completion callback's<br>
\r
281 * [AwsIotJobsCallbackParam_t.operation.result](@ref AwsIotJobsCallbackParam_t.result)
\r
282 * following a call to @ref jobs_function_describeasync or @ref jobs_function_updateasync.
\r
284 AWS_IOT_JOBS_NOT_FOUND = 16,
\r
287 * @brief Jobs operation failed: The Jobs service expected a version that did
\r
288 * not match what was in the request.
\r
290 * * Functions that may return this value:
\r
291 * - @ref jobs_function_updatesync
\r
292 * - @ref jobs_function_wait
\r
294 * May also be the value of a Jobs operation completion callback's<br>
\r
295 * [AwsIotJobsCallbackParam_t.operation.result](@ref AwsIotJobsCallbackParam_t.result)
\r
296 * following a call to @ref jobs_function_updateasync.
\r
298 AWS_IOT_JOBS_VERSION_MISMATCH = 17,
\r
301 * @brief Jobs operation failed: The Jobs service encountered an internal error.
\r
303 * Functions that may return this value:
\r
304 * - @ref jobs_function_getpendingsync
\r
305 * - @ref jobs_function_startnextsync
\r
306 * - @ref jobs_function_describesync
\r
307 * - @ref jobs_function_updatesync
\r
308 * - @ref jobs_function_wait
\r
310 * May also be the value of a Jobs operation completion callback's<br>
\r
311 * [AwsIotJobsCallbackParam_t.operation.result](@ref AwsIotJobsCallbackParam_t.result).
\r
313 AWS_IOT_JOBS_INTERNAL_ERROR = 18,
\r
316 * @brief Jobs operation failed: The request was throttled.
\r
318 * Functions that may return this value:
\r
319 * - @ref jobs_function_getpendingsync
\r
320 * - @ref jobs_function_startnextsync
\r
321 * - @ref jobs_function_describesync
\r
322 * - @ref jobs_function_updatesync
\r
323 * - @ref jobs_function_wait
\r
325 * May also be the value of a Jobs operation completion callback's<br>
\r
326 * [AwsIotJobsCallbackParam_t.operation.result](@ref AwsIotJobsCallbackParam_t.result).
\r
328 AWS_IOT_JOBS_THROTTLED = 19,
\r
331 * @brief Jobs operation failed: Attempt to describe a Job in a terminal state.
\r
333 * Functions that may return this value:
\r
334 * - @ref jobs_function_describesync
\r
335 * - @ref jobs_function_wait
\r
337 * May also be the value of a Jobs operation completion callback's<br>
\r
338 * [AwsIotJobsCallbackParam_t.operation.result](@ref AwsIotJobsCallbackParam_t.result)
\r
339 * following a call to @ref jobs_function_describeasync.
\r
341 AWS_IOT_JOBS_TERMINAL_STATE = 20
\r
342 } AwsIotJobsError_t;
\r
345 * @ingroup jobs_datatypes_enums
\r
346 * @brief Possible states of jobs.
\r
348 * The function @ref jobs_function_statename can be used to get a state's
\r
352 * (https://docs.aws.amazon.com/iot/latest/apireference/API_iot-jobs-data_JobExecutionState.html)
\r
353 * for more information on Job states.
\r
355 typedef enum AwsIotJobState
\r
358 * @brief A Job is queued and awaiting execution.
\r
360 AWS_IOT_JOB_STATE_QUEUED,
\r
363 * @brief A Job is currently executing.
\r
365 AWS_IOT_JOB_STATE_IN_PROGRESS,
\r
368 * @brief A Job has failed. This is a terminal state.
\r
370 AWS_IOT_JOB_STATE_FAILED,
\r
373 * @brief A Job has succeeded. This is a terminal state.
\r
375 AWS_IOT_JOB_STATE_SUCCEEDED,
\r
378 * @brief A Job was canceled. This is a terminal state.
\r
380 AWS_IOT_JOB_STATE_CANCELED,
\r
383 * @brief A Job's timer has expired. This is a terminal state.
\r
385 * Jobs are considered timed out if they remain [IN_PROGRESS]
\r
386 * (@ref AWS_IOT_JOB_STATE_IN_PROGRESS) for more than their
\r
387 * `inProgressTimeoutInMinutes` property or a [Job update](@ref jobs_function_updateasync)
\r
388 * was not sent within [stepTimeoutInMinutes](@ref AwsIotJobsUpdateInfo_t.stepTimeoutInMinutes).
\r
390 AWS_IOT_JOB_STATE_TIMED_OUT,
\r
393 * @brief A Job was rejected by the device. This is a terminal state.
\r
395 AWS_IOT_JOB_STATE_REJECTED,
\r
398 * @brief A Job was removed. This is a terminal state.
\r
400 AWS_IOT_JOB_STATE_REMOVED
\r
401 } AwsIotJobState_t;
\r
404 * @ingroup jobs_datatypes_enums
\r
405 * @brief Types of Jobs library callbacks.
\r
407 * One of these values will be placed in #AwsIotJobsCallbackParam_t.callbackType
\r
408 * to identify the reason for invoking a callback function.
\r
410 typedef enum AwsIotJobsCallbackType
\r
412 AWS_IOT_JOBS_GET_PENDING_COMPLETE = 0, /**< Callback invoked because a [Jobs get pending](@ref jobs_function_getpendingasync) completed. */
\r
413 AWS_IOT_JOBS_START_NEXT_COMPLETE = 1, /**< Callback invoked because a [Jobs start next](@ref jobs_function_startnextasync) completed. */
\r
414 AWS_IOT_JOBS_DESCRIBE_COMPLETE = 2, /**< Callback invoked because a [Jobs describe](@ref jobs_function_describeasync) completed. */
\r
415 AWS_IOT_JOBS_UPDATE_COMPLETE = 3, /**< Callback invoked because a [Jobs update](@ref jobs_function_updateasync) completed. */
\r
416 AWS_IOT_JOBS_NOTIFY_PENDING_CALLBACK = 4, /**< Callback invoked for an incoming message on a [Jobs notify-pending](@ref jobs_function_setnotifypendingcallback) topic. */
\r
417 AWS_IOT_JOBS_NOTIFY_NEXT_CALLBACK = 5 /**< Callback invoked for an incoming message on a [Jobs notify-next](@ref jobs_function_setnotifynextcallback) topic. */
\r
418 } AwsIotJobsCallbackType_t;
\r
420 /*-------------------------- Jobs parameter structs -------------------------*/
\r
423 * @paramstructs{jobs,Jobs library}
\r
427 * @ingroup jobs_datatypes_paramstructs
\r
428 * @brief Parameter to a Jobs callback function.
\r
430 * @paramfor Jobs callback functions
\r
432 * The Jobs library passes this struct to a callback function whenever a
\r
433 * Jobs operation completes or a message is received on a Jobs notify-pending
\r
434 * or notify-next topic.
\r
436 * The valid members of this struct are different based on
\r
437 * #AwsIotJobsCallbackParam_t.callbackType. If the callback type is
\r
438 * #AWS_IOT_JOBS_GET_PENDING_COMPLETE, #AWS_IOT_JOBS_START_NEXT_COMPLETE,
\r
439 * #AWS_IOT_JOBS_DESCRIBE_COMPLETE, or #AWS_IOT_JOBS_UPDATE_COMPLETE, then
\r
440 * #AwsIotJobsCallbackParam_t.operation is valid. Otherwise, if the callback type
\r
441 * is #AWS_IOT_JOBS_NOTIFY_PENDING_CALLBACK or #AWS_IOT_JOBS_NOTIFY_NEXT_CALLBACK,
\r
442 * then #AwsIotJobsCallbackParam_t.callback is valid.
\r
444 * @attention Any pointers in this callback parameter may be freed as soon as the
\r
445 * [callback function](@ref AwsIotJobsCallbackInfo_t.function) returns. Therefore,
\r
446 * data must be copied if it is needed after the callback function returns.
\r
447 * @attention The Jobs library may set strings that are not NULL-terminated.
\r
449 * @see #AwsIotJobsCallbackInfo_t for the signature of a callback function.
\r
451 typedef struct AwsIotJobsCallbackParam
\r
453 AwsIotJobsCallbackType_t callbackType; /**< @brief Reason for invoking the Jobs callback function to provide context. */
\r
455 const char * pThingName; /**< @brief The Thing Name associated with this Jobs callback. */
\r
456 size_t thingNameLength; /**< @brief Length of #AwsIotJobsCallbackParam_t.pThingName. */
\r
458 IotMqttConnection_t mqttConnection; /**< @brief The MQTT connection associated with the Jobs callback. */
\r
462 /* Valid for completed Jobs operations. */
\r
465 AwsIotJobsError_t result; /**< @brief Result of Jobs operation, e.g. succeeded or failed. */
\r
466 AwsIotJobsOperation_t reference; /**< @brief Reference to the Jobs operation that completed. */
\r
468 const char * pResponse; /**< @brief Response retrieved from the Jobs service. */
\r
469 size_t responseLength; /**< @brief Length of retrieved response. */
\r
470 } operation; /**< @brief Information on a completed Jobs operation. */
\r
472 /* Valid for a message on a Jobs notify-pending or notify-next topic. */
\r
475 const char * pDocument; /**< @brief Job execution document received on callback. */
\r
476 size_t documentLength; /**< @brief Length of job execution document. */
\r
477 } callback; /**< @brief Jobs document from an incoming delta or updated topic. */
\r
478 } u; /**< @brief Valid member depends on callback type. */
\r
479 } AwsIotJobsCallbackParam_t;
\r
482 * @ingroup jobs_datatypes_paramstructs
\r
483 * @brief Information on a user-provided Jobs callback function.
\r
485 * @paramfor @ref jobs_function_getpendingasync, @ref jobs_function_startnextasync,
\r
486 * @ref jobs_function_describeasync, @ref jobs_function_updateasync,
\r
487 * @ref jobs_function_setnotifypendingcallback, @ref jobs_function_setnotifynextcallback
\r
489 * Provides a function to be invoked when a Jobs operation completes or when a
\r
490 * Jobs document is received on a callback topic (notify-pending or notify-next).
\r
492 * @initializer{AwsIotJobsCallbackInfo_t,AWS_IOT_JOBS_CALLBACK_INFO_INITIALIZER}
\r
494 typedef struct AwsIotJobsCallbackInfo
\r
496 void * pCallbackContext; /**< @brief The first parameter to pass to the callback function. */
\r
499 * @brief User-provided callback function signature.
\r
501 * @param[in] void* #AwsIotJobsCallbackInfo_t.pCallbackContext
\r
502 * @param[in] AwsIotJobsCallbackParam_t* Details on the outcome of the Jobs
\r
503 * operation or an incoming Job document.
\r
505 * @see #AwsIotJobsCallbackParam_t for more information on the second parameter.
\r
507 void ( * function )( void *,
\r
508 AwsIotJobsCallbackParam_t * );
\r
511 * @brief Callback function to replace when passed to @ref jobs_function_setnotifynextcallback
\r
512 * or @ref jobs_function_setnotifypendingcallback.
\r
514 * This member is ignored by Jobs operation functions.
\r
516 * The number of callbacks of each type that may be registered for each Thing
\r
517 * is limited by @ref AWS_IOT_JOBS_NOTIFY_CALLBACKS. If @ref AWS_IOT_JOBS_NOTIFY_CALLBACKS
\r
518 * is `2`, that means that a maximum of `2` NOTIFY PENDING and `2` NOTIFY NEXT callbacks
\r
519 * (`4` total callbacks) may be set. This member is used to replace an existing callback
\r
522 * To add a new callback:
\r
524 * AwsIotJobsCallbackInfo_t callbackInfo = AWS_IOT_JOBS_CALLBACK_INFO_INITIALIZER;
\r
526 * callbackInfo.function = _newCallback;
\r
527 * callbackInfo.oldFunction = NULL;
\r
530 * For example, if the function `_oldCallback()` is currently registered:
\r
531 * - To replace `_oldCallback()` with a new callback function `_newCallback()`:
\r
533 * AwsIotJobsCallbackInfo_t callbackInfo = AWS_IOT_JOBS_CALLBACK_INFO_INITIALIZER;
\r
535 * callbackInfo.function = _newCallback;
\r
536 * callbackInfo.oldFunction = _oldCallback;
\r
538 * - To remove `_oldCallback()`:
\r
540 * AwsIotJobsCallbackInfo_t callbackInfo = AWS_IOT_JOBS_CALLBACK_INFO_INITIALIZER;
\r
542 * callbackInfo.function = NULL;
\r
543 * callbackInfo.oldFunction = _oldCallback;
\r
546 void ( * oldFunction )( void *,
\r
547 AwsIotJobsCallbackParam_t * );
\r
548 } AwsIotJobsCallbackInfo_t;
\r
551 * @ingroup jobs_datatypes_paramstructs
\r
552 * @brief Common information provided to Jobs requests.
\r
554 * @paramfor @ref jobs_function_getpendingasync, @ref jobs_function_getpendingsync,
\r
555 * @ref jobs_function_startnextasync, @ref jobs_function_startnextsync
\r
556 * @ref jobs_function_describeasync, @ref jobs_function_describesync,
\r
557 * @ref jobs_function_updateasync, @ref jobs_function_updatesync
\r
559 * @initializer{AwsIotJobsRequestInfo_t,AWS_IOT_JOBS_REQUEST_INFO_INITIALIZER}
\r
561 typedef struct AwsIotJobsRequestInfo
\r
564 * @brief The MQTT connection to use for the Jobs request.
\r
566 IotMqttConnection_t mqttConnection;
\r
568 /* These members allow Jobs commands to be retried. Be careful that duplicate
\r
569 * commands do no cause unexpected application behavior. Use of QoS 0 is recommended. */
\r
570 IotMqttQos_t qos; /**< @brief QoS when sending the Jobs command. See #IotMqttPublishInfo_t.qos. */
\r
571 uint32_t retryLimit; /**< @brief Maximum number of retries for the Jobs command. See #IotMqttPublishInfo_t.retryLimit. */
\r
572 uint32_t retryMs; /**< @brief First retry time for the Jobs command. See IotMqttPublishInfo_t.retryMs. */
\r
575 * @brief Function to allocate memory for an incoming response.
\r
577 * This only needs to be set if #AWS_IOT_JOBS_FLAG_WAITABLE is passed.
\r
579 void * ( *mallocResponse )( size_t );
\r
582 * @brief The Thing Name associated with the Job.
\r
584 const char * pThingName;
\r
587 * @brief Length of #AwsIotJobsRequestInfo_t.pThingName.
\r
589 size_t thingNameLength;
\r
592 * @brief The Job ID to update.
\r
594 * This may be set to #AWS_IOT_JOBS_NEXT_JOB to update the next pending Job.
\r
595 * When using #AWS_IOT_JOBS_NEXT_JOB, #AwsIotJobsRequestInfo_t.jobIdLength
\r
596 * should be set to #AWS_IOT_JOBS_NEXT_JOB_LENGTH.
\r
598 * This parameter is ignored for calls to @ref jobs_function_getpendingasync,
\r
599 * @ref jobs_function_getpendingsync, @ref jobs_function_startnextasync,
\r
600 * and @ref jobs_function_startnextsync.
\r
602 const char * pJobId;
\r
605 * @brief Length of #AwsIotJobsRequestInfo_t.pJobId.
\r
607 * This parameter is ignored for calls to @ref jobs_function_getpendingasync,
\r
608 * @ref jobs_function_getpendingsync, @ref jobs_function_startnextasync,
\r
609 * and @ref jobs_function_startnextsync.
\r
611 size_t jobIdLength;
\r
614 * @brief An arbitrary string that identifies this Job update to the Jobs
\r
617 * The recommended value is #AWS_IOT_JOBS_CLIENT_TOKEN_AUTOGENERATE.
\r
619 const char * pClientToken;
\r
622 * @brief Length of #AwsIotJobsRequestInfo_t.pClientToken.
\r
624 size_t clientTokenLength;
\r
625 } AwsIotJobsRequestInfo_t;
\r
628 * @ingroup jobs_datatypes_paramstructs
\r
629 * @brief Output parameter of blocking Jobs API functions.
\r
631 * @paramfor @ref jobs_function_getpendingsync, @ref jobs_function_startnextsync,
\r
632 * @ref jobs_function_describesync, @ref jobs_function_updatesync,
\r
633 * @ref jobs_function_wait
\r
635 * Provides the response received from the Jobs service. The buffer for the
\r
636 * response is allocated with #AwsIotJobsRequestInfo_t.mallocResponse.
\r
638 * @initializer{AwsIotJobsResponse_t,AWS_IOT_JOBS_RESPONSE_INITIALIZER}
\r
640 typedef struct AwsIotJobsResponse
\r
642 const char * pJobsResponse; /**< @brief JSON response received from the Jobs service. */
\r
643 size_t jobsResponseLength; /**< @brief Length of #AwsIotJobsResponse_t.pJobsResponse. */
\r
644 } AwsIotJobsResponse_t;
\r
647 * @ingroup jobs_datatypes_paramstructs
\r
648 * @brief Information on a Job update for @ref jobs_function_startnextasync and
\r
649 * @ref jobs_function_updateasync. These functions modify a Job's state.
\r
651 * @paramfor @ref jobs_function_startnextasync, @ref jobs_function_startnextsync,
\r
652 * @ref jobs_function_updateasync, and @ref jobs_function_updatesync.
\r
654 * @initializer{AwsIotJobsUpdateInfo_t,AWS_IOT_JOBS_UPDATE_INFO_INITIALIZER}
\r
656 typedef struct AwsIotJobsUpdateInfo
\r
659 * @brief The new status to report as a Job execution update.
\r
661 * Valid values are:
\r
662 * - #AWS_IOT_JOB_STATE_IN_PROGRESS
\r
663 * - #AWS_IOT_JOB_STATE_FAILED
\r
664 * - #AWS_IOT_JOB_STATE_SUCCEEDED
\r
665 * - #AWS_IOT_JOB_STATE_REJECTED
\r
667 * This parameter is ignored for calls to @ref jobs_function_startnextasync and
\r
668 * @ref jobs_function_startnextsync. These functions always set the state
\r
669 * to #AWS_IOT_JOB_STATE_IN_PROGRESS.
\r
671 AwsIotJobState_t newStatus;
\r
674 * @brief The expected current version of job execution.
\r
676 * Each time a Job update is sent (for the same `JobId`), the version stored
\r
677 * on the AWS IoT Jobs service is updated. If this value does not match the
\r
678 * value stored by the Jobs service, the Job update is rejected with the code
\r
679 * #AWS_IOT_JOBS_VERSION_MISMATCH.
\r
681 * This value is useful for ensuring the order of Job updates, i.e. that the
\r
682 * Jobs service does not overwrite a later update with a previous one. If not
\r
683 * needed, it can be set to #AWS_IOT_JOBS_NO_VERSION.
\r
685 * This parameter is ignored for calls to @ref jobs_function_startnextasync and
\r
686 * @ref jobs_function_startnextsync.
\r
688 uint32_t expectedVersion;
\r
691 * @brief An application-defined value that identifies a Job execution on a
\r
694 * The Jobs service provides commands for tracking the status of Job execution
\r
695 * on a specific target. Therefore, this value is used to provide a unique
\r
696 * identifier of a specific Job execution on a specific target.
\r
698 * This value is optional. It may be set to #AWS_IOT_JOBS_NO_EXECUTION_NUMBER
\r
701 * This parameter is ignored for calls to @ref jobs_function_startnextasync and
\r
702 * @ref jobs_function_startnextsync.
\r
704 int32_t executionNumber;
\r
707 * @brief The amount of time (in minutes) before a new Job update must be reported.
\r
709 * If this timeout expires without a new Job update being reported (for the same
\r
710 * `jobId`), the Job's status is set to #AWS_IOT_JOB_STATE_TIMED_OUT. Sending a
\r
711 * new Job update will reset this step timeout; a value of #AWS_IOT_JOBS_NO_TIMEOUT
\r
712 * will clear any previous step timeout.
\r
714 * Valid values are between 1 and 10,080 (7 days). This value is optional. It may
\r
715 * be set to #AWS_IOT_JOBS_NO_TIMEOUT if not needed.
\r
717 int32_t stepTimeoutInMinutes;
\r
720 * @brief Whether the Job response document should contain the `JobExecutionState`.
\r
722 * The default value is `false`.
\r
724 * This parameter is ignored for calls to @ref jobs_function_startnextasync and
\r
725 * @ref jobs_function_startnextsync.
\r
727 bool includeJobExecutionState;
\r
730 * @brief Whether the Job response document should contain the `JobDocument`.
\r
732 * The default value is `false`.
\r
734 * This parameter is ignored for calls to @ref jobs_function_startnextasync and
\r
735 * @ref jobs_function_startnextsync.
\r
737 bool includeJobDocument;
\r
740 * @brief An application-defined set of JSON name-value pairs that describe
\r
741 * the status of Job execution.
\r
743 * This value is optional. It may be set to #AWS_IOT_JOBS_NO_STATUS_DETAILS
\r
746 const char * pStatusDetails;
\r
749 * @brief Length of #AwsIotJobsUpdateInfo_t.pStatusDetails.
\r
751 size_t statusDetailsLength;
\r
752 } AwsIotJobsUpdateInfo_t;
\r
754 /*------------------------- Jobs defined constants --------------------------*/
\r
757 * @brief Set #AwsIotJobsRequestInfo_t.pJobId to this value to use the next pending
\r
758 * Job as the Job ID.
\r
760 * @note The value of this constant may change at any time in future versions, but
\r
761 * its name will remain the same.
\r
763 #define AWS_IOT_JOBS_NEXT_JOB ( "$next" )
\r
766 * @brief Length of #AWS_IOT_JOBS_NEXT_JOB.
\r
768 * Set #AwsIotJobsRequestInfo_t.jobIdLength to this value when using
\r
769 * #AWS_IOT_JOBS_NEXT_JOB.
\r
771 * @note The value of this constant may change at any time in future versions, but
\r
772 * its name will remain the same.
\r
774 #define AWS_IOT_JOBS_NEXT_JOB_LENGTH ( sizeof( AWS_IOT_JOBS_NEXT_JOB ) - 1 )
\r
777 * @brief Set #AwsIotJobsRequestInfo_t.pClientToken to this value to automatically
\r
778 * generate a client token for the Jobs request.
\r
780 * @note The value of this constant may change at any time in future versions, but
\r
781 * its name will remain the same.
\r
783 #define AWS_IOT_JOBS_CLIENT_TOKEN_AUTOGENERATE ( NULL )
\r
786 * @brief Set #AwsIotJobsUpdateInfo_t.expectedVersion to this value to omit the
\r
787 * version in the Jobs request.
\r
789 * @note The value of this constant may change at any time in future versions, but
\r
790 * its name will remain the same.
\r
792 #define AWS_IOT_JOBS_NO_VERSION ( 0 )
\r
795 * @brief Set #AwsIotJobsUpdateInfo_t.executionNumber to this value or pass it to
\r
796 * @ref jobs_function_describeasync to omit the execution number in the Jobs request.
\r
798 * @note The value of this constant may change at any time in future versions, but
\r
799 * its name will remain the same.
\r
801 #define AWS_IOT_JOBS_NO_EXECUTION_NUMBER ( -1 )
\r
804 * @brief Set #AwsIotJobsUpdateInfo_t.stepTimeoutInMinutes to this value to omit the
\r
805 * step timeout in the Jobs request.
\r
807 * @note The value of this constant may change at any time in future versions, but
\r
808 * its name will remain the same.
\r
810 #define AWS_IOT_JOBS_NO_TIMEOUT ( 0 )
\r
813 * @brief Set #AwsIotJobsUpdateInfo_t.stepTimeoutInMinutes to this value to cancel
\r
814 * any previously set step timeout.
\r
816 * The Jobs service will return an (InvalidRequest)[@ref AWS_IOT_JOBS_INVALID_REQUEST]
\r
817 * error if this value is used without an existing step timeout.
\r
819 * @note The value of this constant may change at any time in future versions, but
\r
820 * its name will remain the same.
\r
822 #define AWS_IOT_JOBS_CANCEL_TIMEOUT ( -1 )
\r
825 * @brief Set #AwsIotJobsUpdateInfo_t.pStatusDetails to this value to omit the
\r
826 * status details in the Jobs request.
\r
828 * @note The value of this constant may change at any time in future versions, but
\r
829 * its name will remain the same.
\r
831 #define AWS_IOT_JOBS_NO_STATUS_DETAILS ( NULL )
\r
834 * @constantspage{jobs,Jobs library}
\r
836 * @section jobs_constants_initializers Jobs Initializers
\r
837 * @brief Provides default values for the data types of the Jobs library.
\r
839 * @snippet this define_jobs_initializers
\r
841 * All user-facing data types of the Jobs library should be initialized
\r
842 * using one of the following.
\r
844 * @warning Failing to initialize a Jobs data type with the appropriate
\r
845 * initializer may result in undefined behavior!
\r
846 * @note The initializers may change at any time in future versions, but their
\r
847 * names will remain the same.
\r
851 * AwsIotJobsCallbackInfo_t callbackInfo = AWS_IOT_JOBS_CALLBACK_INFO_INITIALIZER;
\r
852 * AwsIotJobsRequestInfo_t requestInfo = AWS_IOT_JOBS_REQUEST_INFO_INITIALIZER;
\r
853 * AwsIotJobsUpdateInfo_t updateInfo = AWS_IOT_JOBS_UPDATE_INFO_INITIALIZER;
\r
854 * AwsIotJobsOperation_t operation = AWS_IOT_JOBS_OPERATION_INITIALIZER;
\r
855 * AwsIotJobsResponse_t response = AWS_IOT_JOBS_RESPONSE_INITIALIZER;
\r
858 * @section jobs_constants_flags Jobs Function Flags
\r
859 * @brief Flags that modify the behavior of Jobs library functions.
\r
861 * Flags should be bitwise-ORed with each other to change the behavior of
\r
862 * Jobs library functions.
\r
864 * The following flags are valid for the Jobs operation functions:
\r
865 * @ref jobs_function_getpendingasync, @ref jobs_function_startnextasync,
\r
866 * @ref jobs_function_describeasync, @ref jobs_function_updateasync,
\r
867 * and their blocking versions.
\r
868 * - #AWS_IOT_JOBS_FLAG_WAITABLE <br>
\r
869 * @copybrief AWS_IOT_JOBS_FLAG_WAITABLE
\r
870 * - #AWS_IOT_JOBS_FLAG_KEEP_SUBSCRIPTIONS <br>
\r
871 * @copybrief AWS_IOT_JOBS_FLAG_KEEP_SUBSCRIPTIONS
\r
873 * The following flags are valid for @ref jobs_function_removepersistentsubscriptions.
\r
874 * These flags are not valid for the Jobs operation functions.
\r
875 * - #AWS_IOT_JOBS_FLAG_REMOVE_GET_PENDING_SUBSCRIPTIONS <br>
\r
876 * @copybrief AWS_IOT_JOBS_FLAG_REMOVE_GET_PENDING_SUBSCRIPTIONS
\r
877 * - #AWS_IOT_JOBS_FLAG_REMOVE_START_NEXT_SUBSCRIPTIONS <br>
\r
878 * @copybrief AWS_IOT_JOBS_FLAG_REMOVE_START_NEXT_SUBSCRIPTIONS
\r
879 * - #AWS_IOT_JOBS_FLAG_REMOVE_DESCRIBE_SUBSCRIPTIONS <br>
\r
880 * @copybrief AWS_IOT_JOBS_FLAG_REMOVE_DESCRIBE_SUBSCRIPTIONS
\r
881 * - #AWS_IOT_JOBS_FLAG_REMOVE_UPDATE_SUBSCRIPTIONS <br>
\r
882 * @copybrief AWS_IOT_JOBS_FLAG_REMOVE_UPDATE_SUBSCRIPTIONS
\r
884 * @note The values of the flags may change at any time in future versions, but
\r
885 * their names will remain the same. Additionally, flags which may be used at
\r
886 * the same time will be bitwise-exclusive of each other.
\r
889 /* @[define_jobs_initializers] */
\r
890 #define AWS_IOT_JOBS_CALLBACK_INFO_INITIALIZER { 0 } /**< @brief Initializer for #AwsIotJobsCallbackInfo_t. */
\r
891 /** @brief Initializer for #AwsIotJobsRequestInfo_t. */
\r
892 #define AWS_IOT_JOBS_REQUEST_INFO_INITIALIZER \
\r
893 { .pClientToken = AWS_IOT_JOBS_CLIENT_TOKEN_AUTOGENERATE }
\r
894 /** @brief Initializer for #AwsIotJobsUpdateInfo_t. */
\r
895 #define AWS_IOT_JOBS_UPDATE_INFO_INITIALIZER \
\r
896 { .newStatus = AWS_IOT_JOB_STATE_IN_PROGRESS, \
\r
897 .expectedVersion = AWS_IOT_JOBS_NO_VERSION, \
\r
898 .executionNumber = AWS_IOT_JOBS_NO_EXECUTION_NUMBER, \
\r
899 .stepTimeoutInMinutes = AWS_IOT_JOBS_NO_TIMEOUT, \
\r
900 .includeJobExecutionState = false, \
\r
901 .includeJobDocument = false, \
\r
902 .pStatusDetails = AWS_IOT_JOBS_NO_STATUS_DETAILS }
\r
903 #define AWS_IOT_JOBS_OPERATION_INITIALIZER NULL /**< @brief Initializer for #AwsIotJobsOperation_t. */
\r
904 #define AWS_IOT_JOBS_RESPONSE_INITIALIZER { 0 } /**< @brief Initializer for #AwsIotJobsResponse_t. */
\r
905 /* @[define_jobs_initializers] */
\r
908 * @brief Allows the use of @ref jobs_function_wait for blocking until completion.
\r
910 * This flag is only valid if passed to the functions @ref jobs_function_getpendingasync,
\r
911 * @ref jobs_function_startnextasync, @ref jobs_function_describeasync, or @ref jobs_function_updateasync.
\r
913 * An #AwsIotJobsOperation_t <b>MUST</b> be provided if this flag is set.
\r
914 * Additionally, an #AwsIotJobsCallbackInfo_t <b>MUST NOT</b> be provided.
\r
916 * When this flag is set, #AwsIotJobsRequestInfo_t.mallocResponse must be set
\r
917 * to a function that can be used to allocate memory to hold an incoming response.
\r
919 * @note If this flag is set, @ref jobs_function_wait <b>MUST</b> be called to
\r
920 * clean up resources.
\r
922 #define AWS_IOT_JOBS_FLAG_WAITABLE ( 0x00000001 )
\r
925 * @brief Maintain the subscriptions for the Jobs operation topics, even after
\r
926 * this function returns.
\r
928 * This flag is only valid if passed to the functions @ref jobs_function_getpendingasync,
\r
929 * @ref jobs_function_startnextasync, @ref jobs_function_describeasync, or @ref jobs_function_updateasync,
\r
930 * and their blocking versions.
\r
932 * The Jobs service reports results of Jobs operations by publishing
\r
933 * messages to MQTT topics. By default, the Job operation functions subscribe to the
\r
934 * necessary topics, wait for the Jobs service to publish the result of the
\r
935 * Jobs operation, then unsubscribe from those topics. This workflow is suitable
\r
936 * for infrequent Jobs operations, but is inefficient for frequent, periodic
\r
937 * Jobs operations (where subscriptions for the Jobs operation topics would be
\r
938 * constantly added and removed).
\r
940 * This flag causes the Jobs operation functions to maintain Jobs operation
\r
941 * topic subscriptions, even after the function returns. These subscriptions
\r
942 * may then be used by a future call to the same function.
\r
944 * This flags only needs to be set once, after which subscriptions are maintained
\r
945 * and reused for a specific Thing Name and Jobs function. The function @ref
\r
946 * jobs_function_removepersistentsubscriptions may be used to remove
\r
947 * subscriptions maintained by this flag.
\r
949 #define AWS_IOT_JOBS_FLAG_KEEP_SUBSCRIPTIONS ( 0x00000002 )
\r
952 * @brief Remove the persistent subscriptions from a Jobs get pending operation.
\r
954 * This flag is only valid if passed to the function @ref
\r
955 * jobs_function_removepersistentsubscriptions.
\r
957 * This flag may be passed to @ref jobs_function_removepersistentsubscriptions
\r
958 * to remove any subscriptions for a specific Thing Name maintained by a previous
\r
959 * call to @ref jobs_function_getpendingasync or @ref jobs_function_getpendingsync.
\r
961 * @warning Do not call @ref jobs_function_removepersistentsubscriptions with
\r
962 * this flag for Thing Names with any in-progress Jobs get pending operations.
\r
964 #define AWS_IOT_JOBS_FLAG_REMOVE_GET_PENDING_SUBSCRIPTIONS ( 0x00000001 )
\r
967 * @brief Remove the persistent subscriptions from a Jobs start next operation.
\r
969 * This flag is only valid if passed to the function @ref
\r
970 * jobs_function_removepersistentsubscriptions.
\r
972 * This flag may be passed to @ref jobs_function_removepersistentsubscriptions
\r
973 * to remove any subscriptions for a specific Thing Name maintained by a previous
\r
974 * call to @ref jobs_function_startnextasync or @ref jobs_function_startnextsync.
\r
976 * @warning Do not call @ref jobs_function_removepersistentsubscriptions with
\r
977 * this flag for Thing Names with any in-progress Jobs start next operations.
\r
979 #define AWS_IOT_JOBS_FLAG_REMOVE_START_NEXT_SUBSCRIPTIONS ( 0x00000002 )
\r
982 * @brief Remove the persistent subscriptions from a Jobs describe operation.
\r
984 * This flag is only valid if passed to the function @ref
\r
985 * jobs_function_removepersistentsubscriptions.
\r
987 * This flag may be passed to @ref jobs_function_removepersistentsubscriptions
\r
988 * to remove any subscriptions for a specific Thing Name maintained by a previous
\r
989 * call to @ref jobs_function_describeasync or @ref jobs_function_describesync.
\r
991 * @warning Do not call @ref jobs_function_removepersistentsubscriptions with
\r
992 * this flag for Thing Names with any in-progress Jobs describe operations.
\r
994 #define AWS_IOT_JOBS_FLAG_REMOVE_DESCRIBE_SUBSCRIPTIONS ( 0x00000004 )
\r
997 * @brief Remove the persistent subscriptions from a Jobs update operation.
\r
999 * This flag is only valid if passed to the function @ref
\r
1000 * jobs_function_removepersistentsubscriptions.
\r
1002 * This flag may be passed to @ref jobs_function_removepersistentsubscriptions
\r
1003 * to remove any subscriptions for a specific Thing Name maintained by a previous
\r
1004 * call to @ref jobs_function_updateasync or @ref jobs_function_updatesync.
\r
1006 * @warning Do not call @ref jobs_function_removepersistentsubscriptions with
\r
1007 * this flag for Thing Names with any in-progress Jobs update operations.
\r
1009 #define AWS_IOT_JOBS_FLAG_REMOVE_UPDATE_SUBSCRIPTIONS ( 0x00000008 )
\r
1011 #endif /* ifndef AWS_IOT_JOBS_TYPES_H_ */
\r