/** * ota_update.h - Controller B pulls its own firmware from this repo's Gitea * releases. Port of Controller A's module (ESP32-S3-Touch-LCD-5B/src/modules/ * ota_update.cpp), see wiki/pages/controller-b-ota.md. * * Triggered by A (OTA_CMD inside a SECURE frame, behind A's parking gate and * its Updates screen) or by this console: * * ota status running version, slot, rollback state * ota check join Wi-Fi, ask Gitea for the latest release, leave * ota install [force] join, download, verify, flash idle slot, reboot * ota rollback boot the previous slot * * Safety, same as A: * - refused unless parked: link alive with engine rpm 0 and no shaft speed, * or link silent (ignition off / bench). A has already applied its gate. * - image must match the signed manifest (sha256 + ECDSA P-256 over * "patrol-b|version|sha256"); the idle slot is never activated otherwise. * - a new image must run OTA_CONFIRM_MS before it is marked valid, else the * bootloader falls back to the old slot. * * Wi-Fi: B lives in bare STA mode for ESP-NOW. For a job it joins the network * whose credentials A handed over (LinkPeer), then disconnects again so the * receiver can hop back to A's channel. */ #ifndef OTA_UPDATE_H #define OTA_UPDATE_H #include namespace Ota { /** Log version/slot; flag an unconfirmed new image. Call early in setup(). */ void init(); /** Runs queued jobs, confirms a fresh image after healthy uptime. Call from loop(). */ void tick(); /** LinkPeer hands A's OTA commands here (registered by init()). */ void onLinkCommand(uint8_t cmd, uint8_t flags); /** Console entry point (`ota ...`). */ bool handleCommand(const char* line); const char* version(); } // namespace Ota #endif // OTA_UPDATE_H