bacnet

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 8 Imported by: 0

README

go-bacnet

Go Go Reference License CI Codecov Release

go-bacnet is a pure-Go BACnet/IP client library: discover devices, read and write properties, subscribe to change-of-value and alarm notifications, transfer files and manage objects on BACnet/IP (Annex J) over IPv4, including routed networks, foreign-device registration and segmentation. It has no dependencies outside the Go standard library.

New to BACnet? Start with PROTOCOL.md.

Status

Client only. The library is tested on every change against five independent open-source BACnet stacks running in containers (bacnet-stack, BACpypes3, BACnet4J, Worldiety, System.IO.BACnet; INTEROP.md) and its requests are checked against Wireshark's dissector. It has not been validated against physical controllers yet; the checklist for that is docs/FIELD_VALIDATION.md. The API is v0 and can still change between minor versions; RELEASE.md lists every change.

Scope

Transport and network BACnet/IP over IPv4/UDP, BVLC, routed addressing (DNET/DADR), Forwarded-NPDU, foreign-device registration with one BBMD, BDT/FDT management, segmented requests and responses
Discovery Who-Is / I-Am, Who-Has / I-Have, Who-Is-Router-To-Network
Object access ReadProperty, ReadPropertyMultiple, WriteProperty, WritePropertyMultiple, ReadRange, Add/RemoveListElement, CreateObject, DeleteObject, AtomicRead/WriteFile
Notifications SubscribeCOV, SubscribeCOVProperty, SubscribeCOVPropertyMultiple, COV and EventNotification reception, AcknowledgeAlarm, GetEventInformation, GetAlarmSummary, GetEnrollmentSummary
Other services time synchronization, text message, private transfer, WriteGroup, LifeSafetyOperation, and (opt-in) DeviceCommunicationControl and ReinitializeDevice

The complete matrix, with how well each capability is validated, is docs/CLIENT_SUPPORT.md.

Not in scope: a BACnet server or device object model, BBMD server, MS/TP, BACnet/IPv6, BACnet/SC, BTL certification. BACnet/IP has no authentication or encryption and this library adds none (SECURITY.md).

A command-line client built on this library lives in otfabric/bacnetctl.

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/client"
)

func main() {
	c, err := client.New() // binds UDP port 47808
	if err != nil {
		log.Fatal(err)
	}
	defer c.Close()

	ctx := context.Background()
	devices, err := c.Discover(ctx, client.DiscoveryOptions{Window: 3 * time.Second})
	if err != nil {
		log.Fatal(err)
	}
	name := bacnet.PropertyReference{Identifier: bacnet.PropertyObjectName}
	for _, d := range devices {
		val, err := c.ReadProperty(ctx, d.Target(), d.DeviceID(), name)
		if err != nil {
			fmt.Printf("device %d at %s: %v\n", d.Instance, d.Address, err)
			continue
		}
		fmt.Printf("device %d at %s: %s\n", d.Instance, d.Address, val.Character.Value)
	}
}

A device whose address you already know needs no discovery:

c, err := client.New(client.WithLocalAddr("0.0.0.0:0")) // any free local port
// ...
target := client.Target{Endpoint: bip.NewEndpoint(netip.MustParseAddrPort("192.168.1.20:47808"))}
av1 := bacnet.ObjectIdentifier{Type: bacnet.ObjectTypeAnalogValue, Instance: 1}
pv, err := c.ReadProperty(ctx, target, av1, bacnet.PropertyReference{Identifier: bacnet.PropertyPresentValue})

These and further examples (writing with a priority, COV subscriptions, logging) are compiled as part of the test suite: see client/example_test.go and examples/.

Things to know before you use it

  • One client, one socket. A Client owns one UDP socket and is safe for concurrent use; requests are multiplexed on it by invoke ID. Create one per local interface and keep it; Close releases the socket and fails pending requests with bacnet.ErrClosed.
  • Port 47808. Devices answer Who-Is with a broadcast to port 47808, so discovery needs the client bound there (the default), and only one process on a host can be. Unicast requests work from any port (WithLocalAddr("0.0.0.0:0")).
  • Broadcasts stop at routers. A Who-Is goes to the broadcast address of every local subnet. To discover devices on another IP subnet, register as a foreign device with a BBMD there (WithForeignDevice) or send a unicast Who-Is (SendWhoIs). WithInterface restricts broadcasts to one interface.
  • Timeouts. A request without an answer fails with bacnet.ErrTimeout after the APDU timeout (3 s) times the attempts (reads are retransmitted 3 times; writes never). A context deadline or cancellation ends it earlier and is preserved for errors.Is. See WithTransactionOptions.
  • Writes can be ambiguous. A write is sent once. If no answer arrives the device may or may not have applied it: the call returns *bacnet.OutcomeUnknownError, never a plain timeout. Read the value back before repeating a write that is not idempotent.
  • Errors are typed. A device's Error, Reject and Abort PDUs come back as *bacnet.ErrorResponse, *bacnet.RejectError and *bacnet.AbortError with standard names; ReadPropertyMultiple reports per-property errors inside its results. ERRORS.md has the whole taxonomy.
  • Dangerous services are opt-in. DeviceCommunicationControl, ReinitializeDevice and Write-BDT fail locally unless enabled with WithDeviceManagementEnabled / WithNetworkManagementEnabled.
  • Silent by default. No logging unless you pass WithLogger (OBSERVABILITY.md).
  • Character strings. CharacterString.Value holds the octets as received. Use Text() to get a Go string from devices that send UCS-2 or ISO 8859-1.

Documentation

Document Contents
PROTOCOL.md BACnet primer
API.md Client behavioural contract: lifecycle, ownership, timeouts, result models
ERRORS.md Sentinels, remote PDUs, outcome-unknown
OBSERVABILITY.md Logging and diagnostics
ARCHITECTURE.md Packages, dependency rules, client runtime
docs/CLIENT_SUPPORT.md Every capability and its evidence level
INTEROP.md Scenario-by-peer results and how to run them
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

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 (
	ErrorClassDevice        uint16 = 0
	ErrorClassObject        uint16 = 1
	ErrorClassProperty      uint16 = 2
	ErrorClassResources     uint16 = 3
	ErrorClassSecurity      uint16 = 4
	ErrorClassServices      uint16 = 5
	ErrorClassVT            uint16 = 6
	ErrorClassCommunication uint16 = 7
)

BACnet Error Class values (ASHRAE 135 BACnetErrorClass).

View Source
const (
	ErrorCodeOther                             uint16 = 0
	ErrorCodeConfigurationInProgress           uint16 = 2
	ErrorCodeDeviceBusy                        uint16 = 3
	ErrorCodeDynamicCreationNotSupported       uint16 = 4
	ErrorCodeFileAccessDenied                  uint16 = 5
	ErrorCodeInconsistentParameters            uint16 = 7
	ErrorCodeInconsistentSelectionCriterion    uint16 = 8
	ErrorCodeInvalidDataType                   uint16 = 9
	ErrorCodeInvalidFileAccessMethod           uint16 = 10
	ErrorCodeInvalidFileStartPosition          uint16 = 11
	ErrorCodeInvalidParameterDataType          uint16 = 13
	ErrorCodeInvalidTimeStamp                  uint16 = 14
	ErrorCodeMissingRequiredParameter          uint16 = 16
	ErrorCodeNoObjectsOfSpecifiedType          uint16 = 17
	ErrorCodeNoSpaceForObject                  uint16 = 18
	ErrorCodeNoSpaceToAddListElement           uint16 = 19
	ErrorCodeNoSpaceToWriteProperty            uint16 = 20
	ErrorCodePropertyIsNotAList                uint16 = 22
	ErrorCodeObjectDeletionNotPermitted        uint16 = 23
	ErrorCodeObjectIdentifierAlreadyExists     uint16 = 24
	ErrorCodeOperationalProblem                uint16 = 25
	ErrorCodePasswordFailure                   uint16 = 26
	ErrorCodeReadAccessDenied                  uint16 = 27
	ErrorCodeServiceRequestDenied              uint16 = 29
	ErrorCodeTimeout                           uint16 = 30
	ErrorCodeUnknownObject                     uint16 = 31
	ErrorCodeUnknownProperty                   uint16 = 32
	ErrorCodeUnsupportedObjectType             uint16 = 36
	ErrorCodeValueOutOfRange                   uint16 = 37
	ErrorCodeWriteAccessDenied                 uint16 = 40
	ErrorCodeCharacterSetNotSupported          uint16 = 41
	ErrorCodeInvalidArrayIndex                 uint16 = 42
	ErrorCodeCOVSubscriptionFailed             uint16 = 43
	ErrorCodeNotCOVProperty                    uint16 = 44
	ErrorCodeOptionalFunctionalityNotSupported uint16 = 45
	ErrorCodeInvalidConfigurationData          uint16 = 46
	ErrorCodeDatatypeNotSupported              uint16 = 47
	ErrorCodeDuplicateName                     uint16 = 48
	ErrorCodeDuplicateObjectID                 uint16 = 49
	ErrorCodePropertyIsNotAnArray              uint16 = 50
	ErrorCodeAbortSegmentationNotSupported     uint16 = 54
	ErrorCodeInvalidTag                        uint16 = 57
	ErrorCodeNetworkDown                       uint16 = 58
	ErrorCodeRejectUnrecognizedService         uint16 = 67
	ErrorCodeUnknownDevice                     uint16 = 70
	ErrorCodeUnknownRoute                      uint16 = 71
	ErrorCodeValueNotInitialized               uint16 = 72
	ErrorCodeInvalidEventState                 uint16 = 73
	ErrorCodeNoAlarmConfigured                 uint16 = 74
	ErrorCodeLogBufferFull                     uint16 = 75
	ErrorCodeLoggedValuePurged                 uint16 = 76
	ErrorCodeNoPropertySpecified               uint16 = 77
	ErrorCodeNotConfiguredForTriggeredLogging  uint16 = 78
	ErrorCodeUnknownSubscription               uint16 = 79
	ErrorCodeParameterOutOfRange               uint16 = 80
	ErrorCodeListElementNotFound               uint16 = 81
	ErrorCodeBusy                              uint16 = 82
	ErrorCodeCommunicationDisabled             uint16 = 83
	ErrorCodeSuccess                           uint16 = 84
	ErrorCodeAccessDenied                      uint16 = 85
	ErrorCodeUnknownFileSize                   uint16 = 122
	ErrorCodeFileFull                          uint16 = 128
	ErrorCodeInternalError                     uint16 = 131
	ErrorCodeNotConfigured                     uint16 = 132
	ErrorCodeOutOfMemory                       uint16 = 133
	ErrorCodeValueTooLong                      uint16 = 134
)

Commonly tested BACnet Error Code values (ASHRAE 135 BACnetErrorCode), in numeric order. ErrorCodeName knows the full standard set.

View Source
const (
	RejectReasonOther                    uint8 = 0
	RejectReasonBufferOverflow           uint8 = 1
	RejectReasonInconsistentParameters   uint8 = 2
	RejectReasonInvalidParameterDataType uint8 = 3
	RejectReasonInvalidTag               uint8 = 4
	RejectReasonMissingRequiredParameter uint8 = 5
	RejectReasonParameterOutOfRange      uint8 = 6
	RejectReasonTooManyArguments         uint8 = 7
	RejectReasonUndefinedEnumeration     uint8 = 8
	RejectReasonUnrecognizedService      uint8 = 9
)

BACnet Reject reasons (ASHRAE 135 BACnetRejectReason).

View Source
const (
	AbortReasonOther                         uint8 = 0
	AbortReasonBufferOverflow                uint8 = 1
	AbortReasonInvalidAPDUInThisState        uint8 = 2
	AbortReasonPreemptedByHigherPriorityTask uint8 = 3
	AbortReasonSegmentationNotSupported      uint8 = 4
	AbortReasonSecurityError                 uint8 = 5
	AbortReasonInsufficientSecurity          uint8 = 6
	AbortReasonWindowSizeOutOfRange          uint8 = 7
	AbortReasonApplicationExceededReplyTime  uint8 = 8
	AbortReasonOutOfResources                uint8 = 9
	AbortReasonTSMTimeout                    uint8 = 10
	AbortReasonAPDUTooLong                   uint8 = 11
)

BACnet Abort reasons (ASHRAE 135 BACnetAbortReason).

View Source
const (
	CharacterEncodingUTF8     uint8 = 0 // ISO 10646 (UTF-8), formerly ANSI X3.4
	CharacterEncodingDBCS     uint8 = 1 // IBM/Microsoft DBCS
	CharacterEncodingJIS      uint8 = 2 // JIS X 0208
	CharacterEncodingUCS4     uint8 = 3 // ISO 10646 (UCS-4), big-endian
	CharacterEncodingUCS2     uint8 = 4 // ISO 10646 (UCS-2), big-endian
	CharacterEncodingISO88591 uint8 = 5 // ISO 8859-1
)

Character string encodings (ASHRAE 135 Clause 20.2.9).

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).

View Source
const WildcardInstance = MaxObjectInstance

WildcardInstance is the "unknown instance" value. A Device object identifier carrying it addresses whichever device receives the request, and the reply names the device's real instance.

Variables

View Source
var (
	ErrClosed  = errors.New("bacnet: client closed")
	ErrTimeout = errors.New("bacnet: request timeout")
	// Deprecated: ErrTransactionCapacity is never returned. A request that
	// finds all invoke IDs in use waits for one until its context ends.
	ErrTransactionCapacity = errors.New("bacnet: transaction capacity exhausted")
	ErrMalformed           = errors.New("bacnet: malformed encoding")
	ErrUnsupported         = errors.New("bacnet: unsupported")
	// Deprecated: ErrResponseSourceMismatch is never returned. A response
	// from an unexpected source is dropped (diagnostic "wrong_source") and
	// the request runs into its timeout.
	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")
	// Deprecated: ErrDeliveryDropped is never returned. Dropped notifications
	// are signalled by SubscriptionEvent.Gap and EventStreamEvent.Gap.
	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")
	// ErrInvalidConfig is returned by client.New when an option carries a
	// value the client cannot run with.
	ErrInvalidConfig = errors.New("bacnet: invalid configuration")
)

Local/runtime sentinels.

Functions

func AbortReasonName added in v0.4.0

func AbortReasonName(reason uint8) string

AbortReasonName returns the standard name of a BACnet abort reason, or "reason-N" (reasons ≥ 64 are vendor-proprietary).

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 AppendContextReal added in v0.4.0

func AppendContextReal(dst []byte, tagNumber uint8, v float32) ([]byte, error)

AppendContextReal appends a context-tagged REAL (4 content octets).

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.

A context element whose Value is a typed primitive (for example Element{Context: true, TagNumber: 1, Value: RealValue(1)}) is encoded as a context-tagged primitive carrying that value's content octets; a context BOOLEAN is one octet. A ValueContext value contributes its raw OctetString. A value that cannot be encoded returns an error; nothing is dropped silently.

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 ContextReal added in v0.4.0

func ContextReal(el Element) (float32, error)

ContextReal extracts a REAL from a context primitive element.

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 ContextUnsigned32 added in v0.4.0

func ContextUnsigned32(el Element) (uint32, error)

ContextUnsigned32 extracts an unsigned from a context primitive element and rejects values that do not fit in 32 bits, so identifiers, indexes and counts are never truncated silently.

func DecodeBACnetError

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

DecodeBACnetError parses a BACnet-Error structure.

Two encodings appear on the wire:

  1. Application ENUMERATED class then ENUMERATED code — the standard form, sent by every peer stack and by this library's encoder;
  2. Context [0] class / [1] code (unsigned or enumerated content) — a non-standard form this library emitted up to v0.3.0, still accepted.

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 the BACnet Error production,

Error ::= SEQUENCE { error-class ENUMERATED, error-code ENUMERATED }

as two application-tagged ENUMERATEDs (class 2, code 32 → 91 02 91 20). Releases up to v0.3.0 emitted context tags [0] and [1] instead, which no other stack produces; DecodeBACnetError still reads that form.

func EncodeObjectIdentifier

func EncodeObjectIdentifier(id ObjectIdentifier) (uint32, error)

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

func ErrorClassName added in v0.4.0

func ErrorClassName(class uint16) string

ErrorClassName returns the standard name of a BACnet error class, or "class-N" for a value the standard does not define (classes ≥ 64 are vendor-proprietary).

func ErrorCodeName added in v0.4.0

func ErrorCodeName(code uint16) string

ErrorCodeName returns the standard name of a BACnet error code, or "code-N" for a value this library has no name for (codes ≥ 256 are vendor-proprietary).

func IsContextConstructed

func IsContextConstructed(el Element) bool

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

func RejectReasonName added in v0.4.0

func RejectReasonName(reason uint8) string

RejectReasonName returns the standard name of a BACnet reject reason, or "reason-N" (reasons ≥ 64 are vendor-proprietary).

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 a BACnetHostNPort: host [0] { none [0] | ip-address [1] | name [2] } followed by 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 from a constructed value holding exactly one context element: date [0], dateRange [1] or weekNDay [2].

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.

Value holds the raw string octets exactly as they appear on the wire after the encoding octet; it is only valid Go text when Encoding is CharacterEncodingUTF8. Use Text to obtain a Go string for the other supported encodings.

func ContextCharacterString added in v0.2.0

func ContextCharacterString(el Element) (CharacterString, error)

ContextCharacterString extracts a character string from a context primitive.

func (CharacterString) Text added in v0.4.0

func (c CharacterString) Text() (string, error)

Text converts the string octets to a Go (UTF-8) string.

UTF-8 (0) is validated, UCS-4 (3) and UCS-2 (4) are decoded as big-endian code units, and ISO 8859-1 (5) is mapped octet by octet. DBCS (1), JIS X 0208 (2) and unknown encodings return an error wrapping ErrUnsupported; octets that are not valid for the declared encoding return an error wrapping ErrMalformed.

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)

DecodeDailySchedule decodes a DailySchedule: one context [0] constructed element holding a flat sequence of (Time, value) application-tag pairs, as ParseSequence returns it from the wire.

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.

func ContextDate added in v0.4.0

func ContextDate(el Element) (Date, error)

ContextDate extracts a Date from a context primitive element.

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 name is present and IP is ignored
	None bool   // host is the "none" alternative; IP and Name are ignored
	Port uint16
}

HostNPort is BACnetHostNPort:

host [0] BACnetHostAddress CHOICE {
  none       [0] NULL,
  ip-address [1] OCTET STRING,
  name       [2] CharacterString }
port [1] Unsigned16

A non-empty Name selects the name alternative, None selects none, and otherwise the IPv4 address in IP is encoded as ip-address.

func DecodeHostNPort added in v0.3.0

func DecodeHostNPort(v ApplicationValue) (HostNPort, error)

DecodeHostNPort decodes a BACnetHostNPort from wire elements or from a value built by EncodeHostNPort. Only 4-octet (IPv4) ip-address values are supported; other lengths return an error wrapping ErrUnsupported.

type LifeSafetyMode added in v0.3.0

type LifeSafetyMode uint32

LifeSafetyMode is BACnetLifeSafetyMode.

const (
	LifeSafetyModeOff                      LifeSafetyMode = 0
	LifeSafetyModeOn                       LifeSafetyMode = 1
	LifeSafetyModeTest                     LifeSafetyMode = 2
	LifeSafetyModeManned                   LifeSafetyMode = 3
	LifeSafetyModeUnmanned                 LifeSafetyMode = 4
	LifeSafetyModeArmed                    LifeSafetyMode = 5
	LifeSafetyModeDisarmed                 LifeSafetyMode = 6
	LifeSafetyModePrearmed                 LifeSafetyMode = 7
	LifeSafetyModeSlow                     LifeSafetyMode = 8
	LifeSafetyModeFast                     LifeSafetyMode = 9
	LifeSafetyModeDisconnected             LifeSafetyMode = 10
	LifeSafetyModeEnabled                  LifeSafetyMode = 11
	LifeSafetyModeDisabled                 LifeSafetyMode = 12
	LifeSafetyModeAutomaticReleaseDisabled LifeSafetyMode = 13
	LifeSafetyModeDefault                  LifeSafetyMode = 14
)

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 = 0
	LifeSafetyStatePreAlarm        LifeSafetyState = 1
	LifeSafetyStateAlarm           LifeSafetyState = 2
	LifeSafetyStateFault           LifeSafetyState = 3
	LifeSafetyStateFaultPreAlarm   LifeSafetyState = 4
	LifeSafetyStateFaultAlarm      LifeSafetyState = 5
	LifeSafetyStateNotReady        LifeSafetyState = 6
	LifeSafetyStateActive          LifeSafetyState = 7
	LifeSafetyStateTamper          LifeSafetyState = 8
	LifeSafetyStateTestAlarm       LifeSafetyState = 9
	LifeSafetyStateTestActive      LifeSafetyState = 10
	LifeSafetyStateTestFault       LifeSafetyState = 11
	LifeSafetyStateTestFaultAlarm  LifeSafetyState = 12
	LifeSafetyStateHoldup          LifeSafetyState = 13
	LifeSafetyStateDuress          LifeSafetyState = 14
	LifeSafetyStateTamperAlarm     LifeSafetyState = 15
	LifeSafetyStateAbnormal        LifeSafetyState = 16
	LifeSafetyStateEmergencyPower  LifeSafetyState = 17
	LifeSafetyStateDelayed         LifeSafetyState = 18
	LifeSafetyStateBlocked         LifeSafetyState = 19
	LifeSafetyStateLocalAlarm      LifeSafetyState = 20
	LifeSafetyStateGeneralAlarm    LifeSafetyState = 21
	LifeSafetyStateSupervisory     LifeSafetyState = 22
	LifeSafetyStateTestSupervisory LifeSafetyState = 23
)

type LockStatus added in v0.3.0

type LockStatus uint32

LockStatus is BACnetLockStatus.

const (
	LockStatusLocked    LockStatus = 0
	LockStatusUnlocked  LockStatus = 1
	LockStatusLockFault LockStatus = 2
	LockStatusUnused    LockStatus = 3
	LockStatusUnknown   LockStatus = 4
)

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 AnyDevice added in v0.4.0

func AnyDevice() ObjectIdentifier

AnyDevice returns the Device object identifier with the wildcard instance. Reading it from a known address is the standard way to learn the instance of a device that was not discovered with Who-Is.

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) Matches added in v0.4.0

func (id ObjectIdentifier) Matches(got ObjectIdentifier) bool

Matches reports whether a reply naming got answers a request for id: the identifiers are equal, or id is the Device wildcard and got is a Device.

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

String returns the standard object type name (for example "analog-input"), or "ObjectType(n)" for values this module does not name.

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 (
	PropertyAll      PropertyIdentifier = 8
	PropertyOptional PropertyIdentifier = 80
	PropertyRequired PropertyIdentifier = 105
)

Special property identifiers of ReadPropertyMultiple: a device answers each with every property of the object in that conformance class.

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

String returns the standard property name (for example "present-value"), or "PropertyIdentifier(n)" for values this module does not name.

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
}

ScheduledTimeValue is BACnetTimeValue (time + primitive 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; OctetString holds the raw content octets
)

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. Each element is either the day's context [0] constructed element (wire form, as returned by ParseSequence or ReadProperty) or a value built by EncodeWeeklySchedule.

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.
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