Skip to content
Version 6.1.0
Contact Us

BACnetStack_AddVirtualNetwork

bool BACnetStack_AddVirtualNetwork(
const uint32_t deviceInstance,
const uint16_t network,
const uint32_t virtualNetworkPortInstance);

Adds a virtual network.

Must be called after BACnetStack_AddDevice().

Every refusal listed under the parameters below is checked before anything is changed. NOT ATOMIC after that: if a step after the network is registered fails - creating the Network Port object, setting its Network_Number or Network_Number_Quality - this returns false with the virtual network ALREADY registered and the device ALREADY switched to virtual-router mode. There is no removal API; discard the stack with BACnetStack_Reset() and reconfigure.

Side effects on success: the device becomes a virtual router; a Network Port object is created with Network_Number set and Network_Number_Quality = CONFIGURED; and Network_Number is made writable on EVERY Network Port object of this device, not only the new one.

Parameter Direction Description
deviceInstance in The device instance of the virtual router device. Must be the instance passed to BACnetStack_AddDevice(); any other value is rejected.
network in The virtual network to create. 0 (local) and 65535 (broadcast) are reserved and rejected, as is a number already added as a virtual network, already served by a physical router port added with BACnetStack_AddRouterPort(), already routed through a router port with BACnetStack_AddRouterRoute(), or already the Network_Number (active or pending) of one of this device’s Network Port objects.
virtualNetworkPortInstance in The object instance of the Network Port object created for this virtual network, 0 to 4194302 inclusive. It must be a new object: an instance that already exists as a Network Port object of this device is rejected.

True if successful, otherwise false. Also false if the stack was built without STACK_OPTION_VIRTUAL_ROUTER. The reason is reported through the debug-message callback.

Topic: Routing and virtual networks. Declared in CASBACnetStackDLL.h.