View Source Jeff.MFG.Encoder protocol (jeff v0.5.0)

The Jeff.MFG.Encoder protocol converts an Elixir data structure into an osdp_MFG command.

example

Example

defmodule InputDisable do
  defstruct input_number: nil, duration: nil

  defimpl Jeff.MFG.Encoder do
    def vendor_code(_), do: 0xC0FFEE

    def encode(command) do
      <<command.input_number::8, duration::16>>
    end
  end
end

Jeff.send_command(acu, address, %InputDisable{input_number: 1, duration: 5000})

Link to this section Summary

Functions

Encodes the given command as a binary.

Returns the 3-byte vendor code associated with the command.

Link to this section Types

Link to this section Functions

@spec encode(t()) :: binary()

Encodes the given command as a binary.

@spec vendor_code(t()) :: Jeff.vendor_code()

Returns the 3-byte vendor code associated with the command.