bacnet

package module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 5 Imported by: 0

README

go-bacnet

Go Go Reference License CI Codecov Release

go-bacnet is a pure-Go BACnet/IP client for discovery, supervisory control, event handling, and device management. It implements BACnet/IP over IPv4 with routed addressing, segmentation, COV, alarm/event, file, object-management, and selected advanced application services.

New to BACnet? Start with PROTOCOL.md.

Status: v0.3.0. The API is usable and extensively tested against four independent open-source BACnet stacks (bacnet-interop v0.9.0). Hardware interoperability testing is still incomplete (FIELD_VALIDATION.md).

Capability groups
  1. Transport and network — BACnet/IP IPv4/UDP, BVLC/NPDU/APDU, routing, Forwarded-NPDU, optional foreign-device registration, segmentation
  2. Discovery and object access — Who-Is/I-Am, Who-Has/I-Have, RP/RPM/WP/WPM, ReadRange, list element mutation
  3. Events, COV, and alarms — SubscribeCOV, notifications, EventNotification, AcknowledgeAlarm, GetEventInformation, GetAlarmSummary, GetEnrollmentSummary
  4. File and object management — AtomicRead/WriteFile, CreateObject, DeleteObject
  5. Advanced services — PrivateTransfer, TextMessage, time synchronization, WriteGroup, Who-Am-I/You-Are, LifeSafetyOperation, audit/VT codecs, opt-in DCC/ReinitializeDevice

Full matrix: docs/CLIENT_SUPPORT.md.
Scenario-by-peer results: INTEROP.md.

Out of scope: convenience/supervisor package; MS/TP; BACnet/IPv6; BACnet/SC; BBMD server; full BACnet server/device model; BTL certification.

Install
go get github.com/otfabric/go-bacnet@latest

Requires Go 1.23 or newer.

Getting started
package main

import (
	"context"
	"fmt"
	"log"
	"time"

	"github.com/otfabric/go-bacnet"
	"github.com/otfabric/go-bacnet/bip"
	"github.com/otfabric/go-bacnet/client"
)

func main() {
	c, err := client.New(client.WithPort(bip.DefaultPort)) // 47808 / 0xBAC0
	if err != nil {
		log.Fatal(err)
	}
	defer c.Close()

	ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
	defer cancel()

	devices, err := c.Discover(ctx, client.DiscoveryOptions{})
	// Discover returns when ctx ends; results are still useful.
	_ = err
	for _, d := range devices {
		fmt.Printf("device %d at %s (%s)\n", d.Instance, d.Address, d.Origin)
	}

	if len(devices) == 0 {
		return
	}
	d := devices[0]
	target := client.Target{
		Address:  d.Address,
		Endpoint: d.ImmediatePeer,
		Origin:   d.Origin,
	}
	obj := bacnet.ObjectIdentifier{Type: bacnet.ObjectTypeDevice, Instance: d.Instance}
	prop := bacnet.PropertyReference{Identifier: bacnet.PropertyObjectName}
	val, err := c.ReadProperty(context.Background(), target, obj, prop)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("object-name: %+v\n", val)
}

Always check the error from client.New before defer c.Close(). BACnet/IP peers use bip.Endpoint (not a root type).

Documentation
Document Contents
PROTOCOL.md BACnet primer
API.md Client behavioural contract
ERRORS.md Sentinels, remote PDUs, outcome-unknown
docs/CLIENT_SUPPORT.md Capability and evidence levels
INTEROP.md Scenario-by-peer results
docs/COMPATIBILITY.md Peer quirks and hardware results
docs/CLIENT_PROFILE.md Descriptive standards profile
docs/STANDARD_BASELINE.md Normative baseline
docs/FIELD_VALIDATION.md Physical-device checklist
PLAN.md Forward plan
RELEASE.md Release history
CONTRIBUTING.md Local checks and interop how-to
SECURITY.md Trust model and reporting
examples/ Runnable samples
License

MIT — see LICENSE.

Documentation

Overview

Package bacnet provides transport-neutral BACnet leaf types and helpers.

This package holds addresses, object/property identifiers, application values, decode limits and error sentinels. It does not open sockets and does not import BVLC, NPDU, APDU, service or client packages.

Wire codecs live in sibling packages (bvlc, npdu, apdu). The client runtime composes those layers. BACnet/IP endpoints live in package bip.

The library is a BACnet/IP IPv4 supervisory client developed against ANSI/ASHRAE 135-2024 (Protocol Revision 31 baseline). The client adapts to known remote capabilities and does not require Revision 31 features from remote devices.

Out of scope:

  • native MS/TP, BACnet/IPv6, BACnet/SC
  • full BBMD server / multi-BBMD failover
  • full BACnet server/device object model
  • BTL certification

Status: container-interoperability validated against pinned open-source peers; field validation pending. See docs/CLIENT_SUPPORT.md and INTEROP.md.

Index

Examples

Constants

View Source
const ArrayAll uint32 = 0xFFFFFFFF

ArrayAll selects all array elements.

View Source
const MaxMACLength = 7

MaxMACLength is the maximum BACnet MAC length retained for BACnet/IP IPv4 addressing (covers BACnet/IP 6-octet MAC and common shorter MACs).

View Source
const MaxObjectInstance = 0x3FFFFF

MaxObjectInstance is the largest valid object instance (22 bits).

Variables

View Source
var (
	ErrClosed                 = errors.New("bacnet: client closed")
	ErrTimeout                = errors.New("bacnet: request timeout")
	ErrTransactionCapacity    = errors.New("bacnet: transaction capacity exhausted")
	ErrMalformed              = errors.New("bacnet: malformed encoding")
	ErrUnsupported            = errors.New("bacnet: unsupported")
	ErrResponseSourceMismatch = errors.New("bacnet: response source mismatch")
	ErrProtocolViolation      = errors.New("bacnet: protocol violation")
	ErrAPDUTooLarge           = errors.New("bacnet: APDU exceeds remote capability")
	ErrTrailingData           = errors.New("bacnet: unexpected trailing data")
	ErrLimitExceeded          = errors.New("bacnet: decode limit exceeded")
	ErrDeliveryDropped        = errors.New("bacnet: delivery dropped")
	// ErrDeviceManagementDisabled is returned when DeviceCommunicationControl
	// or ReinitializeDevice is called without WithDeviceManagementEnabled.
	ErrDeviceManagementDisabled = errors.New("bacnet: device management API disabled")
	ErrBusy                     = errors.New("bacnet: operation already in progress")
)

Local/runtime sentinels.

Functions

func AppendApplicationValue

func AppendApplicationValue(dst []byte, v ApplicationValue) ([]byte, error)

AppendApplicationValue appends a deterministic application-tagged encoding.

func AppendContextBitString added in v0.2.0

func AppendContextBitString(dst []byte, tagNumber uint8, v BitString) ([]byte, error)

AppendContextBitString appends a context-tagged bit string.

func AppendContextBool

func AppendContextBool(dst []byte, tagNumber uint8, v bool) ([]byte, error)

AppendContextBool appends a context-tagged BOOLEAN as one value octet (0 or 1).

func AppendContextCharacterString added in v0.2.0

func AppendContextCharacterString(dst []byte, tagNumber uint8, v CharacterString) ([]byte, error)

AppendContextCharacterString appends a context-tagged character string.

func AppendContextNull

func AppendContextNull(dst []byte, tagNumber uint8) ([]byte, error)

AppendContextNull appends a context-tagged Null.

func AppendContextObjectID

func AppendContextObjectID(dst []byte, tagNumber uint8, id ObjectIdentifier) ([]byte, error)

AppendContextObjectID appends a context-tagged object identifier.

func AppendContextSigned added in v0.2.0

func AppendContextSigned(dst []byte, tagNumber uint8, v int64) ([]byte, error)

AppendContextSigned appends a context-tagged signed integer.

func AppendContextTagged

func AppendContextTagged(dst []byte, tagNumber uint8, body []Element) ([]byte, error)

AppendContextTagged appends opening tag, body tags, and closing tag.

func AppendContextTime added in v0.2.0

func AppendContextTime(dst []byte, tagNumber uint8, t Time) ([]byte, error)

AppendContextTime appends a context-tagged Time (4 octets).

func AppendContextUnsigned

func AppendContextUnsigned(dst []byte, tagNumber uint8, v uint64) ([]byte, error)

AppendContextUnsigned appends a context-tagged unsigned integer.

func AppendObjectIdentifier

func AppendObjectIdentifier(dst []byte, id ObjectIdentifier) ([]byte, error)

AppendObjectIdentifier appends the 4-octet encoding to dst.

func AppendTag

func AppendTag(dst []byte, el Element) ([]byte, error)

AppendTag appends a deterministic encoding of el to dst.

func AsBool

func AsBool(v ApplicationValue) (bool, error)

AsBool converts a Boolean value.

func AsEnumerated

func AsEnumerated(v ApplicationValue) (uint32, error)

AsEnumerated converts an Enumerated value to uint32.

func AsReal

func AsReal(v ApplicationValue) (float32, error)

AsReal converts a Real or Double value to float32.

func AsUnsigned

func AsUnsigned(v ApplicationValue) (uint64, error)

AsUnsigned converts an Unsigned or Enumerated value to uint64.

func ContextBool

func ContextBool(el Element) (bool, error)

ContextBool extracts a context-tagged BOOLEAN (exactly one octet 0 or 1).

func ContextSigned added in v0.2.0

func ContextSigned(el Element) (int64, error)

ContextSigned extracts a signed integer from a context primitive element.

func ContextUnsigned

func ContextUnsigned(el Element) (uint64, error)

ContextUnsigned extracts an unsigned from a context primitive element.

func DecodeBACnetError

func DecodeBACnetError(elements []Element) (class, code uint16, err error)

DecodeBACnetError parses a BACnet-Error structure.

Two encodings appear on the wire:

  1. Context [0] class / [1] code (unsigned or enumerated content) — used by this library's encoder and some goldens;
  2. Application ENUMERATED class then ENUMERATED code — used by bacnet-stack and BACpypes3 Error PDUs and RPM propertyAccessError.

func DecodePropertyValue added in v0.3.0

func DecodePropertyValue(objectType ObjectType, property PropertyIdentifier, value ApplicationValue) (any, bool, error)

DecodePropertyValue optionally maps a known object/property combination to a typed value. Unknown combinations return ok=false with no error so callers keep the raw ApplicationValue.

func EncodeBACnetError

func EncodeBACnetError(dst []byte, class, code uint16) ([]byte, error)

EncodeBACnetError encodes Error Class/Code as context [0]/[1].

func EncodeObjectIdentifier

func EncodeObjectIdentifier(id ObjectIdentifier) (uint32, error)

EncodeObjectIdentifier packs type and instance into a 4-octet value.

func IsContextConstructed

func IsContextConstructed(el Element) bool

IsContextConstructed reports a context-tagged constructed (open/close) value.

Types

type APDUTooLargeError

type APDUTooLargeError struct {
	EncodedSize           int
	RemoteMax             int
	SegmentationSupported bool
}

APDUTooLargeError reports a request that would exceed the remote max APDU without permitted segmentation.

func (*APDUTooLargeError) Error

func (e *APDUTooLargeError) Error() string

func (*APDUTooLargeError) Unwrap

func (e *APDUTooLargeError) Unwrap() error

type AbortError

type AbortError struct {
	InvokeID uint8
	Server   bool
	Reason   uint8
}

AbortError is a remote BACnet Abort PDU.

func (*AbortError) Error

func (e *AbortError) Error() string

type Address

type Address struct {
	// contains filtered or unexported fields
}

Address is a data-link-independent BACnet network address.

Example
package main

import (
	"fmt"

	"github.com/otfabric/go-bacnet"
)

func main() {
	mac := bacnet.MustMAC([]byte{192, 168, 1, 10, 0xBA, 0xC0})
	local := bacnet.LocalStation(mac)
	remote := bacnet.RemoteStation(2, mac)
	fmt.Println(local.Scope() == bacnet.AddressLocalStation)
	fmt.Println(remote.Network())
	fmt.Println(bacnet.GlobalBroadcast().IsBroadcast())
}
Output:
true
2
true

func GlobalBroadcast

func GlobalBroadcast() Address

GlobalBroadcast returns the BACnet global broadcast address.

func LocalBroadcast

func LocalBroadcast() Address

LocalBroadcast returns a local broadcast address.

func LocalStation

func LocalStation(mac MAC) Address

LocalStation returns a local unicast BACnet address.

func RemoteBroadcast

func RemoteBroadcast(network uint16) Address

RemoteBroadcast returns a remote broadcast on network.

func RemoteStation

func RemoteStation(network uint16, mac MAC) Address

RemoteStation returns a remote unicast address on network.

func (Address) Equal

func (a Address) Equal(o Address) bool

Equal reports whether a and o denote the same BACnet address.

func (Address) IsBroadcast

func (a Address) IsBroadcast() bool

IsBroadcast reports whether the address is any broadcast form.

func (Address) MAC

func (a Address) MAC() MAC

MAC returns the station MAC when applicable.

func (Address) Network

func (a Address) Network() uint16

Network returns the BACnet network number when applicable.

func (Address) Scope

func (a Address) Scope() AddressScope

Scope returns the address scope.

func (Address) String

func (a Address) String() string

String returns a human-readable form.

type AddressScope

type AddressScope uint8

AddressScope classifies a BACnet network address.

const (
	AddressLocalStation AddressScope = iota
	AddressLocalBroadcast
	AddressRemoteStation
	AddressRemoteBroadcast
	AddressGlobalBroadcast
)

type ApplicationTag

type ApplicationTag uint8

ApplicationTag numbers for BACnet application-tagged values.

const (
	TagNull ApplicationTag = iota
	TagBoolean
	TagUnsigned
	TagSigned
	TagReal
	TagDouble
	TagOctetString
	TagCharacterString
	TagBitString
	TagEnumerated
	TagDate
	TagTime
	TagObjectIdentifier
	TagReserved13
	TagReserved14
	TagReserved15
)

type ApplicationValue

type ApplicationValue struct {
	Kind ValueKind

	Boolean     bool
	Unsigned    uint64
	Signed      int64
	Real        float32
	Double      float64
	OctetString []byte
	Character   CharacterString
	BitString   BitString
	Enumerated  uint32
	Date        Date
	Time        Time
	ObjectID    ObjectIdentifier

	// Constructed / context nesting.
	Elements []Element
}

ApplicationValue is a generic decoded BACnet application value.

OctetString and BitString.Bytes may alias parse input unless Clone is used. Runtime storage beyond packet processing must call Clone.

Example (Helpers)
package main

import (
	"fmt"

	"github.com/otfabric/go-bacnet"
)

func main() {
	v := bacnet.RealValue(21.5)
	f, err := bacnet.AsReal(v)
	if err != nil {
		fmt.Println("err", err)
		return
	}
	fmt.Println(v.Kind == bacnet.ValueReal)
	fmt.Printf("%.1f\n", f)

	id := bacnet.ObjectIdentifier{Type: bacnet.ObjectTypeAnalogInput, Instance: 1}
	oid := bacnet.ObjectIDValue(id)
	got, err := bacnet.AsObjectID(oid)
	if err != nil {
		fmt.Println("err", err)
		return
	}
	fmt.Println(got.String())
}
Output:
true
21.5
0:1

func BoolValue

func BoolValue(b bool) ApplicationValue

BoolValue returns a Boolean application value.

func DateValue added in v0.3.0

func DateValue(d Date) ApplicationValue

DateValue returns a Date application value.

func DoubleValue

func DoubleValue(f float64) ApplicationValue

DoubleValue returns a Double application value.

func EncodeCalendarEntry added in v0.3.0

func EncodeCalendarEntry(e CalendarEntry) (ApplicationValue, error)

EncodeCalendarEntry encodes a CalendarEntry CHOICE as a constructed value.

func EncodeDailySchedule added in v0.3.0

func EncodeDailySchedule(d DailySchedule) ApplicationValue

EncodeDailySchedule encodes SEQUENCE OF TimeValue under context tag 0.

func EncodeDateRange added in v0.3.0

func EncodeDateRange(dr DateRange) ApplicationValue

EncodeDateRange encodes a DateRange as two application Date tags.

func EncodeDateTime added in v0.3.0

func EncodeDateTime(dt DateTime) ApplicationValue

EncodeDateTime encodes DateTime as date+time application tags.

func EncodeHostNPort added in v0.3.0

func EncodeHostNPort(h HostNPort) ApplicationValue

EncodeHostNPort encodes host as ip-address [0] octet string + port [1].

func EncodeWeeklySchedule added in v0.3.0

func EncodeWeeklySchedule(w WeeklySchedule) ApplicationValue

EncodeWeeklySchedule encodes ARRAY[7] OF DailySchedule as seven constructed days.

func EnumValue

func EnumValue(e uint32) ApplicationValue

EnumValue returns an Enumerated application value.

func NullValue

func NullValue() ApplicationValue

NullValue returns a Null application value.

func ObjectIDValue

func ObjectIDValue(id ObjectIdentifier) ApplicationValue

ObjectIDValue returns an ObjectIdentifier application value.

func ParseApplicationValue

func ParseApplicationValue(data []byte, limits DecodeLimits) (ApplicationValue, int, error)

ParseApplicationValue parses a single application-tagged value.

func RealValue

func RealValue(f float32) ApplicationValue

RealValue returns a Real application value.

func SignedValue

func SignedValue(s int64) ApplicationValue

SignedValue returns a Signed application value.

func TimeValue added in v0.3.0

func TimeValue(t Time) ApplicationValue

TimeValue returns a Time application value.

func UnsignedValue

func UnsignedValue(u uint64) ApplicationValue

UnsignedValue returns an Unsigned application value.

func (ApplicationValue) Clone

Clone returns a deep copy that owns all byte slices.

func (ApplicationValue) TagNumber

func (v ApplicationValue) TagNumber() ApplicationTag

TagNumber returns the application tag for primitive kinds.

type BitString

type BitString struct {
	UnusedBits uint8
	Bytes      []byte
}

BitString holds a BACnet bit string.

func ContextBitString added in v0.2.0

func ContextBitString(el Element) (BitString, error)

ContextBitString extracts a bit string from a context primitive element.

type CalendarEntry added in v0.3.0

type CalendarEntry struct {
	Choice    CalendarEntryChoice
	Date      Date
	DateRange DateRange
	WeekNDay  WeekNDay
}

CalendarEntry is BACnetCalendarEntry.

func DecodeCalendarEntry added in v0.3.0

func DecodeCalendarEntry(v ApplicationValue) (CalendarEntry, error)

DecodeCalendarEntry decodes a CalendarEntry CHOICE.

type CalendarEntryChoice added in v0.3.0

type CalendarEntryChoice uint8

CalendarEntryChoice discriminates BACnetCalendarEntry.

const (
	CalendarEntryDate CalendarEntryChoice = iota
	CalendarEntryDateRange
	CalendarEntryWeekNDay
)

type CharacterString

type CharacterString struct {
	Encoding uint8
	Value    string
}

CharacterString holds a BACnet character string with encoding byte.

func ContextCharacterString added in v0.2.0

func ContextCharacterString(el Element) (CharacterString, error)

ContextCharacterString extracts a character string from a context primitive.

type DailySchedule added in v0.3.0

type DailySchedule struct {
	DaySchedule []ScheduledTimeValue
}

DailySchedule is BACnetDailySchedule (SEQUENCE OF TimeValue).

func DecodeDailySchedule added in v0.3.0

func DecodeDailySchedule(v ApplicationValue) (DailySchedule, error)

TimeValueTag returns an application Time tag (named to avoid clash with TimeValue type helpers). DecodeDailySchedule decodes a DailySchedule.

type Date

type Date struct {
	Year    uint8 // years since 1900; 0xFF = unspecified
	Month   uint8
	Day     uint8
	Weekday uint8
}

Date is a BACnet date (year offset from 1900, month, day, weekday).

func AsDate added in v0.3.0

func AsDate(v ApplicationValue) (Date, error)

AsDate converts a Date value.

type DateRange added in v0.3.0

type DateRange struct {
	Start Date
	End   Date
}

DateRange is BACnetDateRange (start-date, end-date).

func DecodeDateRange added in v0.3.0

func DecodeDateRange(v ApplicationValue) (DateRange, error)

DecodeDateRange decodes a constructed DateRange.

type DateTime added in v0.3.0

type DateTime struct {
	Date Date
	Time Time
}

DateTime is BACnetDateTime.

func DecodeDateTime added in v0.3.0

func DecodeDateTime(v ApplicationValue) (DateTime, error)

DecodeDateTime decodes a DateTime.

type DecodeLimits

type DecodeLimits struct {
	MaxDatagramSize      int
	MaxAPDUSize          int
	MaxConstructedDepth  int
	MaxElements          int
	MaxOctetStringLength int
	MaxCharacterLength   int
	MaxBitStringBits     int
	MaxSegments          int
	MaxReassembledAPDU   int
}

DecodeLimits bounds parser and reassembly allocations. Application-configured hard bounds win over peer-advertised maxima.

func DefaultDecodeLimits

func DefaultDecodeLimits() DecodeLimits

DefaultDecodeLimits returns conservative BACnet/IP IPv4 defaults.

func (DecodeLimits) Normalize

func (l DecodeLimits) Normalize() DecodeLimits

Normalize returns limits with zeros replaced by defaults.

type DoorStatus added in v0.3.0

type DoorStatus uint32

DoorStatus is BACnetDoorStatus.

const (
	DoorStatusClosed DoorStatus = iota
	DoorStatusOpened
	DoorStatusUnknown
	DoorStatusDoorFault
	DoorStatusUnused
	DoorStatusNone
	DoorStatusClosing
	DoorStatusOpening
	DoorStatusSafetyLocked
	DoorStatusLimitedOpened
)

type Element

type Element struct {
	Context   bool
	TagNumber uint8
	Opening   bool
	Closing   bool
	Value     ApplicationValue
}

Element is a generic BACnet tag element (application or context).

func ParseSequence

func ParseSequence(data []byte, limits DecodeLimits, closeTag int) ([]Element, int, error)

ParseSequence parses a sequence of tags until data is exhausted or a closing tag matching closeTag is seen (if closeTag >= 0). Consumed length is returned. Nested opening/closing pairs become ValueConstructed elements (Opening=false).

func ParseTag

func ParseTag(data []byte, limits DecodeLimits) (Element, int, error)

ParseTag parses one BACnet tag from data and returns the element, bytes consumed, and error. Application primitive values may alias data.

type ErrorResponse

type ErrorResponse struct {
	InvokeID uint8
	Service  uint8
	Class    uint16
	Code     uint16
}

ErrorResponse is a remote BACnet Error PDU.

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

type ExceptionSchedule added in v0.3.0

type ExceptionSchedule struct {
	SpecialEvents []SpecialEvent
}

ExceptionSchedule is BACnetExceptionSchedule (SEQUENCE OF SpecialEvent).

type HostNPort added in v0.3.0

type HostNPort struct {
	IP   [4]byte
	Name string // non-empty means ip-address absent / name present
	Port uint16
}

HostNPort is BACnetHostNPort (host CHOICE + optional port).

func DecodeHostNPort added in v0.3.0

func DecodeHostNPort(v ApplicationValue) (HostNPort, error)

DecodeHostNPort decodes HostNPort.

type LifeSafetyMode added in v0.3.0

type LifeSafetyMode uint32

LifeSafetyMode is BACnetLifeSafetyMode.

const (
	LifeSafetyModeOff LifeSafetyMode = iota
	LifeSafetyModeOn
	LifeSafetyModeTest
	LifeSafetyModeManned
	LifeSafetyModeArmed
	LifeSafetyModeDisarmed
	LifeSafetyModePrearmed
	LifeSafetyModeQuiet
	LifeSafetyModeFaultSealed
	LifeSafetyModeFaultUnsealed
	LifeSafetyModeFaultImmediate
	LifeSafetyModeFaultDelayed
	LifeSafetyModePullActive
	LifeSafetyModeManual
	LifeSafetyModeInterlocked
	LifeSafetyModeBlocked
	LifeSafetyModeTamper
	LifeSafetyModeTestActiveAlarm
	LifeSafetyModeTestActiveFault
	LifeSafetyModeTestActiveFaultAlarm
	LifeSafetyModeTestHold
	LifeSafetyModeTestHoldAlarm
	LifeSafetyModeTestHoldFault
	LifeSafetyModeTestHoldFaultAlarm
)

type LifeSafetyOperation added in v0.3.0

type LifeSafetyOperation uint32

LifeSafetyOperation is BACnetLifeSafetyOperation.

const (
	LifeSafetyOperationNone LifeSafetyOperation = iota
	LifeSafetyOperationSilence
	LifeSafetyOperationSilenceAudible
	LifeSafetyOperationSilenceVisual
	LifeSafetyOperationReset
	LifeSafetyOperationResetAlarm
	LifeSafetyOperationResetFault
	LifeSafetyOperationUnsilence
	LifeSafetyOperationUnsilenceAudible
	LifeSafetyOperationUnsilenceVisual
)

type LifeSafetyState added in v0.3.0

type LifeSafetyState uint32

LifeSafetyState is BACnetLifeSafetyState.

const (
	LifeSafetyStateQuiet LifeSafetyState = iota
	LifeSafetyStatePreAlarm
	LifeSafetyStateAlarm
	LifeSafetyStateFault
	LifeSafetyStateFaultPreAlarm
	LifeSafetyStateFaultAlarm
	LifeSafetyStateNotReady
	LifeSafetyStateActive
	LifeSafetyStateTamper
	LifeSafetyStateTestAlarm
	LifeSafetyStateTestActive
	LifeSafetyStateTestFault
	LifeSafetyStateTestFaultAlarm
	LifeSafetyStateHoldup
	LifeSafetyStateHoldupAlarm
	LifeSafetyStateDuress
	LifeSafetyStateTamperAlarm
	LifeSafetyStateAbnormal
	LifeSafetyStateEmergencyPower
	LifeSafetyStateDelayed
	LifeSafetyStateBlocked
	LifeSafetyStateLocalAlarm
	LifeSafetyStateGeneralAlarm
	LifeSafetyStateSupervisory
	LifeSafetyStateTestSupervisory
)

type LockStatus added in v0.3.0

type LockStatus uint32

LockStatus is BACnetLockStatus.

const (
	LockStatusLocked LockStatus = iota
	LockStatusUnlocked
	LockStatusFault
	LockStatusUnknown
	LockStatusLockedOut
	LockStatusUnused
)

type MAC

type MAC struct {
	// contains filtered or unexported fields
}

MAC is an immutable, comparable BACnet MAC address.

func MustMAC

func MustMAC(b []byte) MAC

MustMAC panics if NewMAC fails.

func NewMAC

func NewMAC(b []byte) (MAC, error)

NewMAC copies b into a MAC. Empty input yields a zero MAC.

func (MAC) Bytes

func (m MAC) Bytes() []byte

Bytes returns a copy of the MAC octets.

func (MAC) IsZero

func (m MAC) IsZero() bool

IsZero reports whether the MAC is empty.

func (MAC) Len

func (m MAC) Len() int

Len returns the MAC length in octets.

func (MAC) String

func (m MAC) String() string

String returns a hex representation.

type ObjectIdentifier

type ObjectIdentifier struct {
	Type     ObjectType
	Instance uint32
}

ObjectIdentifier identifies a BACnet object.

func AsObjectID

func AsObjectID(v ApplicationValue) (ObjectIdentifier, error)

AsObjectID converts an ObjectIdentifier value.

func ContextObjectID

func ContextObjectID(el Element) (ObjectIdentifier, error)

ContextObjectID extracts an object identifier from a context primitive.

func DecodeObjectIdentifier

func DecodeObjectIdentifier(v uint32) ObjectIdentifier

DecodeObjectIdentifier unpacks a 4-octet object identifier.

func (ObjectIdentifier) String

func (id ObjectIdentifier) String() string

String returns Type:Instance.

type ObjectType

type ObjectType uint16

ObjectType is a BACnet object type (standard or proprietary).

const (
	ObjectTypeAnalogInput       ObjectType = 0
	ObjectTypeAnalogOutput      ObjectType = 1
	ObjectTypeAnalogValue       ObjectType = 2
	ObjectTypeBinaryInput       ObjectType = 3
	ObjectTypeBinaryOutput      ObjectType = 4
	ObjectTypeBinaryValue       ObjectType = 5
	ObjectTypeCalendar          ObjectType = 6
	ObjectTypeCommand           ObjectType = 7
	ObjectTypeDevice            ObjectType = 8
	ObjectTypeEventEnrollment   ObjectType = 9
	ObjectTypeFile              ObjectType = 10
	ObjectTypeGroup             ObjectType = 11
	ObjectTypeLifeSafetyPoint   ObjectType = 21
	ObjectTypeLifeSafetyZone    ObjectType = 22
	ObjectTypeMultiStateInput   ObjectType = 13
	ObjectTypeNotificationClass ObjectType = 15
	ObjectTypeMultiStateValue   ObjectType = 19
	ObjectTypeTrendLog          ObjectType = 20
	ObjectTypeSchedule          ObjectType = 17
	ObjectTypeMultiStateOutput  ObjectType = 14
	ObjectTypeAccumulator       ObjectType = 23
	ObjectTypePulseConverter    ObjectType = 24
	ObjectTypeTrendLogMultiple  ObjectType = 27
	ObjectTypeNetworkPort       ObjectType = 56
	ObjectTypeAuditLog          ObjectType = 61
	ObjectTypeAccessDoor        ObjectType = 30
	ObjectTypeAccessPoint       ObjectType = 33
)

Common standard object types (ASHRAE 135).

func (ObjectType) String added in v0.3.0

func (t ObjectType) String() string

type OutcomeUnknownError

type OutcomeUnknownError struct {
	Operation string
	Cause     error
}

OutcomeUnknownError indicates a request may have been executed remotely but no definitive response was observed (typical after a write send without ACK).

func (*OutcomeUnknownError) Error

func (e *OutcomeUnknownError) Error() string

func (*OutcomeUnknownError) Unwrap

func (e *OutcomeUnknownError) Unwrap() error

type PropertyIdentifier

type PropertyIdentifier uint32

PropertyIdentifier is a BACnet property identifier (standard or proprietary).

const (
	PropertyObjectIdentifier  PropertyIdentifier = 75
	PropertyObjectName        PropertyIdentifier = 77
	PropertyObjectType        PropertyIdentifier = 79
	PropertyPresentValue      PropertyIdentifier = 85
	PropertyPriorityArray     PropertyIdentifier = 87
	PropertyStatusFlags       PropertyIdentifier = 111
	PropertySystemStatus      PropertyIdentifier = 112
	PropertyVendorIdentifier  PropertyIdentifier = 120
	PropertyVendorName        PropertyIdentifier = 121
	PropertyModelName         PropertyIdentifier = 70
	PropertyProtocolVersion   PropertyIdentifier = 98
	PropertyProtocolRevision  PropertyIdentifier = 139
	PropertyMaxAPDULength     PropertyIdentifier = 62
	PropertySegmentation      PropertyIdentifier = 107
	PropertyDescription       PropertyIdentifier = 28
	PropertyUnits             PropertyIdentifier = 117
	PropertyRelinquishDefault PropertyIdentifier = 104
	PropertyLogBuffer         PropertyIdentifier = 131
	PropertyObjectList        PropertyIdentifier = 76
	PropertyPropertyList      PropertyIdentifier = 371
	PropertyReliability       PropertyIdentifier = 103
	PropertyEventState        PropertyIdentifier = 36
	PropertyWeeklySchedule    PropertyIdentifier = 123
	PropertyExceptionSchedule PropertyIdentifier = 38
	PropertyScheduleDefault   PropertyIdentifier = 174
	PropertyDateList          PropertyIdentifier = 23
	PropertyRecipientList     PropertyIdentifier = 102
	PropertyNetworkType       PropertyIdentifier = 427
	PropertyIPAddress         PropertyIdentifier = 400
	PropertyIPSubnetMask      PropertyIdentifier = 411
	PropertyBACnetIPUDPPort   PropertyIdentifier = 412
)

Common property identifiers.

func (PropertyIdentifier) String added in v0.3.0

func (p PropertyIdentifier) String() string

type PropertyReference

type PropertyReference struct {
	Identifier PropertyIdentifier
	ArrayIndex *uint32 // nil means the entire property; ArrayAll means all elements
}

PropertyReference identifies a property, optionally with an array index.

func (PropertyReference) Equal

Equal reports whether p and o identify the same property reference.

type RejectError

type RejectError struct {
	InvokeID uint8
	Reason   uint8
}

RejectError is a remote BACnet Reject PDU.

func (*RejectError) Error

func (e *RejectError) Error() string

type ScheduledTimeValue added in v0.3.0

type ScheduledTimeValue struct {
	Time  Time
	Value ApplicationValue
}

TimeValue is BACnetTimeValue (time + any value).

type SpecialEvent added in v0.3.0

type SpecialEvent struct {
	CalendarEntry    CalendarEntry // period as calendarEntry; CalendarRef uses ObjectID in PeriodObject
	PeriodObject     *ObjectIdentifier
	ListOfTimeValues []ScheduledTimeValue
	EventPriority    uint8
}

SpecialEvent is one BACnetSpecialEvent (period CHOICE + list of TimeValue + priority).

type Time

type Time struct {
	Hour       uint8
	Minute     uint8
	Second     uint8
	Hundredths uint8
}

Time is a BACnet time.

func AsTime added in v0.3.0

func AsTime(v ApplicationValue) (Time, error)

AsTime converts a Time value.

func ContextTime added in v0.2.0

func ContextTime(el Element) (Time, error)

ContextTime extracts a Time from a context primitive element.

type TimeStamp added in v0.3.0

type TimeStamp struct {
	Choice   TimeStampChoice
	Time     Time
	Sequence uint16
	DateTime DateTime
}

TimeStamp is BACnetTimeStamp.

type TimeStampChoice added in v0.3.0

type TimeStampChoice uint8

TimeStampChoice discriminates BACnetTimeStamp.

const (
	TimeStampTime TimeStampChoice = iota
	TimeStampSequence
	TimeStampDateTime
)

type ValueKind

type ValueKind uint8

ValueKind discriminates ApplicationValue contents.

const (
	ValueNull ValueKind = iota
	ValueBoolean
	ValueUnsigned
	ValueSigned
	ValueReal
	ValueDouble
	ValueOctetString
	ValueCharacterString
	ValueBitString
	ValueEnumerated
	ValueDate
	ValueTime
	ValueObjectID
	ValueConstructed
	ValueContext // context-tagged primitive or opening; Elements hold nested data
)

type WeekNDay added in v0.3.0

type WeekNDay struct {
	Month       uint8
	WeekOfMonth uint8
	DayOfWeek   uint8
}

WeekNDay is BACnetWeekNDay (month, weekOfMonth, dayOfWeek).

type WeeklySchedule added in v0.3.0

type WeeklySchedule [7]DailySchedule

WeeklySchedule is BACnetWeeklySchedule (ARRAY[7] OF DailySchedule).

func DecodeWeeklySchedule added in v0.3.0

func DecodeWeeklySchedule(v ApplicationValue) (WeeklySchedule, error)

DecodeWeeklySchedule decodes seven DailySchedule elements.

Directories

Path Synopsis
Package apdu implements BACnet Application Protocol Data Unit framing.
Package apdu implements BACnet Application Protocol Data Unit framing.
Package bip provides BACnet/IP data-link endpoint types.
Package bip provides BACnet/IP data-link endpoint types.
Package bvlc implements BACnet Virtual Link Control (BACnet/IP) framing.
Package bvlc implements BACnet Virtual Link Control (BACnet/IP) framing.
Package client implements a BACnet/IP supervisory client runtime.
Package client implements a BACnet/IP supervisory client runtime.
cmd
bacnetctl command
Command bacnetctl is a small BACnet/IP utility for decode, discover, read and write.
Command bacnetctl is a small BACnet/IP utility for decode, discover, read and write.
Package device provides optional supervisory helpers built on the client API.
Package device provides optional supervisory helpers built on the client API.
examples
events command
Command events listens for inbound EventNotification PDUs and prints typed NotificationParameters when recognized (for example change-of-state).
Command events listens for inbound EventNotification PDUs and prints typed NotificationParameters when recognized (for example change-of-state).
read-range command
Command read-range demonstrates Client.ReadRange against a Trend Log Log_Buffer, including typed BACnetLogRecord decode when the peer returns well-formed records.
Command read-range demonstrates Client.ReadRange against a Trend Log Log_Buffer, including typed BACnetLogRecord decode when the peer returns well-formed records.
who-has command
Command who-has demonstrates SendWhoHas / DiscoverObjects and the object observation registry.
Command who-has demonstrates SendWhoHas / DiscoverObjects and the object observation registry.
write-multiple command
Command write-multiple demonstrates Client.WritePropertyMultiple.
Command write-multiple demonstrates Client.WritePropertyMultiple.
internal
clock
Package clock provides an injectable clock for deterministic lifecycle tests.
Package clock provides an injectable clock for deterministic lifecycle tests.
diag
Package diag defines an optional diagnostic sink.
Package diag defines an optional diagnostic sink.
faulty
Package faulty provides deterministic transport fault injection for tests.
Package faulty provides deterministic transport fault injection for tests.
fixtures
Package fixtures loads bacnet-interop corpus metadata for unit tests.
Package fixtures loads bacnet-interop corpus metadata for unit tests.
virtual
Package virtual provides an in-memory BACnet/IP transport for deterministic tests.
Package virtual provides an in-memory BACnet/IP transport for deterministic tests.
Package npdu implements BACnet Network Layer Protocol Data Units.
Package npdu implements BACnet Network Layer Protocol Data Units.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL