Expand description
Over The Air Updates (OTA)
The OTA update mechanism allows a device to update itself based on data received while the normal firmware is running (for example, over Wi-Fi or Bluetooth.)
§Examples
The following example shows approximate steps for performing an OTA update.
// 1. Obtain an instance of OTA:
let mut ota = EspOta::new().expect("obtain OTA instance");
// 2. Initiate update and obtain an instance of `EspOtaUpdate`:
let mut update = ota.initiate_update().expect("initiate OTA");
// 3. Write the program data:
while let Some(data) = my_wireless.get_ota_data() {
update.write(&data).expect("write OTA data");
}
// 4. Finalize update:
update.complete().expect("complete OTA");
// 5. Reboot:
esp_idf_svc::hal::reset::restart();
After rebooting and confirming that the new firmware works, mark it as valid. If this is not done, firmware will be rolled back.
// Note: starting a new scope here to ensure that ota instance is dropped at the end.
{
let mut ota = EspOta::new().expect("obtain OTA instance");
ota.mark_running_slot_valid().expect("mark app as valid");
}
Structs§
- A firmware info loader that tries to read the firmware info directly from a user-supplied buffer which can be re-used for other purposes afterwards.
- EspFirmware
Info Loader Deprecated