

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# OTA エージェントを実装する
<a name="implement-ota-agent"></a>

マネージド統合からジョブドキュメントを受け取る場合、ジョブドキュメントを処理し、更新をダウンロードし、インストールオペレーションを実行する独自の OTA エージェントを実装する必要があります。OTA エージェントは次のステップを実行する必要があります。

1. ファームウェア Amazon S3 URL URLs。

1. HTTP を使用してファームウェアの更新をダウンロードします。

1. デジタル署名を検証します。

1. 検証済みの更新をインストールします。

1. `SUCCESS` または `FAILED`ステータス`iotmi\_JobsHandler\_updateJobStatus`で を呼び出します。

デバイスが OTA オペレーションを正常に完了したら、 ステータスの `iotmi\_JobsHandler\_updateJobStatus` API を呼び出し`JobSucceeded`て、ジョブの成功をレポートする必要があります。

```
/**
 * @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 );
```