Packages

BACstack is a low-level Elixir implementation for the ASHRAE standard 135, BACnet - Building Automation and Controller network. In its current published state, v0.0.x, it can (only) act as a BACnet client for other BACnet devices.

Current section

Files

Jump to
bacstack lib bacnet protocol incomplete_apdu.ex
Raw

lib/bacnet/protocol/incomplete_apdu.ex

defmodule BACnet.Protocol.IncompleteAPDU do
  @moduledoc """
  This module is used to represent a segmented incomplete APDU.

  The given struct is to be fed to the `BACnet.Stack.SegmentsStore`, which will handle the segmentation.
  """

  @typedoc """
  Represents an incomplete APDU.
  """
  @type t :: %__MODULE__{}

  @fields [
    :header,
    :server,
    :invoke_id,
    :sequence_number,
    :window_size,
    :more_follows,
    :data
  ]
  @enforce_keys @fields
  defstruct @fields

  @doc """
  Set the window size field to the given number.
  """
  @spec set_window_size(t(), 1..127) :: t()
  def set_window_size(%__MODULE__{} = incomplete, window_size) when window_size in 1..127 do
    %{incomplete | window_size: window_size}
  end
end