AWS IoT for ESP32 v1.0.0
An ESP-IDF based solution
|
AWS IoT (AWS) Jobs service offered by AWS that lets you perform remote operations on a device. The benefit of using this service is you can target more than one device to perform same remote operation. The most common use case is performing Over-The-Air (OTA) firmware updates and you can also use it to perform tasks such as restarting a device.
You have to first define a set of remote operations and implement them on device side. This library handles communication with AWS Jobs service and callbacks a handler to execute the operation.
Here we have summarised how to handle jobs using this library. You can read the official documentation on Jobs to understand it better.
Status | Description |
---|---|
Accepted | The device has accepted the Job. |
Rejected | The device has rejected the Job for some reason. |
In Progress | The device is performing the operation. |
Failed | The job was accepted, but failed due to execute successfully some reason. |
Successful | The job was accepted and completed successfully. |
You need to attach a job document while you create a job. The job document is a JSON representation that describes the remote operation for a target device.
This is a sample job document that describes blink operation, and it specifies to blink 3 times using a count value.
Note: The
action
key-value pair is necessary in the Job document, without it the library will not be able to handle jobs.
To use AWS Job service, you will also need to use AWS S3 bucket to store job documents. After creating your job document, upload it to your S3 bucket. When creating a new job you should pick the job document from this bucket.
Read the official documentation on Managing jobs here for creating a new job.
To simplify things further we have broken down the process in a sequence to give you an overview.
Let's see an example of a job that will blink an LED 3 times.
On your computer, create a text file and copy-paste the contents of the job document shown below. You can give any name to your file, here we will name it as blink_jobDocument.txt
Note: Keep this file aside for now. We will upload it to S3 bucket when creating a job.
The steps below explains the necessary configuration and initialization required on device side to handle jobs. Ensure your device is provisioned with certificates otherwise you have to manually configure the device certificates.
Define blink_led
function.
Please refer to step #1 of Publish-Subscribe user guide to use thing certificates.
If you want to use other two methods then please read the Provisioning methods of Lib AWS under Overview section and configure the system configuration variable of type systemInitConfig_st
.
Using the above configuration initialize the system and connect to AWS.
Register the job operation function as callback handler.
blink_jobDocument.txt
file on your S3 bucket. After uploading the file, ensure that the file can be downloaded using web browser on your computer.