Skip to content
Version 6.1.0
Contact Us

Data link and system callbacks

Sending, receiving, time and logging.

Every application registers the send and receive message callbacks, before the first BACnetStack_Tick(); without them the device can neither hear nor answer. The system time callback is required by several features (foreign-device registration, confirmed requests, event timestamps). In a build with STACK_OPTION_API_DEBUG_LOGGING (on in the prebuilt libraries and the npm package), the debug-message callback reports the reason for a false return. See Data links overview.

Function Summary
BACnetStack_RegisterCallbackReceiveMessageForPort() Registers the callback the stack calls to pull one inbound raw BACnet message from the host’s transport layer.
BACnetStack_RegisterCallbackSendMessageForPort() Registers the callback the stack calls to hand one outbound raw BACnet frame to the host’s transport layer.
BACnetStack_RegisterCallbackMSTPReceiveBytes() Registers the callback the stack calls from BACnetStack_LoopMSTP() to take the octets the RS-485 receiver has already received.
BACnetStack_RegisterCallbackMSTPSendBytes() Registers the callback the stack calls from BACnetStack_LoopMSTP() to write one complete MS/TP frame to the wire.
BACnetStack_RegisterCallbackMSTPMicroseconds() Registers the clock the stack’s MS/TP engine runs on: one monotonic microsecond counter that wraps at 2^32.
BACnetStack_RegisterCallbackMSTPTransmitEnable() Registers the optional callback that switches the RS-485 driver.
BACnetStack_RegisterCallbackMSTPFrameHeader() Registers the optional diagnostic callback that reports each valid frame header the stack hears, any destination, never a frame it sent.
BACnetStack_ReportMSTPReceiveError() Reports a receive error (a UART framing, overrun or parity error) on an MS/TP port in byte mode.
BACnetStack_LoopMSTP() Runs the stack-owned MS/TP engine of one port: applies a new configuration, moves queued NPDUs into the engine, reads the octets the receive callback has, advances the receive and master-node state machines over them, sends what they decide to send, and returns.
BACnetStack_GetMSTPCounters() Reads the counters of an MS/TP port’s stack-owned engine into an array, one entry per BACnetMSTPCounter value.
BACnetStack_RegisterCallbackGetSystemTime() Registers a callback the stack calls to get the host’s current system time (used to timestamp generated events/logs and for time-based processing).
BACnetStack_RegisterCallbackSetSystemTime() Registers a callback the stack calls to set the host’s system time, in response to a TimeSynchronization or UTCTimeSynchronization BACnet message.
BACnetStack_RegisterCallbackLogDebugMessage() Registers the callback that receives the stack’s own diagnostic log lines.