Skip to main content

hdds_micro/
lib.rs

1// SPDX-License-Identifier: Apache-2.0 OR MIT
2// Copyright (c) 2025-2026 naskel.com
3
4//! # HDDS Micro - Embedded DDS for Microcontrollers
5//!
6//! A `no_std` implementation of DDS (Data Distribution Service) for resource-constrained
7//! embedded systems such as ESP32, RP2040, and STM32 microcontrollers.
8//!
9//! ## Design Constraints
10//!
11//! - **Flash**: < 100 KB (target: 60-80 KB)
12//! - **RAM**: < 50 KB (target: 30-40 KB)
13//! - **No heap allocations** in core (const generics for fixed buffers)
14//! - **No floating point** (embedded-friendly)
15//! - **`no_std` compatible**
16//!
17//! ## Architecture
18//!
19//! ```text
20//! +-----------------------------------------+
21//! |  Application (User Code)                |
22//! +-----------------------------------------+
23//!           v                    ^
24//! +-----------------------------------------+
25//! |  MicroParticipant / MicroWriter / Reader|
26//! +-----------------------------------------+
27//!           v                    ^
28//! +-----------------------------------------+
29//! |  RTPS Lite (Header, Submessages)        |
30//! +-----------------------------------------+
31//!           v                    ^
32//! +-----------------------------------------+
33//! |  CDR Micro (Encoder/Decoder)            |
34//! +-----------------------------------------+
35//!           v                    ^
36//! +-----------------------------------------+
37//! |  Transport (WiFi UDP / LoRa / Serial)   |
38//! +-----------------------------------------+
39//! ```
40//!
41//! ## Feature Flags
42//!
43//! - `esp32` -- ESP32-specific optimizations
44//! - `rp2040` -- RP2040-specific optimizations
45//! - `stm32` -- STM32-specific optimizations
46//! - `wifi` -- `WiFi` UDP transport
47//! - `lora` -- `LoRa` transport (SX1276/78)
48//! - `alloc` -- Enable heap allocator
49//! - `std` -- Enable std (for host testing)
50
51#![cfg_attr(not(feature = "std"), no_std)]
52#![deny(unsafe_code)]
53#![warn(missing_docs)]
54
55#[cfg(feature = "alloc")]
56extern crate alloc;
57
58/// RTPS Lite protocol implementation (types, header, submessages)
59pub mod rtps;
60
61/// CDR Micro encoder/decoder (fixed buffer, no allocations)
62pub mod cdr;
63
64/// Transport abstraction for WiFi, LoRa, Serial
65pub mod transport;
66
67/// Core DDS structs (MicroParticipant, MicroWriter, MicroReader)
68pub mod core;
69
70/// Error types for HDDS Micro
71pub mod error;
72
73/// LoRa <-> WiFi/UDP Gateway (requires `std` feature)
74#[cfg(feature = "std")]
75pub mod gateway;
76
77// Re-exports for convenience
78pub use crate::core::{MicroParticipant, MicroReader, MicroWriter};
79pub use crate::error::{Error, Result};
80pub use crate::rtps::{EntityId, GuidPrefix, SequenceNumber};
81pub use crate::transport::Transport;
82
83/// Maximum packet size (MTU) for embedded environments
84pub const MAX_PACKET_SIZE: usize = 1024;
85
86/// Maximum number of samples in history cache
87pub const MAX_HISTORY_DEPTH: usize = 16;
88
89/// Version of HDDS Micro
90pub const VERSION: &str = env!("CARGO_PKG_VERSION");