AWS IoT for ESP32 v1.0.0
An ESP-IDF based solution
|
The best part of the library is OTA, you literally need not configure anything on device for OTA update to work. Just implement your application task. The library will take care of the OTA update process. All you need to do is create an OTA update Job on AWS IoT with target as your device that's it.
Build your application and upload the binary file on S3 bucket.
You may host your file anywhere but it should be publicly accessible using HTTP(S). After hosting the file, to ensure that your file is publicy accessible you can try downloading the file on your local computer using web browser.
Create a job document for OTA update.
The format of the job document required by the library is shown below. Replace the url
value with HTTP(S) link to your file that you uploaded in the previous step.
After the job is created the target device will receive notification about this job and put the device in OTA mode. The library will download the binary file, update the firmware and reboot itself.
For demonstration we will just blink an LED in the application task.
To test and verify firmware update you need two different versions of your application. We will create two applications that will blink an LED at different rates with different version number. Sample code of both the versions is shown below.
Application v1.0.0:
Application v2.0.0:
url
link to application v2.0.0 version.The device should recevie the job notification and start the update process. After updating the firmware the device reboots, you should then see the LED blinking at faster rate.
You may create a duplicate of first project (v1.0.0) then start modifying it for the second version (v2.0.0). Another way is to first build & flash your device with first version then modify the blink rate & change its version number and build it. Then upload this binary to your S3 bucket.
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.
Just add the code to blink the led and change the version number in app_config.h
file.
Sample application task code:
Create an OTA Job with a job document that contains the url
to the second version of application binary. Ensure you select your target device.