Data struct and behaviour for working with Z-Wave commands
Summary
Callbacks
Encode the command parameters
Encode the command parameters
Returns true if the report is a good match for the get command. This is useful for commands like Version Command Class Get, which can be sent in rapid succession during a device interview, which can lead to reports getting matched back to the wrong get.
Validate the command's parameters.
Functions
Returns true if the param exists in the command's parameter list.
Create a command struct from the given spec and parameters.
Get the command param value out the params list
Just like param/3 but will raise if the the param is not in the param list
Put the param value into the params list, updating pervious value if there is one
Encode the Command.t() into it's binary representation
Validate a command's parameters according to the command spec.
Types
@type params() :: Keyword.t()
Command-specific payload parameters.
@type t() :: %Grizzly.ZWave.Command{ command_byte: byte() | nil, command_class: atom(), name: atom(), params: params() }
Command struct
:name- the name of the command:command_class- the command class module for the command:command_byte- the byte representation of the command:params- the parameters for the command as outlined by the Z-Wave specification:spec- the command spec as defined in Grizzly.ZWave.Commands
Callbacks
@callback decode_params(Grizzly.ZWave.CommandSpec.t(), binary()) :: {:ok, keyword()} | {:error, Grizzly.ZWave.DecodeError.t()}
Encode the command parameters
@callback encode_params(Grizzly.ZWave.CommandSpec.t(), t()) :: binary()
Encode the command parameters
Returns true if the report is a good match for the get command. This is useful for commands like Version Command Class Get, which can be sent in rapid succession during a device interview, which can lead to reports getting matched back to the wrong get.
This is an optional callback. If not implemented, command handlers will assume true.
@callback validate_params(Grizzly.ZWave.CommandSpec.t(), params :: keyword()) :: {:ok, validated_params :: keyword()} | {:error, reason :: any()}
Validate the command's parameters.
The callback should return {:ok, validated_params} if the parameters are valid,
or {:error, reason} if they are not. Implementers may modify the parameters
during validation (e.g., setting defaults).
Functions
Returns true if the param exists in the command's parameter list.
@spec new(Grizzly.ZWave.CommandSpec.t(), params :: keyword()) :: {:ok, t()} | {:error, :unknown_command}
Create a command struct from the given spec and parameters.
Get the command param value out the params list
Just like param/3 but will raise if the the param is not in the param list
Put the param value into the params list, updating pervious value if there is one
Encode the Command.t() into it's binary representation
Validate a command's parameters according to the command spec.