Skip to main content

cr1140_sdk/
lib.rs

1// SPDX-License-Identifier: GPL-3.0-only
2//! CR1140 SDK — app-building conveniences layered on top of `cr1140-hal`.
3//!
4//! This crate is deliberately UI-framework agnostic (no Slint, no rendering): it
5//! provides the "batteries" a native CR1140 application needs regardless of how
6//! it draws — keypad LED effects, system telemetry, and device/network info.
7//!
8//! - [`led`] — RGB keypad-LED animation modes and a [`led::LedDriver`].
9//! - [`metrics`] — generic Linux telemetry (CPU, memory, load, uptime) plus a
10//!   [`metrics::Telemetry`] collector returning an aggregated [`metrics::Snapshot`].
11//! - [`device`] — device & OS identity and network state.
12//! - [`guard`] — [`guard::ShutdownGuard`]: restore backlight/LED on exit (RAII),
13//!   with opt-in SIGINT/SIGTERM handling for standalone binaries.
14//! - [`config`] — atomic [`config::Store`] persistence for the p2 overlay
15//!   (`/home/cds-apps`); enabled by the default `config` feature.
16//! - [`retain`] — reflash-surviving [`retain::Store`] on the SPI EEPROM (A/B +
17//!   CRC32, `postcard`); enabled by the default `retain` feature.
18//! - [`net`] — host network-config apply via `nmcli` ([`net::apply`]); off by
19//!   default behind the `net` feature.
20//!
21//! Errors from fallible operations surface as [`SdkError`]. This crate is a guest
22//! under host executors (ROS 2 / Apex / Taktora): it logs through the `tracing`
23//! facade without installing a subscriber, and never grabs signals by default.
24
25#[cfg(feature = "config")]
26pub mod config;
27pub mod device;
28pub mod error;
29pub mod guard;
30pub mod led;
31pub mod metrics;
32#[cfg(feature = "net")]
33pub mod net;
34#[cfg(feature = "retain")]
35pub mod retain;
36
37#[cfg(feature = "config")]
38pub use config::{Store, DEFAULT_APP_DIR};
39pub use error::{SdkError, SdkResult};
40pub use guard::{ShutdownFlag, ShutdownGuard};
41pub use metrics::{MemInfo, Snapshot, Telemetry};
42#[cfg(feature = "retain")]
43pub use retain::Store as RetainStore;