Skip to main content

rusty_esp_signal_esp/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2#![deny(unsafe_code)]
3//! `rusty_esp_signal-esp` — chip backends for `rusty_esp_signal`.
4//!
5//! This is the **wrap** crate of the package: where the silicon must be
6//! touched, it calls the esp-rs HAL (Track B, `esp-hal` + `esp-radio`) or
7//! ESP-IDF (Track A, `esp-idf`) and feeds bytes into the pure core's state
8//! machines. Nothing product- or protocol-specific lives here; that is the
9//! core's job. This crate ingests the signal; the core interprets it.
10//!
11//! ## Track B is compiled by a firmware, never on its own
12//!
13//! esp-hal refuses to build unless exactly one chip feature (`esp32c6`, …) is
14//! set, and a library that selected one would fix the chip for every consumer.
15//! So the chip is chosen by the firmware binary, which turns on this crate's
16//! `esp-hal` feature and its own `esp-hal`/`esp-radio` chip feature; cargo's
17//! feature unification then compiles the backends below for that chip. The
18//! host build and the workspace tests use **no** feature here and see only the
19//! [`Track`] marker, so they never need a chip.
20//!
21//! ## The radios
22//!
23//! Each backend feeds one core module ([`rusty_esp_signal_core`]):
24//!
25//! - [`hal::rng`] — the hardware TRNG behind the core's `Rng` seam, for device
26//!   keys and session ephemerals.
27//! - [`hal::link`] — the ESP-NOW datagram transport under the mID-authenticated
28//!   `link::Session`, plus the handshake driven over it.
29//! - [`hal::csi`] — a Wi-Fi CSI frame borrowed into `radar::csi::CsiFrame`;
30//!   `idf::csi` (feature `esp-idf-csi`) is its Track A twin, a callback on
31//!   ESP-IDF's Wi-Fi task parked into a ring the sketch drains. The ring and
32//!   the buffer's ingest are [`csi_queue`], compiled on the host and tested
33//!   there, because a callback cannot be tested on a board.
34//! - [`hal::ld2410`] — a UART reader feeding `radar::ld2410::Parser`.
35//! - [`hal::station`] — Wi-Fi station events driving `wifi::StationPolicy`.
36//! - [`lora`] (feature `lora`) — `lora::Params` mapped to `lora-phy`
37//!   modulation and packet parameters, and the P2P link over them.
38//! - [`ble`] (feature `ble`) — a `trouble-host` GATT server built from the
39//!   core's `ble::GATT_TABLE`.
40//!
41//! The last two touch no esp crate: they are generic over the modem and the
42//! HCI controller, so a firmware can take either without the radio stack.
43
44#[cfg(feature = "alloc")]
45extern crate alloc;
46
47#[cfg(all(feature = "esp-hal", feature = "esp-idf"))]
48compile_error!("enable exactly one track: `esp-hal` (no_std) or `esp-idf` (std)");
49
50pub use rusty_esp_signal_core as core_crate;
51
52/// Which track this build of the backend crate was compiled for.
53#[derive(Debug, Clone, Copy, PartialEq, Eq)]
54pub enum Track {
55    /// No chip backend compiled in: host build, traits only.
56    Host,
57    /// Track B — bare metal, esp-hal + esp-radio + Embassy.
58    EspHal,
59    /// Track A — std on ESP-IDF.
60    EspIdf,
61}
62
63/// The track this crate was built with.
64pub const TRACK: Track = if cfg!(feature = "esp-hal") {
65    Track::EspHal
66} else if cfg!(feature = "esp-idf") {
67    Track::EspIdf
68} else {
69    Track::Host
70};
71
72pub mod csi_queue;
73
74#[cfg(feature = "esp-hal")]
75pub mod hal;
76
77#[cfg(feature = "lora")]
78pub mod lora;
79
80#[cfg(feature = "ble")]
81pub mod ble;
82
83#[cfg(feature = "esp-idf")]
84pub mod idf;