|
SimpleOTA client v1.1.0
Shared core of the SimpleOTA Arduino and ESP-IDF clients
|
Configuration. More...
#include <simpleota.h>
Data Fields | |
| const char * | token |
| Required. | |
| const char * | base_url |
| Default: "https://simpleota.com". | |
| const char * | device_id |
| Default: Wi-Fi STA MAC "aa:bb:cc:dd:ee:ff". | |
| const char * | chip_family |
| Default: CONFIG_IDF_TARGET ("esp32", "esp32s3", ...), the chip the firmware is built for. | |
| const char * | board_id |
| Board model. | |
| const char * | hardware_revision |
| Board revision. | |
| const char * | partition_profile |
| Partition layout name. | |
| const char * | channel |
| Release channel. | |
| const char * | labels_json |
| Reserved: pre-formed JSON object sent verbatim on check-ins, but not yet consumed by the platform. | |
| simpleota_security_t | security_mode |
| Default: SIMPLEOTA_SECURITY_NONE. | |
| const char * | version_label |
| Default: the label stored with the update that installed this image. | |
| uint32_t | image_build |
| This image's build number, reported when SimpleOTA did not install it (a USB flash). | |
| uint8_t | nvs_schema_version |
| The data schema this firmware expects. | |
| uint32_t | check_interval_s |
| Seconds between checks. | |
| uint32_t | initial_delay_ms |
| Delay before the first check after start(). | |
| uint32_t | confirm_timeout_s |
| Seconds a trial has to confirm. | |
| bool | manual_confirm |
| Managed mode: true = the app calls simpleota_confirm(); false = the first successful check-in confirms. | |
| bool | disable_auto_reboot |
| true: the app calls simpleota_reboot_for_update(). | |
| const simpleota_signing_key_t * | signing_keys |
| Pinned public keys for signed firmware, at most 2. | |
| uint8_t | num_signing_keys |
| Entries in signing_keys. | |
| bool(* | is_connected )(void *user_ctx) |
| Return false while the link is down (e.g. | |
| void(* | event_cb )(const simpleota_event_t *event, void *user_ctx) |
| Lifecycle events, called on the client's task that runs the update: the managed task, or a polling call's task while the caller waits. | |
| void * | user_ctx |
| Passed to is_connected, event_cb and can_update. | |
| const char * | cert_pem |
| TLS trust, always verified. | |
| esp_err_t(* | crt_bundle_attach )(void *conf) |
| Another bundle's attach function. | |
| bool(* | can_update )(void *user_ctx) |
| Managed mode: called on the managed task when an update is offered, after SIMPLEOTA_EVENT_UPDATE_AVAILABLE and before the download. | |
Configuration.
Zero-initialize, then set at least .token. All strings are copied at init; the struct and its strings need not outlive the call.
| const char* simpleota_config_t::token |
Required.
Project token or per-device token.
| const char* simpleota_config_t::base_url |
Default: "https://simpleota.com".
Must be https:// with a host; anything else fails init.
| const char* simpleota_config_t::board_id |
Board model.
Default: left out of check-ins.
| const char* simpleota_config_t::hardware_revision |
Board revision.
Default: left out.
| const char* simpleota_config_t::partition_profile |
Partition layout name.
Default: left out.
| const char* simpleota_config_t::channel |
Release channel.
Default: left out.
| const char* simpleota_config_t::labels_json |
Reserved: pre-formed JSON object sent verbatim on check-ins, but not yet consumed by the platform.
Left out, with a warning, when it is not one JSON object.
| simpleota_security_t simpleota_config_t::security_mode |
Default: SIMPLEOTA_SECURITY_NONE.
SIGNED needs a signing key.
| uint32_t simpleota_config_t::image_build |
This image's build number, reported when SimpleOTA did not install it (a USB flash).
Default: unknown, and such an image reports 0. Set it only in the exact image you upload, to the build SimpleOTA gives it.
| uint8_t simpleota_config_t::nvs_schema_version |
The data schema this firmware expects.
Default: 1.
| uint32_t simpleota_config_t::check_interval_s |
Seconds between checks.
Default: 3600. The managed task spreads each wait of a minute or more by up to a tenth either way, so a fleet does not check in at once, and retries a check or download that failed on the network after 30 s, 2 min and 10 min. In managed mode a 429 or 503 with a Retry-After in seconds is waited out instead (a day at most). A trial ignores it and keeps its quick checks.
| uint32_t simpleota_config_t::initial_delay_ms |
Delay before the first check after start().
Default: none. Not a wait for the IP; see is_connected.
| uint32_t simpleota_config_t::confirm_timeout_s |
Seconds a trial has to confirm.
Default: 300. Clamped to [10, 86400].
| bool simpleota_config_t::manual_confirm |
Managed mode: true = the app calls simpleota_confirm(); false = the first successful check-in confirms.
Polling mode always needs simpleota_confirm().
| const simpleota_signing_key_t* simpleota_config_t::signing_keys |
Pinned public keys for signed firmware, at most 2.
Parsed at init, which fails on a PEM that does not parse rather than run unpinned. They bind only with security_mode SIMPLEOTA_SECURITY_SIGNED: in any other mode an update the server marks unsigned is still accepted on its checksum, and init logs a warning.
A device that will never take a signed update can leave the verifier out of its image by building every source file of the client with -DSIMPLEOTA_DISABLE_SIGNED_UPDATES. Init then refuses signing keys and SIGNED.
| bool(* simpleota_config_t::is_connected) (void *user_ctx) |
Return false while the link is down (e.g.
no IP yet). It is polled every second, and the check runs as soon as it returns true. NULL: always try. start() must then come after the IP arrives, or the first check fails and the next is check_interval_s later.
| void(* simpleota_config_t::event_cb) (const simpleota_event_t *event, void *user_ctx) |
Lifecycle events, called on the client's task that runs the update: the managed task, or a polling call's task while the caller waits.
Keep it quick, and don't call the client from it except simpleota_reboot_for_update().
| const char* simpleota_config_t::cert_pem |
TLS trust, always verified.
Default: the ESP-IDF certificate bundle, except on Arduino-ESP32 2.0.0 to 2.0.3, which do not link it: there, ISRG Root X1 and X2 and GTS Root R4. esp_crt_bundle_set(), which Arduino-ESP32's setCACertBundle(bundle, size) calls from 3.0.4, replaces that bundle for the whole application, this client included; 2.x's WiFiClientSecure keeps its own copy and does not. Set cert_pem to pin a specific CA, or several concatenated, instead (then the default is not used).
| esp_err_t(* simpleota_config_t::crt_bundle_attach) (void *conf) |
Another bundle's attach function.
Default: the trust above.
| bool(* simpleota_config_t::can_update) (void *user_ctx) |
Managed mode: called on the managed task when an update is offered, after SIMPLEOTA_EVENT_UPDATE_AVAILABLE and before the download.
Return false to put the update off, on low battery or in the middle of something that must not be interrupted: nothing is downloaded, and the next check asks again, which simpleota_check_now() brings forward once the device is ready. Keep it quick, and don't call the client from it. NULL: always update. Polling mode does not call it: there the application decides by calling simpleota_apply(). Since API 1.1.