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 evernight gateway broker.

What it provides

Quick start

cd packages/kei
cargo test --all-features              # 20 tests
cargo bench --bench wire_bench         # criterion benchmarks
cargo run --example host_demo          # host-side wire protocol demo

QEMU demo (Cortex-M4)

The examples/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.

cd examples/qemu-mps2
cargo build --release --target thumbv7em-none-eabi
qemu-system-arm -M mps2-an386 -cpu cortex-m4 -m 16M \
    -display none -serial stdio \
    -kernel target/thumbv7em-none-eabi/release/kei-qemu-mps2

A host-side gateway (examples/host_gateway.rs) decodes the wire frames:

cargo build --example host_gateway --target x86_64-unknown-linux-gnu
qemu-system-arm ... | target/.../debug/examples/host_gateway

Using kei in your embassy project

Add to your Cargo.toml:

[dependencies]
kei = { git = "https://github.com/celestia-island/kei.git", branch = "dev", default-features = false, features = ["wire", "manifest", "hal"] }

Implement Transport for your UART, then use Node:

use kei::wire::{Node, Request};
let mut node = Node::new(your_uart_transport, 1); // station_id = 1
loop {
    let req = node.poll(&mut sensor);
    // handle req, send telemetry back
}