|
ESPectre SDK 2.8.0-280-gac7af68
Wi-Fi CSI motion sensing for ESP32 firmware
|
The recommended entry point for firmware embedding ESPectre. More...
#include <runtime_frontend_controller.h>
Public Member Functions | |
| ~RuntimeFrontendController () override | |
| Shut the runtime down on scope exit. | |
| void | set_config (const RuntimeConfig &config) |
| Stage the configuration used by the next setup(). | |
| RuntimeConfig & | config () |
| Mutable access to the staged configuration. | |
| const RuntimeConfig & | config () const |
| Read-only view of the staged configuration. | |
| const RuntimeSnapshot & | snapshot () const |
| Latest known snapshot, without querying the backend. | |
| RuntimeDiagnosticsSnapshot | diagnostics () const |
| Read backend counters without touching the cached sensing snapshot. | |
| const RuntimeCapabilities & | capabilities () const |
| What the active backend supports. | |
| bool | is_setup_complete () const |
| True between a successful setup() and the next shutdown(). | |
| bool | setup (IRuntimeListener *listener) |
| Create the backend, apply the configuration, and start sensing. | |
| void | loop () |
| Advance runtime work and deliver pending listener callbacks. | |
| void | shutdown () |
| Stop sensing and release the backend. | |
| void | set_services_armed (bool armed) |
| Gate runtime-owned services without tearing the runtime down. | |
| void | set_live_telemetry_enabled (bool enabled) |
| Enable or suppress IRuntimeListener::on_live_telemetry(). | |
| bool | services_armed () const |
| Current armed state, including before setup. | |
| void | quiesce_for_ota () |
| Quiet the runtime ahead of an OTA update. | |
| bool | set_threshold_runtime (float threshold) |
| Set the motion threshold, validating it against the active detector. | |
| bool | set_motion_hits_runtime (uint8_t motion_on_hits, uint8_t motion_off_hits) |
| Set the hit filter. | |
| bool | set_csi_traffic_mode_runtime (CsiTrafficMode mode) |
| Change the live CSI traffic ownership mode. | |
| bool | set_traffic_generator_mode_runtime (RuntimeTrafficMode mode) |
| Change the live internal traffic generator packet type. | |
| bool | set_detection_algorithm_runtime (DetectionAlgorithm algorithm) |
| Switch detector while running. | |
| bool | trigger_recalibration () |
| Restart startup calibration. | |
| bool | is_calibrating () const |
| True while the backend is calibrating. | |
The recommended entry point for firmware embedding ESPectre.
It owns the runtime backend, picks the right one from RuntimeConfig::runtime_profile, caches the latest snapshot and the discovered capabilities, and validates control calls before they reach the backend. The shipped Native and Matter frontends are thin wrappers over it.
Definition at line 66 of file runtime_frontend_controller.h.
|
override |
Shut the runtime down on scope exit.
Explicit shutdown() remains recommended.
| void espectre::RuntimeFrontendController::set_config | ( | const RuntimeConfig & | config | ) |
Stage the configuration used by the next setup().
Ignored once setup has started, so reconfiguring a running runtime means shutdown() first, or the set_*_runtime() methods for the fields that support live changes.
|
inline |
Mutable access to the staged configuration.
Provided so a frontend can adjust individual fields before setup() without rebuilding the whole struct. Writing to it after setup changes only this cached copy, not the running runtime.
Definition at line 85 of file runtime_frontend_controller.h.
|
inline |
Read-only view of the staged configuration.
Definition at line 87 of file runtime_frontend_controller.h.
|
inline |
Latest known snapshot, without querying the backend.
Refreshed automatically at setup(), by control calls, and before every listener callback is forwarded to your frontend. Use the cached snapshot for on-demand reads such as answering a status query; use the listener callbacks to react to change.
Definition at line 96 of file runtime_frontend_controller.h.
| RuntimeDiagnosticsSnapshot espectre::RuntimeFrontendController::diagnostics | ( | ) | const |
Read backend counters without touching the cached sensing snapshot.
Unlike snapshot(), this queries the backend on every call. Invoke it from an existing periodic sensing callback, not from the hot loop. Returns a zeroed snapshot before setup().
|
inline |
What the active backend supports.
Meaningful only after setup().
Gate your product surface on it rather than hardcoding: the controller already refuses capability-gated calls, and this is how you avoid exposing a control the runtime will reject.
Definition at line 112 of file runtime_frontend_controller.h.
|
inline |
True between a successful setup() and the next shutdown().
Definition at line 114 of file runtime_frontend_controller.h.
| bool espectre::RuntimeFrontendController::setup | ( | IRuntimeListener * | listener | ) |
Create the backend, apply the configuration, and start sensing.
Calling it twice is a no-op that returns true.
| listener | Event sink, or nullptr for none. Not owned; it must outlive the controller. |
| void espectre::RuntimeFrontendController::loop | ( | ) |
Advance runtime work and deliver pending listener callbacks.
Call it continuously from your loop task. Safe, and a no-op, before setup.
| void espectre::RuntimeFrontendController::shutdown | ( | ) |
Stop sensing and release the backend.
Safe before setup and to repeat.
| void espectre::RuntimeFrontendController::set_services_armed | ( | bool | armed | ) |
Gate runtime-owned services without tearing the runtime down.
Sticky: the value is remembered and reapplied to the backend created by a later setup(). Matter uses it to stay silent until commissioning. Frontends use it to pause CSI without dropping Wi-Fi.
| void espectre::RuntimeFrontendController::set_live_telemetry_enabled | ( | bool | enabled | ) |
Enable or suppress IRuntimeListener::on_live_telemetry().
Also sticky.
|
inline |
Current armed state, including before setup.
Definition at line 149 of file runtime_frontend_controller.h.
| void espectre::RuntimeFrontendController::quiesce_for_ota | ( | ) |
Quiet the runtime ahead of an OTA update.
Drops live telemetry and disarms services so the download is not competing with CSI capture and traffic generation. Reverse it with set_services_armed(true) if the update is abandoned.
| bool espectre::RuntimeFrontendController::set_threshold_runtime | ( | float | threshold | ) |
Set the motion threshold, validating it against the active detector.
| threshold | Value on the 0..1 metric scale. |
| bool espectre::RuntimeFrontendController::set_motion_hits_runtime | ( | uint8_t | motion_on_hits, |
| uint8_t | motion_off_hits ) |
Set the hit filter.
| motion_on_hits | Consecutive above-threshold evaluations to report motion (1..20). Higher trades latency for fewer false positives. |
| motion_off_hits | Consecutive below-threshold evaluations to clear it (1..20). |
| bool espectre::RuntimeFrontendController::set_csi_traffic_mode_runtime | ( | CsiTrafficMode | mode | ) |
Change the live CSI traffic ownership mode.
| bool espectre::RuntimeFrontendController::set_traffic_generator_mode_runtime | ( | RuntimeTrafficMode | mode | ) |
Change the live internal traffic generator packet type.
| bool espectre::RuntimeFrontendController::set_detection_algorithm_runtime | ( | DetectionAlgorithm | algorithm | ) |
Switch detector while running.
The threshold follows the detector: the controller adopts the new detector's threshold rather than carrying the old value across scales.
| bool espectre::RuntimeFrontendController::trigger_recalibration | ( | ) |
Restart startup calibration.
| bool espectre::RuntimeFrontendController::is_calibrating | ( | ) | const |
True while the backend is calibrating.
False before setup.