Disable Direct Download
Prevent the ElegantOTA Pro portal from accepting firmware URLs, or remove the HTTP client from the build entirely.
ElegantOTA Pro feature. This functionality is available only in the commercial edition of ElegantOTA.Direct Download lets a portal user give the device a URL to download an image from. It is enabled by default, so anyone who can open the portal can make the device download from any address.
Behind authentication, this is a convenience. Without authentication, on a network you do not fully control, it allows others to install firmware you did not write. If your product does not need Direct Download, disable it.
Disable Direct Download
ElegantOTA.setDirectDownloadMode(false);Enable Direct Download
ElegantOTA.setDirectDownloadMode(true);Direct Download is enabled by default after a cold boot.
Check the setting
if (ElegantOTA.checkDirectDownloadMode() == true) {
Serial.println("Direct Download is enabled");
} else {
Serial.println("Direct Download is disabled");
}Behavior
While Direct Download is disabled:
- The Direct tab disappears from the portal.
- The
/ota/downloadendpoint refuses requests, regardless of the client that sends them.
The setting only controls URLs submitted through the portal endpoint. The following continue to work:
- Calls to
ElegantOTA.pullFrom()from your own code. - Uploading a
.binfile in File mode. - Auto Update, which only downloads from the update channel compiled into the firmware.
Disabling Direct Download does not replace authentication. Anyone who can reach an unprotected portal can still upload firmware in File mode.
Remove remote updates from the build
If you need neither Direct Download nor Auto Update, compile the HTTP client out of the library to save flash:
build_flags = -D ELEGANTOTA_ENABLE_REMOTE=0The portal then offers only File mode, and the related functions, including pullFrom(), setDirectDownloadMode(), setAutoMode(), setUpdateURL(), setCACert(), state(), source() and onUpdateAvailable(), are not compiled. Remove any calls to them from your sketch.