IoT managed integrations End Device SDK
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Enumerations | Functions
iotmi_jobs_handler.h File Reference

This file defines the Jobs Handler interface. The Jobs Handler provides APIs for managing IoT managed integrations OTA jobs. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Classes

struct  iotmiJobsHandler_config
 Configuration structure for initializing the Jobs Handler. More...
 
struct  iotmi_JobDocument
 Structure representing a job document. More...
 

Macros

#define JOBS_HANDLER_JOBID_MAX_LENGTH   64U /* per AWS IoT API Reference */
 Maximum length of a job ID for the AWS IoT Jobs Service.
 

Typedefs

typedef struct iotmiJobsHandler_config iotmiJobsHandler_config_t
 Configuration structure for initializing the Jobs Handler.
 
typedef struct iotmi_JobDocument iotmi_JobData_t
 Structure representing a job document.
 

Enumerations

enum  JobsHandlerStatus_t {
  kJobsHandlerSuccess = 0 , kJobsHandlerError , kJobsHandlerBadParameter , kJobsHandlerOutOfMemory ,
  kJobsHandlerTimeout , kJobsHandlerMqttAdapterError , kJobsHandlerSyncQueueError
}
 Return codes from jobs functions. More...
 
enum  iotmi_JobCurrentStatus_t {
  kJobCurrentStatusMin = 0 , kJobQueued = kJobCurrentStatusMin , kJobInProgress , kJobFailed ,
  kJobSucceeded , kJobRejected , kJobCurrentStatusMax
}
 Enumeration of possible job statuses. More...
 

Functions

bool iotmiJobsHandler_isInitialized ()
 Check if the Jobs Handler is initialized.
 
JobsHandlerStatus_t iotmiJobsHandler_start (const iotmiJobsHandler_config_t *pConfig)
 Initialize the Jobs Handler.
 
JobsHandlerStatus_t iotmiJobsHandler_getJobDocument (iotmi_JobData_t *pJobDocument, uint32_t timeoutMs)
 Retrieve a job document from the internal queue.
 
JobsHandlerStatus_t iotmiJobsHandler_destroyJobDocument (iotmi_JobData_t *pJobDocument)
 Destroy a job document.
 
JobsHandlerStatus_t iotmiJobsHandler_pollJobDocument ()
 Poll for a job document from the IoT Jobs service.
 
JobsHandlerStatus_t iotmiJobsHandler_updateJobStatus (const char *pJobId, size_t jobIdLength, iotmi_JobCurrentStatus_t status, const char *statusDetails, size_t statusDetailsLength)
 Update the status of a specific job with optional details.
 
void iotmiJobsHandler_stop (void)
 Stop the Jobs Handler and release all resources.
 

Detailed Description

This file defines the Jobs Handler interface. The Jobs Handler provides APIs for managing IoT managed integrations OTA jobs.

Note
All Jobs Handler APIs are not thread-safe. It is the caller's responsibility to ensure that these functions are called in a thread-safe manner, typically by using external synchronization mechanisms.

Enumeration Type Documentation

◆ iotmi_JobCurrentStatus_t

Enumeration of possible job statuses.

Enumerator
kJobCurrentStatusMin 

The minimum value for job status.

kJobQueued 

The job is in the queue, waiting to be processed.

kJobInProgress 

The job is currently being processed.

kJobFailed 

The job processing failed.

kJobSucceeded 

The job processing succeeded.

kJobRejected 

The job was rejected, possibly due to an error or invalid request.

kJobCurrentStatusMax 

The maximum value for job status.

◆ JobsHandlerStatus_t

Return codes from jobs functions.

Enumerator
kJobsHandlerSuccess 

The function completed successfully.

kJobsHandlerError 

An unspecified error occurred in the function.

kJobsHandlerBadParameter 

A function parameter was NULL or has an illegal value.

kJobsHandlerOutOfMemory 

The function ran out of memory.

kJobsHandlerTimeout 

The function timed out.

kJobsHandlerMqttAdapterError 

An error occurred while using the MQTT adapter.

kJobsHandlerSyncQueueError 

An error occurred while using the PAL Sync Queue.

Function Documentation

◆ iotmiJobsHandler_destroyJobDocument()

JobsHandlerStatus_t iotmiJobsHandler_destroyJobDocument ( iotmi_JobData_t *  pJobDocument)

Destroy a job document.

This function frees the memory associated with a job document.

Note
This function is not thread-safe and should be protected by the caller if used in a multi-threaded environment.
Parameters
[in]pJobDocumentPointer to the job document to destroy.
Returns
  • kJobsHandlerSuccess on success.
  • Other error codes indicating the type of failure.

◆ iotmiJobsHandler_getJobDocument()

JobsHandlerStatus_t iotmiJobsHandler_getJobDocument ( iotmi_JobData_t *  pJobDocument,
uint32_t  timeoutMs 
)

Retrieve a job document from the internal queue.

This function waits for a job document to be available in the queue and retrieves it. If no job document is available, the function waits for up to timeoutMs milliseconds.

Note
This function is not thread-safe and should be protected by the caller if used in a multi-threaded environment.
Parameters
[out]pJobDocumentPointer to a structure where the job document will be stored. The caller is responsible for freeing the memory of the job document by calling iotmiJobsHandler_destroyJobDocument.
[in]timeoutMsThe maximum wait time in milliseconds for a job document to become available.
Returns
  • kJobsHandlerSuccess if a job document is successfully retrieved.
  • kJobsHandlerTimeout if no job document is available within the timeout.
  • Other error codes indicating the type of failure.

◆ iotmiJobsHandler_isInitialized()

bool iotmiJobsHandler_isInitialized ( )

Check if the Jobs Handler is initialized.

This function checks if the Jobs Handler has been successfully initialized and is ready for use.

Note
This function is not thread-safe.
Returns
true if the Jobs Handler is initialized, otherwise false.

◆ iotmiJobsHandler_pollJobDocument()

JobsHandlerStatus_t iotmiJobsHandler_pollJobDocument ( )

Poll for a job document from the IoT Jobs service.

This function initiates a poll for a job document from the IoT Jobs service and adds it to the internal queue if available.

Note
This function is not thread-safe and should be protected by the caller if used in a multi-threaded environment.
Returns
  • kJobsHandlerSuccess on success.
  • Other error codes indicating the type of failure.

◆ iotmiJobsHandler_start()

JobsHandlerStatus_t iotmiJobsHandler_start ( const iotmiJobsHandler_config_t *  pConfig)

Initialize the Jobs Handler.

This function starts the Jobs Handler using the specified configuration parameters. It sets up the necessary resources for processing IoT Jobs.

Note
This function is not thread-safe and should be called once before using any other Jobs Handler APIs.
Parameters
[in]pConfigPointer to a configuration structure containing initialization parameters, such as Thing Name and queue size.
Returns
  • kJobsHandlerSuccess on success.
  • Other error codes indicating the type of failure.

◆ iotmiJobsHandler_stop()

void iotmiJobsHandler_stop ( void  )

Stop the Jobs Handler and release all resources.

This function stops the Jobs Handler, unsubscribes from any active topics, and frees any resources allocated for handling IoT Jobs.

Note
This function is not thread-safe and should be called when the Jobs Handler is no longer needed.

◆ iotmiJobsHandler_updateJobStatus()

JobsHandlerStatus_t iotmiJobsHandler_updateJobStatus ( const char *  pJobId,
size_t  jobIdLength,
iotmi_JobCurrentStatus_t  status,
const char *  statusDetails,
size_t  statusDetailsLength 
)

Update the status of a specific job with optional details.

This function updates the status of a specified job, with an option to include additional details in JSON format. The update is sent to the IoT Jobs service.

Note
This function is not thread-safe and should be protected by the caller if used in a multi-threaded environment.
Parameters
[in]pJobIdPointer to the job ID string.
[in]jobIdLengthLength of the job ID string.
[in]statusThe new status of the job.
[in]statusDetailsPointer to a JSON-formatted string containing additional status details, or NULL if not needed.
[in]statusDetailsLengthLength of the status details string, or 0 if statusDetails is NULL.
Returns
  • kJobsHandlerSuccess on success.
  • Other error codes indicating the type of failure.