1. 程式人生 > >Using Device Jobs for Over-the-Air Updates

Using Device Jobs for Over-the-Air Updates

Whether it’s a firmware update or security patch, an update to a config file on a device, or a factory reset, all products need maintenance after they are in your customers’ hands. And to manage your fleet, you need to know which devices in your fleet have received and processed, either successfully or unsuccessfully, any of your updates. AWS IoT Device Management facilitates the deployment and tracking of management tasks to your fleet of devices with the Jobs service, whether you manage hundreds, thousands, or even millions of devices. Using Jobs, you can send remote actions to one or many devices at once, control the deployment of your jobs to your devices, and track the current and historical status of job executions for each device.

Jobs can be used to manage your fleet of devices in many ways:

  • To update firmware, software or other files such as security certificates on your devices.
  • To perform administrative tasks, such as restarting devices or performing diagnostics.
  • To restore devices to factory settings or other known good state

This blog post walks you through the creation and deployment of an example job to a device: setting up a device, configuring it to communicate with AWS IoT, creating a job, and tracking the job processing events.

For an overview of the way AWS IoT Core works with AWS IoT Device Management, see the

AWS IoT Core Features and the Jobs documentation.

Setting Up Your Device

After your device operating system is set up and has network connectivity, do the following:

  1. Follow the steps in the AWS IoT Raspberry Pi tutorial found here. Although the steps are written for the Raspberry Pi, you can use them for other Linux-based devices, too. After you complete the tutorial, you will have an IoT thing registered in your AWS account called “MyRaspberryPi.” You will also have configured security certificates to download onto your device.
  2. Follow the instructions here to install and use the AWS IoT Device SDK for JavaScript on your device. Certificates referred to in this blog post are the certificates set up in the previous step.

Your device is now configured to communicate with AWS IoT, including the Jobs service.

Running the Example on Your Device

One of the examples included in the AWS IoT Device SDK for JavaScript is called jobs-example.js. Run this example using the following command, substituting the path to your certificates and the name of the file you used for your thing configuration:

$ node examples/jobs-example.js –f ./certs –F config.json

Your device is now ready to process jobs and send and receive AWS IoT Core messages.

Create a Job Document

A job document is a free form valid JSON document that provides all of the information that your device needs to execute the job. Although the job document can contain anything you deem relevant to your device, by convention the AWS IoT Device SDK for JavaScript uses the property “operation” to route job documents to specific handlers. The jobs-example.js program has a sample handler for an operation called “customJob”, so we are going to create a job document JSON file called “example-job.json”. For this blog post, this is what “example-job.json” should contain:

{
    "operation":"customJob",
    "otherInfo":"someValue"
}

For other job document examples, see the jobs-agent example in the AWS IoT SDK for JavaScript readme.

Create a Job

It is now possible to create a job that delivers the job document to all of the devices you specify. You can use the AWS IoT console, the SDK, or the AWS CLI to create a job.

Here is an example of how to create a job through the AWS CLI:

$ aws iot create-job \
--job-id "example-job-01" \
--targets "arn:aws:iot:::thing/MyRaspberryPi" \
--document file:///example-job.json \
--description "My First test job" \
--target-selection SNAPSHOT

If you’d like to store your job document on S3, you might use the `–document-source` parameter instead of the `–document` parameter to specify the S3 URL for the job document.

Alternatively, to create the job through the AWS IoT console, follow these steps:

Upload the job document to an S3 bucket. For information about uploading documents to S3, see How Do I Upload Files and Folders to an S3 Bucket in the Amazon Simple Storage Service Console Guide.

In the AWS IoT console, choose Manage and then choose Jobs.

On the Select a job page, choose Create custom job.

On the Create a job page, enter a unique job ID. Under Select devices to update, select your previously created thing, as shown here:

Scroll down and choose the “example-job.json” file you uploaded to the S3 bucket. Under Job type, select Your job will complete after deploying to the selected devices/groups (snapshot). The other selection, continuous jobs, is used to deploy a job to groups of devices as devices are added to the groups. Leave Job executions rollout configuration unchanged, as shown here:

Choose Create and then you’ll see your newly created job.

Execute the Job on a Device

After your job is created, the Jobs service will send notification of a pending job to your device. Your device will get the job details and document through the NextJobExecutionChanged API which it is subscribed to. The jobs-example.js program will execute the job on the device, and then publish its completed status using UpdateJobExecution API. During that process, you should see the following output on your IoT client.

$ node examples/jobs-example.js -f ./certs -F config.json
connect
startJobNotifications completed for thing: MyRaspberryPi
customJob operation handler invoked, jobId: example-job-01

If you refresh the Jobs page, you should see that your job was completed successfully.

Tracking Job Progress with Job and Job Execution Events

You can also use job and jobExecution events to track the progress of your job. This can be helpful to alert users, system administrators, or other parts of your system that a job is complete or a job execution has changed its status. For example, you can alert a user about a firmware update on a device or inform a system administrator of an issue in their fleet that needs to be investigated and resolved.

Job events are sent to the following topics when a job is completed or canceled.

$aws/events/job/example-job-01/completed
$aws/events/job/example-job-01/canceled

Job execution events are sent to the following topics when a job execution reaches a final status.

$aws/events/jobExecution/example-job-01/succeeded
$aws/events/jobExecution/example-job-01/failed
$aws/events/jobExecution/example-job-01/rejected
$aws/events/jobExecution/example-job-01/canceled
$aws/events/jobExecution/example-job-01/removed

When the job execution on MyRaspberryPi is successful, you should receive a JobExecution succeeded event. You can see this event by navigating to the AWS IoT test page and subscribing to the following topic:

$aws/events/jobExecution/example-job-01/succeeded


When the job execution for your device is complete, you should see the following message:


After the entire job example-job-01 is complete, you should also receive a job completed event after you subscribe to the following topic:

$aws/events/job/example-job-01/completed

Conclusion

Feel free to leave your feedback in the comments. If you have questions or issues implementing this solution, open a thread on the AWS IoT Device Management forum.

相關推薦

Using Device Jobs for Over-the-Air Updates

Whether it’s a firmware update or security patch, an update to a config file on a device, or a factory reset, all products need maintenance after

5G/NR OTA (Over The Air) 測試詳解

posit 3.4 important efi 網絡 3.1.1 關於 處理 分布 原文鏈接:http://www.sharetechnote.com/html/5G/5G_OTA.html1 什麽是OTA (Over The Air)OTA代表Over The Air。為

Using Continuous Jobs with AWS IoT Device Management

In an earlier Using Over-the-Air Updates with AWS IoT Device Management blog post, we showed you how to create a simple AWS IoT snapshot job and t

Unable to determine the device handle for GPU 0000:04:00.0: GPU is lost. Reboot the system to recov

After almost 3 days of battle, I managed (If you read the whole question) to discard everything but the motherboard. So I took the motherboard out, did som

The issue about using Git bash for Docker in window

I recently installed Docker for Windows on my laptop. When I tried running the default docker run -it ubuntu bash demo from Git Bash, I

The More You Know: Using Knowledge Graphs for Image Classification ——用知識圖譜進行影象分類論文閱讀筆記

Abstract  使人類區別於現代基於學習的計算機視覺演算法的一個特徵是獲得關於世界的知識並使用該知識推理關於視覺世界的能力。人類可以瞭解物體的特徵以及它們之間發生的關係,從而學習各種各樣的視覺概念,並且可以通過很少的例子學習。本文研究了知識圖譜形式的結構化先驗知

The run destination iOS Device is not valid for running the scheme”

      嘗試過幾次,同一個專案,剛剛還正常地執行在模擬器上的,但是當再一次run的時候,一直報”The run destination iOS Device is not valid for ru

PL/SQL Developer登錄出現——Using a filter for all users can lead to poor performance!

objects default devel http mage eve 配置 tool cnblogs 用PL/SQL Developer登錄Oracle時提示:Using a filter for all users can lead to poor performan

vmware復制虛擬機出現Error:No suitable device found:no device found for connection 'System eth0'

prot 虛擬機 oop dns add system span 出現 scripts vmware復制虛擬機出現Error:No suitable device found:no device found for connection ‘System eth0‘ 廢話不多

CF585E:Present for Vitalik the Philatelist

就是 tel clas res list lib 技術 closed sed n<=500000個2<=Ai<=1e7的數,求這樣選數的方案數:先從其中挑出一個gcd不為1的集合,然後再選一個不屬於該集合,且與該集合內任意一個數互質的數。 好的統計題。 其

轉 11g Grid Control: Overview of the EMCTL Options Available for Managing the Agent

and agen font man .com rom access pri into Please set the ORACLE_HOME to your Agent Home location usingFor Unix:export ORACLE_HOME=/o

Geometric regularity criterion for NSE: the cross product of velocity and vorticity 1: $v imes om$

math blog lar suitable don table pro 證明 uitable 在 [Chae, Dongho. On the regularity conditions of suitable weak solutions of the 3D Navier

Replace using VIM, reuse part of the search pattern

hole ng- gpo sin ear ack att ace test 參考:https://unix.stackexchange.com/questions/35206/replace-using-vim-reuse-part-of-the-search-patter

【15】ES6 for Humans: The Latest Standard of JavaScript: ES2015 and Beyond

amazon idt keywords order line padding star ise spa 【15】ES6 for Humans共148頁:目前看到:已經全部閱讀。 亞馬遜地址:魔芋:總結:我先看的是阮一峰的在線書籍。這本書的內容很多都與之重復的。居然賣¥463

OTT(Over The Top),IPTV

模擬 視頻 集成 質量 操作 硬件廠商 互聯網 目前 視頻編解碼 摘自:http://www.cnii.com.cn/technology/2013-04/07/content_1121713.htm 在通信領域,指的是借助運營商的網絡服務,提供包括短信、語音甚至視頻類的服

虛擬機器電腦之間的遷移以及靜態IP的配置,以及虛擬機器遷移後重啟網絡卡報錯:Error:No suitable device found: no device found for connection "S

1.虛擬機器遷移後網絡卡的配置:‘ 自己電腦容量不夠了,準備將資料遷移到公司電腦,但是虛擬機器中做了好多配置,重新安裝會很麻煩,感覺虛擬機器是不是可以直接匯出匯入,保留配置。百度後找到了解決方法。 VMware虛擬機器遷移過程: ’右鍵選擇vmware中的虛擬機器,選擇開啟虛擬機器目錄,

Six golden A Global Leader in Industrial IoT rules for creating the ideal German cover letter and r

www.inhandnetworks.de Applying for jobs is never simple but it can feel even more difficult in a foreign country when you’re unfamiliar with the l

【論文速讀】Shitala Prasad_ECCV2018】Using Object Information for Spotting Text

Shitala Prasad_ECCV2018】Using Object Information for Spotting Text 作者和程式碼 關鍵詞 文字檢測、水平文字、FasterRCNN、xywh、multi-stage 方法亮點 作者argue影象中的文字不可能單獨出現,文字一定是寫

Structural Features for Predicting the Linguistic Quality of Text: Applications to Machine Translation, Automatic Summarization and Human-Authored Tex

abstract句子結構是文字語言質量的關鍵,我們記錄了以下實驗結果:句法短語統計和其他結構特徵對文字方面的預測能力。手工評估的句子fluency流利度用於機器翻譯評估和文字摘要質量的評估是黃金準則。我們發現和短語長度相關的結構特徵是弱特徵,但是與fluency強相關,基於整個結構特徵的分類器可以在句子flu