Skip to main content

Crate zwave_cc

Crate zwave_cc 

Source
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 crc crate’s CRC_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.
ParseError
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.
ParseErrorKind
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 n of the mask is value n + offset.
decode_cc_list
Decodes a command class list (two-byte ids from 0xF1), stopping at the 0xEF mark that separates supported from controlled classes.
decode_duration
Decodes a duration byte: None for unknown (0xFE) or reserved values. 0 is instantly, up to 0x7F seconds, 0x80..=0xFD minutes.
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). None means “device default” (0xFF).
write_sized
Writes v as a big-endian integer of size bytes (0, 1, 2 or 4).