Reference architecture
The runtime runs inside your ESP-IDF product. Your firmware runs the product; ESPectre runs the sensing.
Who does what
Product lifecycle
Boot, Wi-Fi setup and connection, storage, updates, logging, UI, and what happens when motion changes.
Sensing lifecycle
CSI capture and filtering, calibration, detection, readiness, state snapshots, diagnostics, and events.
One controller and one listener
RuntimeFrontendController takes configuration and commands. IRuntimeListener receives state changes and errors.
Lifecycle and tasks
setup(listener)prepare CSI captureloop()deliver eventsshutdown()release runtimeCreate the default Wi-Fi station and event loop first. If you can, call setup() before connecting to Wi-Fi, so the runtime can configure the radio for CSI when the station starts. Call setup(), loop(), the controls, and shutdown() from one task. Listener callbacks run on that same task and must return quickly; hand network publishing, flash writes, and other blocking work to another task.
If setup() fails, nothing is configured, so you can fix the configuration and retry. Controls return false when a value is invalid, a feature is unavailable, or the change is refused. Errors that happen later arrive through on_runtime_fault().
Three-layer architecture
Dependencies go one way: frontend → runtime → core. A product usually replaces the frontend and reuses the other two layers.
runtime/esp_idf/.Runtime data flow
espectre_protocol_sdk.h to speak the ESPectre Protocol over your own transport, espectre_services_sdk.h for commands, Direct HTTP, discovery, provisioning, and startup helpers, and espectre_mqtt_sdk.h for MQTT. Enable the source groups your firmware needs, or plug in your own services through the same interfaces.The SDK's provisioning service stores Wi-Fi credentials; your firmware chooses how the user enters them. The Improv Serial and update code used by the reference firmware is not part of the SDK.
esp_log, or anything else. Without a sink, the SDK logs nothing.Extending the source tree or porting another platform
Where new code belongs
| If the code… | Put it in… |
|---|---|
| Changes CSI processing or detector behavior | core/, with matching Python behavior |
| Defines shared lifecycle, events, snapshots, or transport rules | runtime/ |
| Calls ESP-IDF, FreeRTOS, Wi-Fi, NVS, or lwIP | runtime/esp_idf/ |
| Connects sensing to a protocol, ecosystem, or product UI | frontend/ |
Building a runtime for another platform
A port builds on the shared core: it feeds CSI in the expected format, keeps the same timing and readiness behavior, and sends IRuntimeListener events from its own task. The runtime behind RuntimeFrontendController is internal to ESP-IDF, so a new platform brings its own runtime and controller.