apis-saltans-aps
APS layer frame definitions and utilities for Zigbee.
This crate models the Zigbee APS frame structures (data, command, and acknowledgment paths), including control fields, delivery modes, destinations, and extended header metadata.
Status
This crate is under active development.
What This Crate Provides
- APS frame control primitives:
ControlFrameTypeDeliveryModeTxOptions(APSDE-DATA transmission options)
- Addressing and destination modeling:
Destination(unicast, broadcast endpoint, group)Broadcast(well-known Zigbee broadcast addresses)
- Frame structures:
Data<T>(generic APS data frame)Unicast<T>(typed unicast variant)Command<T>(APS command frame)Acknowledgement(APS ACK frame)
- Defragmentation:
Assembler(stateful APS data-frame reassembly)
- Extended header support:
ExtendedExtendedControlFragmentationAckFmt
Top-level re-exports are available from apis-saltans-aps directly.
Crate Layout
frame::control: APS frame control bitfields and decoding helpersframe::data: APS data frame headers and payload wrappersframe::command: APS command frame/header typesframe::acknowledgement: APS acknowledgment frame and ack formatframe::extended: extended header fields and fragmentationframe::data::defragmentation: stateful reassembly of fragmented APS data framesbroadcast: Zigbee network broadcast addressestx_options: APSDE-DATA transmission-option bitflags
Defragmentation
Assembler consumes zb_nwk::Envelope<Data<bytes::Bytes>> values.
It uses the NWK source and APS counter to identify an in-progress fragmented
transaction. Bytes keeps raw APS payload handling cheap when frames are passed
between queues or reassembled from multiple fragments.
Behavior:
- unfragmented frames are returned immediately;
- first fragments start a transaction;
- follow-up fragments are inserted by block number;
- completed frames are returned with their extended header removed;
- invalid frames and out-of-bounds fragments are dropped and return
None.
use ;
use Bytes;
use Envelope;
Serialization
This crate uses le-stream for little-endian byte encoding/decoding.
Patterns used in the API:
ToLeStreamfor serialization to iteratorsFromLeStreamfor parsing selected frame/header types
Most frame builders produce strongly typed structures first, then serialize via to_le_stream().
Quick Start
Build and Serialize a Unicast APS Data Frame
use Unicast;
use ToLeStream;
let frame = new;
let bytes: = frame.to_le_stream.collect;
assert!;
Parse an APS Data Header
use Header;
use FromLeStream;
let raw = ;
let parsed = from_le_stream;
if let Some = parsed
Header::cluster_id() always returns the raw wire value. Use Header::cluster() when a typed
zb_core::Cluster is useful; it returns the unchanged u16 in Err when the ID is not one of the
clusters known by apis-saltans-core.
Notes on Safety APIs
Some constructors are intentionally marked unsafe (for example new_unchecked) when invariants must be enforced by the caller (header/content consistency). Prefer safe constructors unless you are explicitly rebuilding structures from validated external state.
Dependencies
Primary dependencies:
le-streambytesbitflagsnum_enum(primitive conversions for fieldless integer-representation enums)
Related Workspace Crates
apis-saltans-core: core Zigbee protocol typesapis-saltans-zcl: Zigbee Cluster Library framing and commandsapis-saltans-zdp: Zigbee Device Profile services