Expand description
§zwave-cc
Z-Wave command classes, generated from data definitions.
Every command class in defs/cc/*.toml becomes a module with one struct
per command (multilevel_sensor::Report, wake_up::IntervalSet, …),
a Command enum per class, and the crate-level Command that
dispatches on the class id. Parsers are generated from the same
definitions as encoders, are bounded by their input, never panic and
never use unsafe; trailing bytes from newer versions are ignored.
The sensor, meter and notification types assigned by the Z-Wave Alliance
are in tables. Transport Service segmentation and reassembly
(transport_service) and CRC-16 encapsulation (crc16) are written
by hand, because their command ids carry data bits.
use zwave_cc::{Command, multilevel_sensor};
let frame = [0x31, 0x05, 0x01, 0x22, 0x00, 0xe1];
let Command::MultilevelSensor(multilevel_sensor::Command::Report(r)) = Command::parse(&frame).unwrap() else { panic!() };
assert_eq!(r.sensor_type, 1); // air temperature
assert_eq!(r.value.to_f64(), 22.5);
assert_eq!(Command::from(r).encode(), frame);Part of zwave-bridge, maintained by Pulzar. See the user guide, the library guide and the API documentation.
License: MIT.
Modules§
- application_
status - Application Status command class (
0x22), version 1. - association
- Association command class (
0x85), version 3. - basic
- Basic command class (
0x20), version 2. - battery
- Battery command class (
0x80), version 3. - binary_
sensor - Binary Sensor command class (
0x30), version 2. - binary_
switch - Binary Switch command class (
0x25), version 2. - configuration
- Configuration command class (
0x70), version 4. - crc16
- CRC-16 Encapsulation and the CRC Z-Wave uses (CRC-CCITT, polynomial
0x1021, initial value 0x1D0F; the
crccrate’sCRC_16_SPI_FUJITSU). - crc16_
encapsulation - CRC-16 Encapsulation command class (
0x56), version 1. - device_
reset_ locally - Device Reset Locally command class (
0x5a), version 1. - firmware_
update_ md - Firmware Update Meta Data command class (
0x7a), version 8. - manufacturer_
specific - Manufacturer Specific command class (
0x72), version 2. - meter
- Meter command class (
0x32), version 6. - multi_
channel - Multi Channel command class (
0x60), version 4. - multilevel_
sensor - Multilevel Sensor command class (
0x31), version 11. - multilevel_
switch - Multilevel Switch command class (
0x26), version 4. - notification
- Notification command class (
0x71), version 8. - security
- Security 0 command class (
0x98), version 1. - security_
2 - Security 2 command class (
0x9f), version 1. - supervision
- Supervision command class (
0x6c), version 2. - tables
- The multilevel sensor, meter and notification types assigned by the
Z-Wave Alliance, generated from
defs/tables/*.toml. - transport_
service - Transport Service: frames longer than one radio frame, split into segments of a datagram with a CRC-16 each.
- version
- Version command class (
0x86), version 3. - wake_up
- Wake Up command class (
0x84), version 3. - zwave_
plus_ info - Z-Wave Plus Info command class (
0x5e), version 2.
Structs§
- CcInfo
- Metadata of a command class.
- Parse
Error - A command whose bytes do not match its definition.
- RawCommand
- A command the definitions do not cover, kept as bytes.
- Value
- A sensor, meter or battery health value: a signed integer of 1, 2 or 4 bytes with a decimal precision and a scale.
Enums§
- Command
- A parsed command of any known command class.
- Parse
Error Kind - What was wrong with a command.
Constants§
- COMMAND_
CLASSES - Every command class these definitions cover: id, name, title, version.
Functions§
- cc_info
- The metadata for a command class id.
- decode_
bitmask - Decodes a bit mask: bit
nof the mask is valuen + offset. - decode_
cc_ list - Decodes a command class list (two-byte ids from
0xF1), stopping at the0xEFmark that separates supported from controlled classes. - decode_
duration - Decodes a duration byte:
Nonefor unknown (0xFE) or reserved values. 0 is instantly, up to0x7Fseconds,0x80..=0xFDminutes. - encode_
bitmask - Encodes values as a bit mask, the shortest that holds the largest.
- encode_
cc_ list - Encodes a command class list.
- encode_
duration - Encodes a duration (rounded; capped at 126 minutes).
Nonemeans “device default” (0xFF). - write_
sized - Writes
vas a big-endian integer ofsizebytes (0, 1, 2 or 4).