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 ¶
- Constants
- Variables
- func AbortReasonName(reason uint8) string
- func AppendApplicationValue(dst []byte, v ApplicationValue) ([]byte, error)
- func AppendContextBitString(dst []byte, tagNumber uint8, v BitString) ([]byte, error)
- func AppendContextBool(dst []byte, tagNumber uint8, v bool) ([]byte, error)
- func AppendContextCharacterString(dst []byte, tagNumber uint8, v CharacterString) ([]byte, error)
- func AppendContextNull(dst []byte, tagNumber uint8) ([]byte, error)
- func AppendContextObjectID(dst []byte, tagNumber uint8, id ObjectIdentifier) ([]byte, error)
- func AppendContextReal(dst []byte, tagNumber uint8, v float32) ([]byte, error)
- func AppendContextSigned(dst []byte, tagNumber uint8, v int64) ([]byte, error)
- func AppendContextTagged(dst []byte, tagNumber uint8, body []Element) ([]byte, error)
- func AppendContextTime(dst []byte, tagNumber uint8, t Time) ([]byte, error)
- func AppendContextUnsigned(dst []byte, tagNumber uint8, v uint64) ([]byte, error)
- func AppendObjectIdentifier(dst []byte, id ObjectIdentifier) ([]byte, error)
- func AppendTag(dst []byte, el Element) ([]byte, error)
- func AsBool(v ApplicationValue) (bool, error)
- func AsEnumerated(v ApplicationValue) (uint32, error)
- func AsReal(v ApplicationValue) (float32, error)
- func AsUnsigned(v ApplicationValue) (uint64, error)
- func ContextBool(el Element) (bool, error)
- func ContextReal(el Element) (float32, error)
- func ContextSigned(el Element) (int64, error)
- func ContextUnsigned(el Element) (uint64, error)
- func ContextUnsigned32(el Element) (uint32, error)
- func DecodeBACnetError(elements []Element) (class, code uint16, err error)
- func DecodePropertyValue(objectType ObjectType, property PropertyIdentifier, value ApplicationValue) (any, bool, error)
- func EncodeBACnetError(dst []byte, class, code uint16) ([]byte, error)
- func EncodeObjectIdentifier(id ObjectIdentifier) (uint32, error)
- func ErrorClassName(class uint16) string
- func ErrorCodeName(code uint16) string
- func IsContextConstructed(el Element) bool
- func RejectReasonName(reason uint8) string
- type APDUTooLargeError
- type AbortError
- type Address
- type AddressScope
- type ApplicationTag
- type ApplicationValue
- func BoolValue(b bool) ApplicationValue
- func DateValue(d Date) ApplicationValue
- func DoubleValue(f float64) ApplicationValue
- func EncodeCalendarEntry(e CalendarEntry) (ApplicationValue, error)
- func EncodeDailySchedule(d DailySchedule) ApplicationValue
- func EncodeDateRange(dr DateRange) ApplicationValue
- func EncodeDateTime(dt DateTime) ApplicationValue
- func EncodeHostNPort(h HostNPort) ApplicationValue
- func EncodeWeeklySchedule(w WeeklySchedule) ApplicationValue
- func EnumValue(e uint32) ApplicationValue
- func NullValue() ApplicationValue
- func ObjectIDValue(id ObjectIdentifier) ApplicationValue
- func ParseApplicationValue(data []byte, limits DecodeLimits) (ApplicationValue, int, error)
- func RealValue(f float32) ApplicationValue
- func SignedValue(s int64) ApplicationValue
- func TimeValue(t Time) ApplicationValue
- func UnsignedValue(u uint64) ApplicationValue
- type BitString
- type CalendarEntry
- type CalendarEntryChoice
- type CharacterString
- type DailySchedule
- type Date
- type DateRange
- type DateTime
- type DecodeLimits
- type DoorStatus
- type Element
- type ErrorResponse
- type ExceptionSchedule
- type HostNPort
- type LifeSafetyMode
- type LifeSafetyOperation
- type LifeSafetyState
- type LockStatus
- type MAC
- type ObjectIdentifier
- type ObjectType
- type OutcomeUnknownError
- type PropertyIdentifier
- type PropertyReference
- type RejectError
- type ScheduledTimeValue
- type SpecialEvent
- type Time
- type TimeStamp
- type TimeStampChoice
- type ValueKind
- type WeekNDay
- type WeeklySchedule
Examples ¶
Constants ¶
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).
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.
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).
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).
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).
const ArrayAll uint32 = 0xFFFFFFFF
ArrayAll selects all array elements.
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).
const MaxObjectInstance = 0x3FFFFF
MaxObjectInstance is the largest valid object instance (22 bits).
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 ¶
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
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
AppendContextBitString appends a context-tagged bit string.
func AppendContextBool ¶
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 ¶
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
AppendContextReal appends a context-tagged REAL (4 content octets).
func AppendContextSigned ¶ added in v0.2.0
AppendContextSigned appends a context-tagged signed integer.
func AppendContextTagged ¶
AppendContextTagged appends opening tag, body tags, and closing tag.
func AppendContextTime ¶ added in v0.2.0
AppendContextTime appends a context-tagged Time (4 octets).
func AppendContextUnsigned ¶
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 ¶
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 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 ¶
ContextBool extracts a context-tagged BOOLEAN (exactly one octet 0 or 1).
func ContextReal ¶ added in v0.4.0
ContextReal extracts a REAL from a context primitive element.
func ContextSigned ¶ added in v0.2.0
ContextSigned extracts a signed integer from a context primitive element.
func ContextUnsigned ¶
ContextUnsigned extracts an unsigned from a context primitive element.
func ContextUnsigned32 ¶ added in v0.4.0
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 ¶
DecodeBACnetError parses a BACnet-Error structure.
Two encodings appear on the wire:
- Application ENUMERATED class then ENUMERATED code — the standard form, sent by every peer stack and by this library's encoder;
- 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 ¶
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
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
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 ¶
IsContextConstructed reports a context-tagged constructed (open/close) value.
func RejectReasonName ¶ added in v0.4.0
RejectReasonName returns the standard name of a BACnet reject reason, or "reason-N" (reasons ≥ 64 are vendor-proprietary).
Types ¶
type APDUTooLargeError ¶
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 ¶
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 ¶
LocalStation returns a local unicast BACnet address.
func RemoteBroadcast ¶
RemoteBroadcast returns a remote broadcast on network.
func RemoteStation ¶
RemoteStation returns a remote unicast address on network.
func (Address) IsBroadcast ¶
IsBroadcast reports whether the address is any broadcast 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 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 ¶
func (v ApplicationValue) Clone() ApplicationValue
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 ¶
BitString holds a BACnet bit string.
func ContextBitString ¶ added in v0.2.0
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 ¶
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
ContextDate extracts a Date from a context primitive element.
type DateRange ¶ added in v0.3.0
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
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 ¶
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).
type ErrorResponse ¶
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.
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 ¶
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 ¶
func (p PropertyReference) Equal(o PropertyReference) bool
Equal reports whether p and o identify the same property reference.
type RejectError ¶
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 ¶
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
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 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.
Source Files
¶
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. |