One-page cheat sheet for the zigbee-rs public API, organized by crate.
Type Description
IeeeAddress = [u8; 8]64-bit IEEE/EUI-64 address
ShortAddress(u16)16-bit network address. Constants: BROADCAST (0xFFFF), UNASSIGNED (0xFFFE), COORDINATOR (0x0000)
PanId(u16)PAN identifier. Constant: BROADCAST (0xFFFF)
MacAddressEither Short(PanId, ShortAddress) or Extended(PanId, IeeeAddress)
Channel2.4 GHz channels Ch11–Ch26. from_number(u8), number() → u8
ChannelMask(u32)Bitmask of channels. Constants: ALL_2_4GHZ (0x07FFF800), PREFERRED. Methods: contains(Channel), iter()
TxPower(i8)Transmit power in dBm
Method Description
mlme_scan(MlmeScanRequest) → Result<MlmeScanConfirm>Active/energy/orphan scan
mlme_associate(MlmeAssociateRequest) → Result<MlmeAssociateConfirm>Associate with coordinator
mlme_associate_response(MlmeAssociateResponse) → Result<()>Respond to association request (ZC/ZR)
mlme_disassociate(MlmeDisassociateRequest) → Result<()>Leave the network
mlme_reset(set_default_pib: bool) → Result<()>Reset MAC sublayer
mlme_start(MlmeStartRequest) → Result<()>Start network as coordinator
mlme_get(PibAttribute) → Result<PibValue>Read a PIB attribute
mlme_set(PibAttribute, PibValue) → Result<()>Write a PIB attribute
mlme_poll() → Result<Option<MacFrame>>Poll parent for pending data (ZED)
mcps_data(McpsDataRequest) → Result<McpsDataConfirm>Transmit a MAC frame
mcps_data_indication() → Result<McpsDataIndication>Receive a MAC frame
capabilities() → MacCapabilitiesQuery radio capabilities
Field Type Description
coordinatorboolCan act as PAN coordinator
routerboolCan route frames
hardware_securityboolHardware AES-CCM* support
max_payloadu16Max MAC payload bytes
tx_power_min / tx_power_maxTxPowerTX power range
NoBeacon, InvalidParameter, RadioError, ChannelAccessFailure, NoAck, FrameTooLong, Unsupported, SecurityError, TransactionOverflow, TransactionExpired, ScanInProgress, TrackingOff, AssociationDenied, PanAtCapacity, Other, NoData
Feature-gated MAC implementations: esp (ESP32-C6/H2), nrf (nRF52840/52833), bl702, cc2340, telink, phy6222, mock (testing)
Method Description
new(mac, device_type) → SelfCreate NWK layer
set_rx_on_when_idle(bool)Set RX-on-when-idle (router=true, sleepy ZED=false)
rx_on_when_idle() → boolQuery RX-on-when-idle
nib() → &NibRead Network Information Base
nib_mut() → &mut NibWrite Network Information Base
is_joined() → boolWhether device has joined a network
device_type() → DeviceTypeCoordinator / Router / EndDevice
mac() → &M / mac_mut() → &mut MAccess underlying MAC driver
security() → &NwkSecurityRead network security state
security_mut() → &mut NwkSecurityWrite network security state
neighbor_table() → &NeighborTableRead neighbor table
routing_table() → &RoutingTableRead routing table
find_short_by_ieee(&IeeeAddress) → Option<ShortAddress>Resolve IEEE → short address
find_ieee_by_short(ShortAddress) → Option<IeeeAddress>Resolve short → IEEE address
update_neighbor_address(ShortAddress, IeeeAddress)Update address mapping in neighbor table
Coordinator, Router, EndDevice
Constant Value Description
ZDO_ENDPOINT0x00ZDO endpoint
MIN_APP_ENDPOINT0x01First application endpoint
MAX_APP_ENDPOINT0xF0Last application endpoint
BROADCAST_ENDPOINT0xFFBroadcast to all endpoints
PROFILE_HOME_AUTOMATION0x0104HA profile ID
PROFILE_SMART_ENERGY0x0109SE profile ID
PROFILE_ZLL0xC05EZLL profile ID
Method Description
new(nwk) → SelfCreate APS layer wrapping NWK
next_aps_counter() → u8Get next APS frame counter
is_aps_duplicate(src_addr, counter) → boolDetect duplicate APS frames
age_dup_table()Age out old duplicate entries
register_ack_pending(counter, dst, frame) → Option<usize>Track pending APS ACK
confirm_ack(src, counter) → boolConfirm ACK received
take_ack_status(counter) → Option<bool>Consume ACK status
age_ack_table() → Vec<Vec<u8>>Age ACKs, return retransmit candidates
nwk() → &NwkLayer<M> / nwk_mut()Access NWK layer
aib() → &Aib / aib_mut()Access APS Information Base
binding_table() → &BindingTable / binding_table_mut()Access binding table
group_table() → &GroupTable / group_table_mut()Access group table
security() → &ApsSecurity / security_mut()Access APS security
fragment_rx() → &FragmentReassembly / fragment_rx_mut()Access fragment reassembly
Method Description
new() → SelfCreate empty binding table
add(entry) → Result<(), BindingEntry>Add a binding entry
remove(src, ep, cluster, dst) → boolRemove a binding
find_by_source(src, ep, cluster) → Iterator<&BindingEntry>Find bindings for a source
find_by_cluster(cluster_id) → Iterator<&BindingEntry>Find bindings for a cluster
find_by_endpoint(ep) → Iterator<&BindingEntry>Find bindings for an endpoint
entries() → &[BindingEntry]All entries
len(), is_empty(), is_full(), clear()Capacity management
Constructor Description
unicast(src_addr, src_ep, cluster, dst_addr, dst_ep) → SelfUnicast binding
group(src_addr, src_ep, cluster, group_addr) → SelfGroup binding
Method Description
new() → SelfCreate empty group table
add_group(group_addr, endpoint) → boolAdd endpoint to group
remove_group(group_addr, endpoint) → boolRemove endpoint from group
remove_all_groups(endpoint)Remove endpoint from all groups
find(group_addr) → Option<&GroupEntry>Find a group entry
is_member(group_addr, endpoint) → boolCheck group membership
groups() → &[GroupEntry]All groups
Method Description
simple_desc_req(dst, ep) → Result<SimpleDescriptor>Query endpoint descriptor
active_ep_req(dst) → Result<Vec<u8>>Query active endpoints
match_desc_req(dst, profile, in_clusters, out_clusters) → Result<Vec<u8>>Find matching endpoints
device_annce(nwk_addr, ieee_addr) → Result<()>Announce device on network
Method Description
bind_req(dst, entry) → Result<()>Create remote binding
unbind_req(dst, entry) → Result<()>Remove remote binding
Method Description
mgmt_permit_joining_req(dst, duration, tc) → Result<()>Open/close joining
nlme_network_discovery(mask, duration) → Result<Vec<NetworkDescriptor>>Scan for networks
nlme_join(network) → Result<ShortAddress>Join a network
nlme_rejoin(network) → Result<ShortAddress>Rejoin a network
nlme_network_formation(mask, duration) → Result<()>Form a new network (ZC)
nlme_permit_joining(duration) → Result<()>Set local permit join
nlme_start_router() → Result<()>Start router functionality
nlme_reset(warm_start) → Result<()>Reset network layer
Method Description
register_endpoint(SimpleDescriptor) → Result<()>Register a local endpoint
endpoints() → &[SimpleDescriptor]List registered endpoints
find_endpoint(ep) → Option<&SimpleDescriptor>Find endpoint descriptor
set_node_descriptor(NodeDescriptor) / node_descriptor()Node descriptor access
set_power_descriptor(PowerDescriptor) / power_descriptor()Power descriptor access
set_local_nwk_addr(ShortAddress) / local_nwk_addr()Local network address
set_local_ieee_addr(IeeeAddress) / local_ieee_addr()Local IEEE address
Method Description
new(aps) → SelfCreate ZDO layer wrapping APS
next_seq() → u8Next ZDP sequence number
deliver_response(cluster, tsn, payload) → boolDeliver a ZDP response
aps() → &ApsLayer<M> / aps_mut()Access APS layer
nwk() → &NwkLayer<M> / nwk_mut()Access NWK layer
Method Description
new(zdo) → SelfCreate BDB layer wrapping ZDO
zdo() → &ZdoLayer<M> / zdo_mut()Access ZDO layer
attributes() → &BdbAttributes / attributes_mut()BDB commissioning attributes
state() → &BdbStateCurrent BDB state machine state
is_on_network() → boolWhether device has joined
reset_attributes()Reset BDB attributes to defaults
Success, InProgress, NotOnNetwork, NotPermitted, NoScanResponse, FormationFailure, SteeringFailure, NoIdentifyResponse, BindingTableFull, TouchlinkFailure, TargetFailure, Timeout
#![allow(unused)]
fn main() {
pub trait Cluster {
fn cluster_id(&self) -> ClusterId;
fn handle_command(&mut self, cmd_id: CommandId, payload: &[u8])
-> Result<Vec<u8, 64>, ZclStatus>;
fn attributes(&self) -> &dyn AttributeStoreAccess;
fn attributes_mut(&mut self) -> &mut dyn AttributeStoreMutAccess;
fn received_commands(&self) -> Vec<u8, 32>; // optional
fn generated_commands(&self) -> Vec<u8, 32>; // optional
}
}
Method Description
get(AttributeId) → Option<&ZclValue>Read attribute value
set(AttributeId, ZclValue) → Result<()>Write attribute with validation
set_raw(AttributeId, ZclValue) → Result<()>Write attribute without validation
find(AttributeId) → Option<&AttributeDefinition>Find attribute metadata
all_ids() → Vec<AttributeId, 32>List all attribute IDs
ID Constant Name
0x0000BASICBasic
0x0001POWER_CONFIGPower Configuration
0x0003IDENTIFYIdentify
0x0004GROUPSGroups
0x0005SCENESScenes
0x0006ON_OFFOn/Off
0x0008LEVEL_CONTROLLevel Control
0x0019OTA_UPGRADEOTA Upgrade
0x0020POLL_CONTROLPoll Control
0x0300COLOR_CONTROLColor Control
0x0402TEMPERATURETemperature Measurement
0x0405HUMIDITYRelative Humidity
0x0406OCCUPANCYOccupancy Sensing
0x0500IAS_ZONEIAS Zone
0x0702METERINGMetering
0x0B04ELECTRICAL_MEASUREMENTElectrical Measurement
See ZCL Cluster Table for the complete list of all 46 clusters.
Method Description
new() → SelfCreate empty engine
configure(ReportingConfig) → Result<()>Add/update a reporting configuration
configure_for_cluster(ep, cluster, config) → Result<()>Configure for specific cluster
tick(elapsed_secs)Advance timers
check_and_report(store) → Option<ReportAttributes>Check if any reports are due
check_and_report_cluster(ep, cluster, store) → Option<ReportAttributes>Check for specific cluster
get_config(ep, cluster, direction, attr) → Option<&ReportingConfig>Read reporting config
Method Description
builder(mac) → DeviceBuilder<M>Start building a device
start() → Result<u16, StartError>Join network, returns short address
leave() → Result<()>Leave the network
factory_reset(nv)Factory reset, optionally clear NV storage
user_action(UserAction)Inject a user action (Join/Leave/Toggle/PermitJoin/FactoryReset)
Method Description
is_joined() → boolNetwork join status
short_address() → u16Current short address
channel() → u8Current channel
pan_id() → u16Current PAN ID
device_type() → DeviceTypeCoordinator/Router/EndDevice
endpoints() → &[EndpointConfig]Registered endpoints
manufacturer_name() → &strManufacturer string
model_identifier() → &strModel string
channel_mask() → ChannelMaskConfigured channel mask
sw_build_id() → &strSoftware build ID
date_code() → &strDate code
is_sleepy() → boolWhether device is a sleepy end device
Method Description
receive() → Result<McpsDataIndication>Wait for incoming frame
poll() → Result<Option<McpsDataIndication>>Poll parent (ZED)
process_incoming(indication, clusters) → Option<StackEvent>Process a received frame through the stack
send_zcl_frame(dst, dst_ep, src_ep, cluster, data) → Result<()>Send a ZCL frame
Method Description
reporting() → &ReportingEngine / reporting_mut()Access reporting engine
check_and_send_cluster_reports(ep, cluster, store) → boolCheck and transmit due reports
save_state(nv)Persist device state to NV storage
restore_state(nv) → boolRestore state from NV storage
power() → &PowerManager / power_mut()Access power manager
bdb() → &BdbLayer<M> / bdb_mut()Access BDB layer
Method Description
new(mac) → SelfCreate builder with MAC driver
device_type(DeviceType) → SelfSet device type
manufacturer(&'static str) → SelfSet manufacturer name
model(&'static str) → SelfSet model identifier
sw_build(&'static str) → SelfSet software build ID
date_code(&'static str) → SelfSet date code
channels(ChannelMask) → SelfSet channel mask
power_mode(PowerMode) → SelfSet power mode (AlwaysOn/Sleepy/DeepSleep)
endpoint(ep, profile, device_id, configure_fn) → SelfAdd an endpoint
build() → ZigbeeDevice<M>Build the device
Method Description
cluster_server(cluster_id) → SelfAdd a server cluster
cluster_client(cluster_id) → SelfAdd a client cluster
device_version(version) → SelfSet device version
Pre-configured DeviceBuilder shortcuts in zigbee_runtime::templates:
Template Description
temperature_sensor(mac)Temperature sensor (0x0402)
temperature_humidity_sensor(mac)Temp + humidity (0x0402, 0x0405)
on_off_light(mac)On/Off light (0x0006)
dimmable_light(mac)Dimmable light (0x0006, 0x0008)
color_temperature_light(mac)Color temp light (0x0006, 0x0008, 0x0300)
contact_sensor(mac)Contact sensor (IAS Zone 0x0500)
occupancy_sensor(mac)Occupancy sensor (0x0406)
smart_plug(mac)Smart plug (0x0006, 0x0B04, 0x0702)
thermostat(mac)Thermostat (0x0201)
Variant Description
Joined { short_address, channel, pan_id }Successfully joined network
LeftLeft the network
AttributeReport { src_addr, endpoint, cluster_id, attr_id }Received an attribute report
CommandReceived { src_addr, endpoint, cluster_id, command_id, seq_number, payload }Received a cluster command
CommissioningComplete { success }BDB commissioning finished
DefaultResponse { src_addr, endpoint, cluster_id, command_id, status }Received a default response
PermitJoinChanged { open }Permit join state changed
ReportSentAn attribute report was transmitted
OtaImageAvailable { version, size }OTA image available
OtaProgress { percent }OTA download progress
OtaComplete / OtaFailedOTA finished
OtaDelayedActivation { delay_secs }OTA activation delayed
FactoryResetRequestedFactory reset requested
Method Description
new(PowerMode) → SelfCreate power manager
mode() → PowerModeCurrent power mode
record_activity(now_ms)Record activity to prevent premature sleep
record_poll(now_ms)Record data poll time
set_pending_tx(bool)Mark pending transmission
set_pending_reports(bool)Mark pending reports
decide(now_ms) → SleepDecisionDecide: StayAwake / LightSleep(ms) / DeepSleep(ms)
should_poll(now_ms) → boolWhether it’s time to poll parent
Variant Description
PowerMode::AlwaysOnZC/ZR — never sleep
PowerMode::Sleepy { poll_interval_ms, wake_duration_ms }ZED with periodic polling
PowerMode::DeepSleep { wake_interval_s }ZED with deep sleep cycles
SleepDecision::StayAwakeDon’t sleep
SleepDecision::LightSleep(ms)Light sleep for N ms
SleepDecision::DeepSleep(ms)Deep sleep for N ms
Join, Leave, Toggle, PermitJoin(u8), FactoryReset
Re-exports all sub-crates and provides high-level coordinator/router/trust center components.
#![allow(unused)]
fn main() {
pub use zigbee_runtime::ZigbeeDevice;
pub use zigbee_types::{Channel, ChannelMask, IeeeAddress, MacAddress, PanId, ShortAddress};
pub use zigbee_aps as aps;
pub use zigbee_bdb as bdb;
pub use zigbee_mac as mac;
pub use zigbee_nwk as nwk;
pub use zigbee_runtime as runtime;
pub use zigbee_types as types;
pub use zigbee_zcl as zcl;
pub use zigbee_zdo as zdo;
}
Method Description
new(CoordinatorConfig) → SelfCreate coordinator
generate_network_key()Generate random 128-bit network key
network_key() → &[u8; 16] / set_network_key(key)Network key access
allocate_address() → ShortAddressAllocate address for joining device
can_accept_child() → boolCheck child capacity
is_formed() → bool / mark_formed()Network formation state
next_frame_counter() → u32Next NWK frame counter
Field Type Description
channel_maskChannelMaskChannels to form on
extended_pan_idIeeeAddressExtended PAN ID
centralized_securityboolUse centralized Trust Center
require_install_codesboolRequire install codes for joining
max_childrenu8Max direct children
max_depthu8Max network depth
initial_permit_join_durationu8Permit join duration at startup (seconds)
Method Description
new(RouterConfig) → SelfCreate router
add_child(ieee, short, is_ffd, rx_on) → Result<()>Register a child device
remove_child(addr)Remove a child
find_child(addr) → Option<&ChildDevice>Find child by short address
find_child_by_ieee(&ieee) → Option<&ChildDevice>Find child by IEEE address
is_child(addr) → boolCheck if address is a child
can_accept_child() → boolCheck capacity
age_children(elapsed_seconds)Age children, detect timeouts
child_activity(addr)Record child activity
child_count() → u8Number of children
is_started() → bool / mark_started()Router started state
Method Description
new(network_key) → SelfCreate Trust Center with network key
network_key() → &[u8; 16] / set_network_key(key)Network key access
key_seq_number() → u8Current key sequence number
set_require_install_codes(bool)Enable/disable install code requirement
link_key_for_device(&ieee) → [u8; 16]Get link key for device
set_link_key(ieee, key, TcKeyType) → Result<()>Set device-specific link key
remove_link_key(&ieee)Remove a link key
mark_key_verified(&ieee)Mark key as verified
should_accept_join(&ieee) → boolCheck join policy for device
update_frame_counter(&ieee, counter) → boolUpdate incoming frame counter
next_frame_counter() → u32Next outgoing frame counter
device_count() → usizeNumber of registered devices