Repository navigation
Signed OTA updates from GitHub releases + firmware modernization - #2
Merged
Merged
Conversation
On boot the device checks the latest GitHub release and installs it if newer. Updates are fetched over TLS (verified against the ESP-IDF CA bundle), must carry an ECDSA P-256 signature from the project key, and must contain a version marker matching the release tag so older signed images can't be republished to downgrade devices. Failed boots roll back. A release workflow builds, signs and publishes firmware for v* tags, verifying the signature against the key devices currently trust. Modernization: - pioarduino platform (Arduino-ESP32 3.3.12 / ESP-IDF 5.5) - ArduinoJson 7, ESP32Async web server, ESP-IDF MQTT client - Replace archived double-reset library with a small NVS-based one - Use the CA bundle instead of pinning ISRG Root X1; spacestate.pixelbar.nl now chains to DigiCert Global Root G2, which the old firmware rejects - Split the sketch into modules; min_spiffs partitions for 1.9MB OTA slots Credentials moved from compile-time Secrets.h into NVS (set via the config portal), since release binaries are public. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move ota::markFirmwareValid() to run immediately after WiFi connects, before checkForUpdate(). This prevents the OTA check from causing a rollback if it fails, hangs, or crashes. The rollback decision should be based on whether the firmware successfully connected to WiFi, not on whether a subsequent GitHub API call succeeded. Co-authored-by: NinjaLikesCheez <NinjaLikesCheez@users.noreply.github.com>
Change the retain flag from 0 to 1 in publishState() so the state topic is retained as documented in the README. This ensures Home Assistant and other MQTT clients see the last state immediately on connection without waiting for the next periodic publish. Co-authored-by: NinjaLikesCheez <NinjaLikesCheez@users.noreply.github.com>
spacestate.pixelbar.nl now rejects HTTP/1.0 requests with 426 Upgrade Required, so every state fetch failed. Drop useHTTP10() and read the body with getString(), which handles chunked responses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NinjaLikesCheez
marked this pull request as ready for review
November 12, 2026 11:02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The switch now checks GitHub for a newer release on every boot and installs it over the air. The firmware also moves to the current ESP32 toolchain and libraries.
This fixes a live problem: the certificate for
spacestate.pixelbar.nlwas replaced on 28 Oct 2026. It now chains to DigiCert Global Root G2, but the current firmware only trusts Let's Encrypt's ISRG Root X1. The deployed switch is therefore probably failing to submit and fetch the space state. The new firmware checks certificates against the standard Mozilla CA bundle instead of one hard-coded root, so it connects again.OTA updates
releases/latestfrom the GitHub API. If the tag is newer than the running version, it streamsfirmware.bininto the inactive OTA slot and reboots into it.devand never replace themselves.Release pipeline
release.ymlruns when avX.Y.Ztag is pushed. It builds with that version, signs the binary, checks the signature against the previous release's public key (the key devices actually trust, so key rotation is handled safely), checks the version marker, and publishes the release.build.ymlbuilds on PRs and pushes tomain.Modernization
ESP32AsyncAsyncTCP / ESPAsyncWebServer forks..inois split into modules.Security fix: no credentials in firmware
The space state API token used to be compiled in, and release binaries are public. Credentials are now stored on the device and set via the config portal;
Secrets.his optional and only used to seed them on a USB flash. The portal no longer pre-fills passwords or tokens, and the token is no longer printed to the serial log.Bug fixes
expire_aftermarked the sensor unavailable after 15 minutes. It's now re-published every 5 minutes.Before merging / deploying
scripts/generate-ota-signing-key.sh, thengh secret set OTA_SIGNING_KEY < ota_signing_key.pem, then commitkeys/ota_signing_key.pub.pem. Until then OTA stays disabled.min_spiffs.csv: the build is about 1.40 MB and doesn't fit the old 1.25 MB slots. WiFi and MQTT settings are kept. Enter the space state credentials in the portal, or providesrc/Secrets.hfor that flash.v1.0.0to publish the first signed release.Testing
-Wall -Wextra.🤖 Generated with Claude Code