Perform OTA Update
The following steps show you how to OTA (over-the-air) update the Ayla agent and/or host app running on your devices.
- Sign in to your Ayla Cloud account using the Sign In API. The API returns access_token and refresh_token.
- Open the Integrated Agent: ESP32 page in another dedicated tab, follow the instructions on the page to establish an ESP32 development environment, and then connect one or more devices to the Ayla Cloud.
- In your Docker shell, run the following command:
cd /root/esp/esp-idf-v4.1/examples/ayla_demo/.
- Open
main/demo_ledevb.c
, and set the following constants to values of your choice:
#define BUILD_PROGNAME "esp32"
#define BUILD_VERSION "1.00"
- Run
make
andmake flash
to update the firmware on your device. - Use the Ayla API Reference to verify your device's version property value in the cloud. Example:
esp32 1.00 Mar 26 2020 16:38:39
- Increment
BUILD_VERSION
indemo_ledevb.c
. Example:
#define BUILD_VERSION "1.01"
- Run
make
, but do not flash the image to the device. Here is the location of the new image file:
/root/esp/esp-idf-v4.1/examples/ayla_demo/build/ayla_demo.bin
- In a host terminal, copy the image file from the docker container to your host computer:
$ docker cp ada16:/root/esp/esp-idf-v4.1/examples/ayla_demo/build/ayla_demo.bin .
- Rename the image file to indicate the version:
$ mv ayla_demo.bin esp32_101.bin
- In the Ayla API Reference, run the Create Image Record API to create an image record using a request data object similar to the following:
{
"description": "esp32_101",
"model": "ledevb",
"version": "esp32_101"
}
Note the model and version values in the response data:
{
...
"model": "ledevb",
"version": "esp32_101",
...
}
Best Practices
- Ensure that all Devices configured with a specific Device Model run compatible firmware so that there's backward compatibility.
- Deploying an incompatible image to a device may render it inoperable.
- Run the Upload Image API to upload your image file, and associate it with the image record.
- Run the Get Image Record API to verify your work. The response data object reflects the size of the uploaded file.
{
...
"file_size": 1205232,
"in_use":false
"model": "ledevb",
...
"version": "esp32_101",
...
}
- Run the Create Filter API to target the ESP32 device(s) you want to upgrade. ICC filters provide various ways of selecting device sets. The following request data object is one example:
{
"name": "My ESP32 Devices",
"dsns": {
"match": [
"AC000W000000001",
"AC000W000000002"
]
},
"oem_model": "ledevb"
}
Note the value of the filter id field (e.g. 6899) in the response data object.
- Run the Get Filter API to verify that the filter was created.
16. Run the Create Job API with a request data object similar to the following:
{
"name": "Upgrade ESP32 devices to esp32_101",
"type_id": "OTA",
"filter_id": 6899,
"exec_method": "ONE_TIME",
"retries": 0
}
Note the value of the job id field (e.g. 5416) in the response data object.
- Run the Get Job API to verify job information. Note
status = CREATED
.
18. Run the Set OTA Action API with a request data object similar to the following to associate an OTA action with the job:
{
"type": "host",
"ayla_model": "ledevb",
"version": "esp32_101"
}
- Run Start Job.
Updated 12 months ago