ota - wolfen351/public-micropython-iot-platform GitHub Wiki
Overview
The OTA (Over-The-Air) module provides functionality for updating firmware and managing configurations for the device. It includes features for downloading, verifying, and installing updates, as well as managing free space and handling errors during the update process.
Features
- Load OTA configuration from
profile.json
. - Check for available updates from a remote server.
- Download and verify firmware updates.
- Install new firmware, including handling compressed and tarred files.
- Manage free space and ensure sufficient memory for updates.
- Handle failed update attempts with recovery mechanisms.
- Recursive deletion of files and directories.
UI Hardware / Pinout Configuration
No specific hardware or pinout configuration is required for the OTA module.
Telemetry Provided
- Logs update status and errors using the
SerialLog
module. - Reports free disk space and memory usage during updates.
Telemetry Consumed
- None.
Methods Provided
load_ota_cfg()
: Loads the OTA configuration fromprofile.json
.check_for_updates(version_check=True)
: Checks for available updates and downloads them if necessary.force_update()
: Forces an update regardless of the current version.install_new_firmware(quiet=False)
: Installs the downloaded firmware.check_free_space(min_free_space)
: Checks if there is enough free space for the update.local_version()
: Retrieves the current firmware version.
Commands Provided
- None. This is called via the wifi module, from the web and from MQTT. It is referenced directly via code and does not use the command system.
Commands Consumed
- None.
Additional Information
- The module uses the
requests
library for HTTP requests. If the library is not available, it attempts to install it dynamically. - The module supports handling compressed firmware files using the
deflate
andtarfile
libraries, which are also installed dynamically if missing. - The
recursive_delete
function ensures safe deletion of files and directories to prevent accidental removal of critical files. - The OTA configuration file (
profile.json
) must include keys likeota
,shortName
,url
,tmp_filename
,excluded_files
, anddelete
for proper operation.