Async Mode
ElegantOTA includes an async mode feature, enabling asynchronous web server functionality for managing OTA updates. When async mode is enabled, ElegantOTA utilizes ESPAsyncWebServer to handle all HTTP routes.
This mode should only be enabled if you are using ESPAsyncWebServer library in your project/firmware. You cannot run synchronous WebServer
and ESPAsyncWebServer
libraries together in the same firmware.
Recommended Dependencies
Install dependencies based on your platform:
- (ESP32Async) ESPAsyncTCP - v2.0.0
- (ESP32Async) ESPAsyncWebServer - v3.7.3
Use of Unrecommended Dependencies (Experimental)
Incase your project is strictly dependent on a fork of dependency which is not listed above, you need to follow these steps if you are using PlatformIO:
-
Please make sure to install ElegantOTA ‘manually’ using the steps provided in installation guide
-
Open
library.json
file in ElegantOTA library folder and delete thedependencies
parameter. This will disable auto installation of recommended dependencies.
Enabling Async Mode
Please follow the steps based on your platform:
When using Arduino IDE, you will have to enable async mode by editing a line inside ElegantOTA library as Arduino IDE doesn’t currently provide us with any way to set build flags.
-
Go to your Arduino libraries directory
-
Open
ElegantOTA
folder and then opensrc
folder -
Locate the
ELEGANTOTA_USE_ASYNC_WEBSERVER
macro in theElegantOTA.h
file, and set it to1
:#define ELEGANTOTA_USE_ASYNC_WEBSERVER 1
-
Save the changes to the
ElegantOTA.h
file. -
You are now ready to use ElegantOTA in async mode for your OTA updates, utilizing the ESPAsyncWebServer library.
Benefits of Async Mode
Enabling async mode for ElegantOTA offers several advantages:
-
Non-blocking Operation: In async mode, ElegantOTA leverages the asynchronous web server capabilities of ESPAsyncWebServer. This means that OTA updates won’t block your device’s main loop. It allows your device to continue executing other tasks while handling OTA updates in the background.
-
Improved Responsiveness: Your device can remain responsive to user interactions or other processes during OTA updates, ensuring a smoother user experience.