kei no_std Library
The kei library (packages/kei/) is a #![no_std] Rust crate that provides the shared contract between embassy-based sensor nodes and the gateway broker.
What it provides
- Wire protocol (kei::wire) — compact binary framing (magic + length + type + payload + CRC16) for UART/USB-CDC/SPI. Includes Node (sensor side) and Gateway (broker side) high-level APIs.
- Manifest schema (kei::manifest) — hardware descriptions: register maps, alarm rules, station configs, scale transforms (Linear / Table interpolation / Polynomial).
- HAL traits (kei::hal) — Transport, AsyncTransport, AddressedTransport — embassy-implementable abstractions.
- Protocol type identifiers (kei::codec) — ProtocolKind enum and ProtocolFrame opaque container.
Quick start
bash
1
2
3
4
QEMU demo (Cortex-M4)
The packages/kei/qemu-mps2/ directory contains a bare-metal firmware that runs under QEMU's mps2-an386 machine (Cortex-M4) and demonstrates the wire protocol end-to-end.
bash
1
2
3
4
5
A host-side gateway (examples/host_gateway.rs) decodes the wire frames:
bash
1
2
|
Using kei in your embassy project
Add to your Cargo.toml:
toml
1
2
[dependencies]
kei = { git = "https://github.com/celestia-island/kei.git", branch = "master", default-features = false, features = ["wire", "manifest", "hal"] }
Implement Transport for your UART, then use Node:
rust
1
2
3
4
5
6
use ;
let mut node = new; // station_id = 1
loop