Skip to content
Version 6.1.0
Contact Us

BACnetStack_AddRouterPort

bool BACnetStack_AddRouterPort(
const uint32_t deviceInstance,
const uint8_t portId,
const uint16_t networkNumber,
const uint8_t networkType);

Registers a directly connected network for physical inter-datalink routing (ASHRAE 135 cl. 6.6).

Call once per Network Port that should participate. Two or more ports make the device a BACnet router; a single port routes nothing. Network numbers must be unique across ports.

This is independent of BACnetStack_AddVirtualNetwork() - a device may route between real ports, between virtual networks, or both.

BACnet reference: ANSI/ASHRAE 135-2024 clause 6.6 (BACnet Routers).

Parameter Direction Description
deviceInstance in The instance number of the main device.
portId in The router port identifier, as reported in the Routing_Table property (cl. 12.56.62). 0 is rejected: in an Initialize-Routing-Table(-Ack) a Port ID of zero tells the receiver to purge its entries for that network (cl. 6.4.7).
networkNumber in The network number directly connected to this port. 0 and 65535 are reserved and rejected.
networkType in The datalink behind this port: 0 = BACnet/IP, 1 = MS/TP, 2 = BACnet/SC; any other value is refused. These are the stack’s packet network types (the values BACnetStack_DecodeAs() takes too), not BACnetNetworkType (where IPv4 is 5). Determines the BACnet/SC forwarding rules (NPDU size floor, data-attribute and Secure Path handling). This is the second deliberate exception to the Network Port instance convention every other Send/Receive export follows: a router port is a distinct routing-layer concept from a Network Port object.

True if the port was registered, otherwise false.

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