實作 OTA 代理程式 - 的受管整合 AWS IoT Device Management

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

實作 OTA 代理程式

當您從受管整合收到任務文件時,您必須實作自己的 OTA 代理程式,以處理任務文件、下載更新並執行任何安裝操作。OTA 代理程式需要執行下列步驟:

  1. 韌體 Amazon S3 URLs剖析任務文件。

  2. 透過 HTTP 下載韌體更新。

  3. 驗證數位簽章。

  4. 安裝已驗證的更新。

  5. iotmi\_JobsHandler\_updateJobStatus 使用 SUCCESSFAILED 狀態呼叫 。

當您的裝置成功完成 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 );