Skip to content
Version 6.1.0
Contact Us

API Reference

This is the per-function reference for the Customer API of the CAS BACnet Stack: the BACnetStack_* functions your application calls, and the callback signatures your application implements and registers with them.

It is written for advanced integrators who work below the level of the getting-started material. **If you are starting out, begin with the Quick Start and the example projects** on Chipkin’s GitHub. Come back here when you need the exact contract of a function.

Every exported function belongs to one topic, and each topic page starts with an overview of how its functions fit together:

The Files list also has the two headers themselves. CASBACnetStackDLL.h lists every exported function in one place, and BACnetCallbackInterface.h has the signatures of the callbacks your application implements: the FPCallback* and FPHook* types passed to the BACnetStack_RegisterCallback* and BACnetStack_RegisterHook* functions.

To Use
Add your device BACnetStack_AddDevice()
Add an object BACnetStack_AddObject(), or the type’s own add function (see the object type pages)
Connect a data link BACnetStack_RegisterCallbackSendMessageForPort(), BACnetStack_RegisterCallbackReceiveMessageForPort() and BACnetStack_AddNetworkPortObject()
Run the stack BACnetStack_Tick()
Serve a property’s value The Get callback for its datatype, such as BACnetStack_RegisterCallbackGetPropertyReal()
Turn an optional property on BACnetStack_SetPropertyEnabled()
Let clients write a property BACnetStack_SetPropertyWritable(), and the Set callback for its datatype, such as BACnetStack_RegisterCallbackSetPropertyReal()
Offer a service BACnetStack_SetServiceEnabled()
Tell the stack a value changed BACnetStack_UpdateValue()
Give the stack a clock BACnetStack_RegisterCallbackGetSystemTime()
Announce the device BACnetStack_SendIAm()
Find other devices BACnetStack_SendWhoIs() and BACnetStack_RegisterHookIAm()
Read or write a property on another device BACnetStack_SendReadProperty() and BACnetStack_SendWriteProperty()
Learn that a request failed or timed out BACnetStack_RegisterHookError() and BACnetStack_RegisterHookTimeout()
Arm an alarm BACnetStack_SetAlarmsAndEventsForObjectEnabled(), the object type’s intrinsic algorithm setter and BACnetStack_AddNotificationClassObject()
Log a value over time BACnetStack_AddTrendLogObject()
Run a schedule BACnetStack_AddScheduleObject()
Act as a BBMD, or register as a foreign device BACnetStack_SetBBMD() and BACnetStack_SendRegisterForeignDevice()
Connect to a BACnet/SC hub BACnetStack_SetBACnetSCHubConnector()
Find out why a call failed BACnetStack_RegisterCallbackLogDebugMessage()
Decode a message as XML or JSON BACnetStack_DecodeAs()
Start again from nothing BACnetStack_Reset()

The task-oriented guides to how the pieces fit together are chapters of the manual. Each one links into this reference for per-function detail.

The full rules are on the API conventions page. The rules most integrations depend on are:

  • By default the stack is single-threaded. Make every BACnetStack_* call, including BACnetStack_Tick(), from the same thread, or build with STACK_OPTION_THREAD_SAFE (see the API conventions page).
  • Call BACnetStack_Tick() repeatedly. Incoming messages are processed, and timers, retries and timeouts advance, only inside it. (A BACnetStack_Send* call transmits immediately through the send message callback.) Register the send and receive message callbacks before the first tick.
  • A false return means the call did not succeed. The return value does not say why. 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.
  • There is one stack per process, and no explicit initialization call. Make your first call from main() or later, never from a static initializer.

Parameters such as objectType, propertyIdentifier and errorCode, and the enumerated property values passed through the property callbacks, are plain integers that carry BACnet enumeration values. The Enumerations section lists the BACnet enumerations, the bit numbers of the bit strings (such as the service numbers BACnetStack_SetServiceEnabled() takes) and the datatype codes, with their values in numeric order and the parameters that refer to them.

The test-tool interface (BACnetStackTestTool_*) exists only in test-tool builds, and is not part of the Customer API. The stack’s internal classes are not documented here.