This module is mostly used for basic decoding of BACnet frames (Protocol Data Units - PDU).
This module handles decoding of BVLL (and delegates specifics), NPCI and NSDU.
APDU is completely covered by BACnet.Protocol.APDU.
For BACnet Virtual Link Layer (BVLL), it will handle it and delegate, once it determines it is a BVLC function. BVLC function codes such as distribute broadcast, original broad- and unicast and forwarded NPDU are handled by this module directly. Currently only BVLL type 0x81 (BACnet/IPv4) is implemented.
The five simple BVLC functions that only carry an NPDU (or nothing) are
represented in this module as atoms inside the bvlc/0 union:
:original_unicast, :original_broadcast, :distribute_broadcast_to_network.
All seven management functions (Register-Foreign-Device, the BDT/FDT read/write
operations, Delete-FDT-Entry, etc.) are represented by the richer structs in
BACnet.Protocol.BvlcFunction, BACnet.Protocol.BvlcResult and
BACnet.Protocol.BvlcForwardedNPDU.
For Network Protocol Control Information (NPCI), it will handle all decoding associated with it and handle field handling.
For Network Service Data Unit (NSDU), it will handle all decoding associated with the regular BACnet types, excluding reserved and vendor proprietary.
For Application Data Unit (APDU), see the BACnet.Protocol.APDU module.
See Also
BACnet.Protocol.APDUBACnet.Protocol.BroadcastDistributionTableEntryBACnet.Protocol.BvlcFunction- the seven management BVLC payloadsBACnet.Protocol.BvlcForwardedNPDU- Forwarded-NPDU carrier (function 0x04)BACnet.Protocol.BvlcResult- BVLC-Result (function 0x00)BACnet.Protocol.ForeignDeviceTableEntryBACnet.Protocol.NPCIBACnet.Protocol.NetworkLayerProtocolMessage
Summary
Types
BACnet Application Data Units (APDU).
BACnet Virtual Link Control (BVLC), used in BACnet/IP (Annex J).
Functions
Decodes the BVLL header of a BACnet/IP packet (Annex J.2).
Decodes the NPCI header of a BACnet packet.
Decodes the NPDU of a BACnet packet.
Decodes the NSDU of a BACnet packet.
Types
@type apdu() :: BACnet.Protocol.APDU.ConfirmedServiceRequest.t() | BACnet.Protocol.APDU.UnconfirmedServiceRequest.t() | BACnet.Protocol.APDU.ComplexACK.t() | BACnet.Protocol.APDU.SimpleACK.t() | BACnet.Protocol.APDU.SegmentACK.t() | BACnet.Protocol.APDU.Abort.t() | BACnet.Protocol.APDU.Error.t() | BACnet.Protocol.APDU.Reject.t()
BACnet Application Data Units (APDU).
@type bvlc() :: BACnet.Protocol.BvlcForwardedNPDU.t() | BACnet.Protocol.BvlcFunction.t() | BACnet.Protocol.BvlcResult.t() | :distribute_broadcast_to_network | :original_broadcast | :original_unicast
BACnet Virtual Link Control (BVLC), used in BACnet/IP (Annex J).
This is the union of everything that can appear after a BVLL header (Type 0x81)
on the wire. The five simple carriers are represented as atoms so that higher
layers (especially BACnet.Stack.Transport.IPv4Transport) do not have to
allocate structs for the common case of ordinary unicast/broadcast traffic.
| Variant | Produced by BVLC Function | Description |
|---|---|---|
BvlcForwardedNPDU.t() | 0x04 | Broadcast or foreign-device traffic relayed by a BBMD |
BvlcFunction.t() | 0x01, 0x02, 0x03, 0x05-0x08 | The seven management operations (BDT/FDT, Register, Delete) |
BvlcResult.t() | 0x00 | Success/NAK reply for a management request |
:original_unicast | 0x0A | Normal directed NPDU (most common) |
:original_broadcast | 0x0B | Local broadcast on a B/IP subnet |
:distribute_broadcast_to_network | 0x09 | Foreign device asking its BBMD to broadcast on its behalf |
Functions
@spec decode_bvll(non_neg_integer(), non_neg_integer(), binary()) :: {:ok, {bvlc_size :: non_neg_integer(), bvlc :: bvlc(), rest :: binary()}} | {:error, term()}
Decodes the BVLL header of a BACnet/IP packet (Annex J.2).
The first two arguments are the BVLL Type (normally 0x81) and the BVLC
Function code. The third argument is the remaining bytes after the 4-octet
BVLL header. On success the function returns the number of bytes consumed
by the BVLC payload (so the caller knows where the NPDU begins), the
decoded bvlc/0 value, and any trailing bytes that belong to the NPDU.
Management functions (0x01-0x03, 0x05-0x08) are delegated to
BACnet.Protocol.BvlcFunction.decode/2. The five simple NPDU carriers and
the BVLC-Result (0x00) and Forwarded-NPDU (0x04) cases are handled directly
and return the corresponding atom or struct.
@spec decode_npci(binary()) :: {:ok, {BACnet.Protocol.NPCI.t(), rest :: binary()}} | {:error, term()}
Decodes the NPCI header of a BACnet packet.
@spec decode_npdu(BACnet.Protocol.NPCI.t(), binary()) :: {:ok, {type :: :network | :apdu, BACnet.Protocol.NetworkLayerProtocolMessage.t() | binary()}} | {:error, term()}
Decodes the NPDU of a BACnet packet.
For network messages, it decodes the NSDU. For application messages, it simply returns the APDU for further processing.
@spec decode_nsdu(binary()) :: {:ok, BACnet.Protocol.NetworkLayerProtocolMessage.t()} | {:error, term()}
Decodes the NSDU of a BACnet packet.