Skip to content

RaftESPOTAUpdateSysMod

Rob Dobson edited this page May 4, 2026 · 2 revisions

ESPOTAUpdate SysMod

Built-in SysMod that performs ESP32 OTA firmware updates. Receives the firmware image as a stream and writes it to the inactive OTA partition using esp_ota_* APIs, then triggers a restart.

Source: RaftSysMods/components/ESPOTAUpdate/

What it provides

  • HTTP-direct firmware push (espFwUpdate) from a host (e.g. an IDE plugin or raft CLI).
  • File-stream firmware update started by the framework when registered as the firmware handler with ProtocolExchange.
  • Worker task that handles esp_ota_begin/write/end so the network stack is not blocked.
  • Per-update statistics: total bytes, write time, throughput, CRC.

SysType configuration

{
    "name": "ESPOTAUpdate",
    "OTADirect": 1
}
Key Default Meaning
OTADirect true Enable the HTTP-direct path (espFwUpdate). When false, only file-stream updates are accepted.

REST endpoints exposed

Endpoint Method Purpose
espFwUpdate POST Stream firmware image as POST body. Body is consumed in chunks; response is sent on completion.

Application integration

To make the framework route file-stream uploads (e.g. a ufStart over BLE/WebSocket/serial with content type firmware) to this SysMod, register it with ProtocolExchange:

auto* pProtoExch = (ProtocolExchange*)getSysManager()->getSysMod("ProtoExchange");
auto* pOTA      = (ESPOTAUpdate*)getSysManager()->getSysMod("ESPOTAUpdate");
if (pProtoExch && pOTA)
    pProtoExch->setFWUpdateHandler(pOTA);

RaftCoreApp does this automatically when both SysMods are present.

Restart behaviour

After a successful OTA write, the SysMod waits TIME_TO_WAIT_BEFORE_RESTART_MS (1000 ms) so the response can be transmitted, then triggers esp_restart().

Related

Clone this wiki locally