

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

# Implementa l'agente OTA
<a name="implement-ota-agent"></a>

Quando si riceve il documento di lavoro da Managed Integrations, è necessario disporre di un'implementazione del proprio agente OTA che elabori il documento di lavoro, scarichi gli aggiornamenti ed esegua tutte le operazioni di installazione. L'agente OTA deve eseguire i seguenti passaggi:

1. Analizza i documenti di lavoro per il firmware Amazon URLs S3.

1. Scarica gli aggiornamenti del firmware tramite HTTP.

1. Verifica le firme digitali.

1. Installa aggiornamenti convalidati.

1. Chiama `iotmi\_JobsHandler\_updateJobStatus` con `SUCCESS` o `FAILED` status.

Quando il dispositivo completa con successo l'operazione OTA, deve chiamare l'`iotmi\_JobsHandler\_updateJobStatus`API con uno stato pari `JobSucceeded` a per segnalare un lavoro riuscito.

```
/**
 * @brief Enumeration of possible job statuses.
 */
typedef enum{
    JobQueued,     /** The job is in the queue, waiting to be processed. */
    JobInProgress, /** The job is currently being processed. */
    JobFailed,     /** The job processing failed. */
    JobSucceeded,  /** The job processing succeeded. */
    JobRejected    /** The job was rejected, possibly due to an error or invalid request. */
} iotmi_JobCurrentStatus_t;

/**
 * @brief Update the status of a job with optional status details.
 *
 * @param[in] pJobId Pointer to the job ID string.
 * @param[in] jobIdLength Length of the job ID string.
 * @param[in] status The new status of the job.
 * @param[in] statusDetails Pointer to a string containing additional details about the job status.
 *                          This can be a JSON-formatted string or NULL if no details are needed.
 * @param[in] statusDetailsLength Length of the status details string. Set to 0 if `statusDetails` is NULL.
 *
 * @return 0 on success, non-zero on failure.
 */
int iotmi_JobsHandler_updateJobStatus( const char * pJobId,
                                        size_t jobIdLength,
                                        iotmi_JobCurrentStatus_t status,
                                        const char * statusDetails,
                                        size_t statusDetailsLength );
```