1
0
Fork 0
mirror of https://github.com/imjasonh/esp32 synced 2026-07-09 00:45:22 +00:00
esp32/provisioning.toml.example
Jason Hall 7cb4e8c75c cloud_log: NVS-loaded config, tracing layer, queue, stub sender
First commit of cloud-logging work (logs-plan.md). Foundation only:
the actual NTP/JWT/RSA/HTTPS-POST sender is the next commit; this
sender is a stub that writes 'would POST' to serial.

src/cloud_log.rs:
- GcpConfig::load reads the optional 'gcp' NVS namespace. If any
  required key (project_id / sa_email / sa_key_id / sa_key_pem) is
  missing, returns Ok(None) — cloud logging is opt-in per device.
- LogQueue: Mutex<VecDeque>-backed bounded ring buffer (256 entries),
  drops oldest when full and surfaces the drop count on the next push.
- CloudLogLayer: tracing_subscriber Layer that captures events,
  extracts structured fields via field::Visit, applies the configured
  min_severity filter, and pushes onto the queue. Uses wall-clock
  time when SystemTime::now() is past 2020 (NTP synced); else None
  so Cloud Logging assigns server-side timestamps.

main.rs:
- Take NVS first, before any tracing events fire.
- If the gcp NVS namespace is populated, install CloudLogLayer as
  the global tracing subscriber and spawn the sender thread (32 KB
  stack).
- tracing now uses the 'log-always' feature so events still emit
  log records even with a subscriber installed — keeps EspLogger
  writing to serial regardless.

tools/provision/:
- Optional [gcp] section in provisioning.toml. Tool emits the gcp
  namespace into the NVS CSV when present, validates min_severity
  spelling early.

ota.md: gcp namespace added to NVS schema docs.
provisioning.toml.example: commented [gcp] block.

Firmware size: 1.52 MB -> 1.60 MB (tracing-subscriber + cloud_log code).
Plenty of slot headroom remaining (1.94 MB).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 17:06:00 -04:00

40 lines
1.7 KiB
Text

# Provisioning config for `make provision`. Copy to `provisioning.toml`
# (gitignored) and fill in your values, then `make provision` to write
# everything to the device's NVS partition over USB.
[wifi]
ssid = "your-wifi-ssid"
pass = "your-wifi-password"
[trust]
# Bundled Sigstore Fulcio root + intermediate CA PEMs. These come from
# https://github.com/sigstore/root-signing/tree/main/targets and need to
# be re-fetched + re-provisioned if Sigstore rotates them (rare).
fulcio_root_pem = "trust/fulcio_root.pem"
fulcio_intermediate_pem = "trust/fulcio_intermediate.pem"
# Allowlist of (identity, issuer) pairs the OTA verifier accepts as
# signers of incoming firmware. Identity is the SAN value in the Fulcio
# leaf cert — an rfc822Name (email) for OIDC issuers like Google, or a
# URI for workflow-based issuers like GitHub Actions.
# Manual `make publish` from a developer machine.
[[trust.identities]]
identity = "imjasonh@gmail.com"
issuer = "https://accounts.google.com"
# Automated publishes from the GHA workflow on push to main.
[[trust.identities]]
identity = "https://github.com/imjasonh/esp32/.github/workflows/publish.yml@refs/heads/main"
issuer = "https://token.actions.githubusercontent.com"
# Optional. If absent, the device boots with serial-only logging and
# never tries to talk to GCP. Uncomment + fill in to enable shipping
# tracing events (app + OTA) to Google Cloud Logging.
#
# [gcp]
# project_id = "my-logs-project"
# sa_email = "esp32-logger@my-logs-project.iam.gserviceaccount.com"
# sa_key_id = "abc123..." # the `private_key_id` field from the SA JSON key
# sa_key_pem = "gcp-sa-key.pem" # path to the PKCS#8 RSA private key PEM
# min_severity = "info" # trace / debug / info / warn / error