SimpleOTA client v1.2.0
Shared core of the SimpleOTA Arduino and ESP-IDF clients
Loading...
Searching...
No Matches
simpleota_config_t Struct Reference

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.
 
const char * project_id
 The id of the SimpleOTA project this device belongs to: the project's UUID, lowercase with hyphens, as the CLI's key snippet prints it.
 

Detailed Description

Configuration.

Zero-initialize, then set at least .token. All strings are copied at init; the struct and its strings need not outlive the call.

Field Documentation

◆ token

const char* simpleota_config_t::token

Required.

Project token or per-device token.

◆ base_url

const char* simpleota_config_t::base_url

Default: "https://simpleota.com".

Must be https:// with a host; anything else fails init.

◆ board_id

const char* simpleota_config_t::board_id

Board model.

Default: left out of check-ins.

◆ hardware_revision

const char* simpleota_config_t::hardware_revision

Board revision.

Default: left out.

◆ partition_profile

const char* simpleota_config_t::partition_profile

Partition layout name.

Default: left out.

◆ channel

const char* simpleota_config_t::channel

Release channel.

Default: left out.

◆ labels_json

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.

◆ security_mode

simpleota_security_t simpleota_config_t::security_mode

Default: SIMPLEOTA_SECURITY_NONE.

SIGNED and STRICT need a signing key.

◆ image_build

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.

◆ nvs_schema_version

uint8_t simpleota_config_t::nvs_schema_version

The data schema this firmware expects.

Default: 1.

◆ check_interval_s

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.

◆ initial_delay_ms

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.

◆ confirm_timeout_s

uint32_t simpleota_config_t::confirm_timeout_s

Seconds a trial has to confirm.

Default: 300. Clamped to [10, 86400].

◆ manual_confirm

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().

◆ signing_keys

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 or SIMPLEOTA_SECURITY_STRICT: 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, SIGNED and STRICT.

◆ is_connected

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.

◆ event_cb

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().

◆ cert_pem

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).

◆ crt_bundle_attach

esp_err_t(* simpleota_config_t::crt_bundle_attach) (void *conf)

Another bundle's attach function.

Default: the trust above.

◆ can_update

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.

◆ project_id

const char* simpleota_config_t::project_id

The id of the SimpleOTA project this device belongs to: the project's UUID, lowercase with hyphens, as the CLI's key snippet prints it.

Not the project's slug, which can be renamed. It is not a secret. With it and a signing key, an update's strict signature is checked whenever the offer carries one, and one made for another project or another build number is refused (reason signature_invalid) before the download. SIMPLEOTA_SECURITY_STRICT needs it, and refuses an update without a strict signature too. Only that mode protects against a server replaying an old build: in any other, a server can leave the strict signature out and the update is taken on its image signature alone. Default: strict signatures are not checked. Init fails when it is non-empty and not a UUID in that form. Since API 1.2.


The documentation for this struct was generated from the following file: