ESPectre SDK 2.8.0-280-gac7af68
Wi-Fi CSI motion sensing for ESP32 firmware
Loading...
Searching...
No Matches
espectre_sdk.h
Go to the documentation of this file.
1/*
2 * ESPectre - SDK Facade
3 *
4 * Single entry point for firmware integrating the ESPectre sensing engine.
5 *
6 * Author: Francesco Pace <francesco.pace@gmail.com>
7 * SPDX-License-Identifier: GPL-3.0-only
8 * Commercial licensing available under separate agreement; see LICENSING.md.
9 */
10#pragma once
11
12/**
13 * @mainpage ESPectre SDK
14 *
15 * This reference covers the supported integration surface only. Every header
16 * listed here follows the SDK version contract; anything else in the bundle is
17 * internal and may change in any release.
18 *
19 * Start at espectre_sdk.h for the integration model, the threading contract,
20 * and a working example. The repository guide `docs/EMBEDDING.md` covers build
21 * integration, install surfaces, and release channels.
22 */
23
24/**
25 * @file espectre_sdk.h
26 * @brief The public ESPectre integration surface, in one include.
27 *
28 * ESPectre turns ordinary Wi-Fi traffic into a motion signal: it captures
29 * Channel State Information from the radio, extracts features, and reports a
30 * debounced motion state. This header is the supported entry point for
31 * firmware that embeds that engine instead of flashing one of the published
32 * frontends.
33 *
34 * @code
35 * #include "espectre_sdk.h"
36 *
37 * class ProductFrontend : public espectre::IRuntimeListener {
38 * public:
39 * bool setup() {
40 * espectre::RuntimeConfig config; // documented defaults, ready to use
41 * runtime_.set_config(config);
42 * return runtime_.setup(this);
43 * }
44 *
45 * void loop() { runtime_.loop(); }
46 *
47 * void on_motion_state_changed(const espectre::RuntimeSnapshot &snapshot) override {
48 * if (!snapshot.ready_to_publish) return;
49 * publish(snapshot.motion_state == espectre::MotionState::MOTION);
50 * }
51 *
52 * private:
53 * espectre::RuntimeFrontendController runtime_;
54 * };
55 * @endcode
56 *
57 * @section sdk_paths Two integration paths
58 *
59 * - **Full runtime (recommended).** Your firmware owns boot, provisioning,
60 * networking, OTA, and the product surface. ESPectre owns Wi-Fi CSI capture,
61 * calibration, detection, and eventing behind
62 * `espectre::RuntimeFrontendController` and `espectre::IRuntimeListener`.
63 * Requires ESP-IDF >= 5.5.
64 * - **Core-only.** Your firmware already captures CSI. Include
65 * `espectre_core_sdk.h` and drive `espectre::LightweightDetector` or
66 * `espectre::HighAccuracyDetector` directly. `runtime/esp_idf/csi_pipeline.cpp`
67 * is the reference for normalization, evaluation cadence, and hit filtering.
68 *
69 * @section sdk_threading Threading contract
70 *
71 * The control surface is single-owner. Internal bounded mailboxes protect
72 * callback-to-loop handoff, but they do not make control calls thread-safe.
73 *
74 * - Run `setup()`, `loop()`, and `shutdown()` on one task. These are the calls
75 * that build and tear down runtime state, and they are not safe to race.
76 * - Every `IRuntimeListener` callback is delivered on the caller's task: from
77 * `loop()` for sensing events, or inline on the task that invoked a control
78 * method. Work raised in the Wi-Fi CSI callback is deferred through an
79 * internal mailbox first, so no listener callback runs in interrupt or Wi-Fi
80 * driver context.
81 * - Keep callbacks bounded and non-blocking. Slow work delays `loop()` and can
82 * fill the bounded CSI mailbox, dropping incoming frames. Queue network I/O,
83 * NVS writes, and other blocking work for another task.
84 * - Call `set_*_runtime()` only from the owner task. The shipped MQTT, Direct
85 * WebSocket, and OTA adapters queue stack events and deliver their application callbacks
86 * from the frontend loop, so Native follows this rule without external locks.
87 * - Do not drive the controller from inside `on_runtime_fault()` beyond
88 * `shutdown()`.
89 *
90 * @section sdk_versioning Versioning
91 *
92 * `ESPECTRE_SDK_VERSION_STRING` and `ESPECTRE_SDK_VERSION_AT_LEAST()` identify
93 * the SDK sources you compiled against. See `runtime/espectre_sdk_version.h`
94 * for how that differs from your firmware version.
95 *
96 * @section sdk_stability Stability tiers
97 *
98 * Everything reachable from this header is the stable runtime surface and
99 * follows the SDK version contract. The opt-in `espectre_core_sdk.h` facade is
100 * the lower-level detector extension. Other headers are internal and can
101 * change in any release. `docs/EMBEDDING.md` defines the exact guarantees.
102 *
103 * @section sdk_licensing Licensing
104 *
105 * ESPectre is dual-licensed: GPLv3, or a separately offered commercial license
106 * for proprietary firmware. See `LICENSING.md`.
107 */
108
109// SDK identity.
111
112// Runtime contracts. Platform-agnostic and host-testable.
121
122// Boundary interfaces you implement to reach your own transports.
126#include "runtime/ota_service.h"
127
128// Recommended entry point. The declaration is portable; linking it requires
129// the ESP-IDF runtime sources.
Wire types and payload builders for the ESPectre Protocol.
Compile-time identity of the ESPectre SDK sources you compiled against.
Runtime configuration and the backend contract behind it.
The schema behind RuntimeConfig: enums, defaults, and valid ranges.