|
SimpleOTA client v1.0.1
Shared core of the SimpleOTA Arduino and ESP-IDF clients
|
The update engine both clients run: boot validation, check-ins, applying an update, the trial and its confirm or rollback, and the deferred reports. More...
Go to the source code of this file.
Data Structures | |
| struct | sota_config_t |
| Strings are borrowed: they must outlive the engine. More... | |
| struct | sota_engine_t |
| One engine's state. More... | |
Enumerations | |
| enum | sota_apply_result_t { SOTA_APPLY_OK = 0 , SOTA_APPLY_CHECKSUM_FAIL = 1 , SOTA_APPLY_FLASH_FAIL = 2 , SOTA_APPLY_NO_OFFER = 3 , SOTA_APPLY_SIGNATURE_FAIL = 4 , SOTA_APPLY_REBOOT_PENDING = 5 , SOTA_APPLY_UNCONFIRMED = 6 , SOTA_APPLY_DOWNGRADE = 7 } |
| sota_engine_apply() results, the same values as simpleota_result_t. More... | |
| enum | sota_confirm_result_t { SOTA_CONFIRM_DONE , SOTA_CONFIRM_NO_TRIAL , SOTA_CONFIRM_FAILED } |
| What sota_engine_confirm() did. More... | |
Functions | |
| bool | sota_engine_init (sota_engine_t *e, const sota_config_t *cfg) |
| Set up an engine. | |
| bool | sota_engine_add_key (sota_engine_t *e, const char *key_id, const char *pem) |
| Pin an Ed25519 public key (PEM). | |
| void | sota_engine_validate_boot (sota_engine_t *e) |
| Work out what this boot means for a saved trial: start supervising it, queue its report, or roll back. | |
| bool | sota_engine_check (sota_engine_t *e) |
| Check in. | |
| sota_apply_result_t | sota_engine_apply (sota_engine_t *e) |
| Download, verify and flash the offer. | |
| sota_confirm_result_t | sota_engine_confirm (sota_engine_t *e) |
| Confirm the running trial image. | |
| void | sota_engine_timeout_fired (sota_engine_t *e) |
| Called by the port's timer, from any context: note the timeout and sota_app_wake(). | |
| void | sota_engine_service (sota_engine_t *e) |
| Roll back when the confirm timeout has fired. | |
| uint32_t | sota_engine_step (sota_engine_t *e, bool connected) |
| One pass of a managed task: service, then check and apply when connected. | |
| bool | sota_engine_reboot_for_update (sota_engine_t *e) |
| With auto_reboot off: post "reboot" for the waiting update and restart. | |
| void | sota_engine_deinit (sota_engine_t *e) |
| Stop the timer and the watchdog, free the offer, and let another engine be set up. | |
| bool | sota_engine_update_waiting (void) |
| A flashed update waits for its reboot (for this boot, every engine). | |
| bool | sota_engine_hold_pending_image (void) |
| For Arduino's verifyRollbackLater(): the running image is on probation and is a SimpleOTA trial. | |
The update engine both clients run: boot validation, check-ins, applying an update, the trial and its confirm or rollback, and the deferred reports.
The public API layer (port/esp32/simpleota.c) owns a sota_engine_t and calls these functions. A device runs one engine at a time (sota_engine_init()). The engine reaches the platform only through the link-time interfaces sota_kv.h, sota_image.h, sota_boot.h, sota_sys.h, sota_net.h and sota_app.h, which the port implements.
Polling use: sota_engine_check(), then sota_engine_apply() when it offers an update. A managed task calls sota_engine_step() and waits the seconds it returns, waking early on sota_app_wake().
| enum sota_apply_result_t |
sota_engine_apply() results, the same values as simpleota_result_t.
What sota_engine_confirm() did.
| bool sota_engine_init | ( | sota_engine_t * | e, |
| const sota_config_t * | cfg | ||
| ) |
Set up an engine.
No storage or network access. False for a token with control characters, an unusable server URL, or while another engine is set up: a device has one trial record, so it runs one engine until sota_engine_deinit().
| bool sota_engine_add_key | ( | sota_engine_t * | e, |
| const char * | key_id, | ||
| const char * | pem | ||
| ) |
Pin an Ed25519 public key (PEM).
key_id may be NULL. False when the PEM does not parse or two keys are pinned already.
| void sota_engine_validate_boot | ( | sota_engine_t * | e | ) |
Work out what this boot means for a saved trial: start supervising it, queue its report, or roll back.
Runs once; check() and apply() call it.
| bool sota_engine_check | ( | sota_engine_t * | e | ) |
Check in.
True when an update is offered. Sends queued reports first, except during a trial, and confirms a trial when auto_confirm is set.
| sota_apply_result_t sota_engine_apply | ( | sota_engine_t * | e | ) |
Download, verify and flash the offer.
Restarts on success when auto_reboot is set.
| void sota_engine_service | ( | sota_engine_t * | e | ) |
Roll back when the confirm timeout has fired.
Call from a task that may block: the managed task, or the API layer after sota_app_wake().
| uint32_t sota_engine_step | ( | sota_engine_t * | e, |
| bool | connected | ||
| ) |
One pass of a managed task: service, then check and apply when connected.
Events report the outcome. Returns the seconds to wait before the next pass.
| bool sota_engine_reboot_for_update | ( | sota_engine_t * | e | ) |
With auto_reboot off: post "reboot" for the waiting update and restart.
Returns false, without restarting, when no update is waiting.
| bool sota_engine_hold_pending_image | ( | void | ) |
For Arduino's verifyRollbackLater(): the running image is on probation and is a SimpleOTA trial.
Reads storage; NVS must be initialised.