BACnet.Protocol.APDU.Abort (bacstack v0.1.0-dev.1)

Copy Markdown View Source

Abort APDUs abruptly terminate an ongoing confirmed transaction.

APDU Description (ASHRAE 135)

The BACnet-Abort-PDU is used to terminate a transaction between two peers. The BACnet-Abort-PDU may be generated by either a requesting BACnet-user or a responding BACnet-user when a transaction cannot be completed or when an error condition occurs. (Clause 21 and Clause 5.4)

Common reasons (see BACnet.Protocol.Constants.abort_reason/0 and Clause 18.10 "Abort Reason"):

  • :other, :buffer_overflow, :apdu_too_long
  • :segmentation_not_supported
  • :tsm_timeout, :application_exceeded_reply_time
  • Security related: :security_error, :insufficient_security
  • Resource problems: :out_of_resources, :window_size_out_of_range

Either side (client or server) may send an Abort (distinguished by the 'server' bit).

This module implements the BACnet.Stack.EncoderProtocol.

Decoding is performed by BACnet.Protocol.APDU.decode/1 (and BACnet.Protocol.APDU.decode_abort/1).

Examples

iex> abort = %Abort{
...>   sent_by_server: true,
...>   invoke_id: 7,
...>   reason: :segmentation_not_supported
...> }
iex> Abort.encode(abort)
{:ok, <<0x71, 0x07, 0x04>>}

Decoding an Abort from the wire:

iex> raw = <<0x71, 0x07, 0x04>>
iex> BACnet.Protocol.APDU.decode(raw)
{:ok, %Abort{invoke_id: 7, sent_by_server: true, reason: :segmentation_not_supported}}

Summary

Types

t()

Represents the Application Data Unit (APDU) Abort.

Functions

Encodes the Abort APDU into binary data.

Types

t()

@type t() :: %BACnet.Protocol.APDU.Abort{
  invoke_id: 0..255,
  reason: BACnet.Protocol.Constants.abort_reason() | non_neg_integer(),
  sent_by_server: boolean()
}

Represents the Application Data Unit (APDU) Abort.

To allow forward compatibility, reason is allowed to be an integer.

Functions

encode(apdu)

@spec encode(t()) :: {:ok, iodata()} | {:error, Exception.t()}

Encodes the Abort APDU into binary data.