本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
实施 OTA 代理
当您收到来自托管集成的任务文档时,必须实现自己的 OTA 代理,该代理可以处理任务文档、下载更新和执行任何安装操作。OTA 代理需要执行以下步骤:
-
解析固件 Amazon S3 URLs 的任务文档。
-
通过 HTTP 下载固件更新。
-
验证数字签名。
-
安装经过验证的更新。
-
iotmi\_JobsHandler\_updateJobStatus使用SUCCESS或FAILED状态拨打电话。
当您的设备成功完成 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 );