pub struct NetworkLayer<T: TransportPort> { /* private fields */ }Expand description
Non-router BACnet network layer.
Wraps a TransportPort and provides APDU-level send/receive by handling
NPDU framing. This layer does not act as a router (it does not forward
messages between networks), but it can send to remote devices through
local routers using NPDU destination addressing.
Implementations§
Source§impl<T: TransportPort + 'static> NetworkLayer<T>
impl<T: TransportPort + 'static> NetworkLayer<T>
Sourcepub async fn start(&mut self) -> Result<Receiver<ReceivedApdu>, Error>
pub async fn start(&mut self) -> Result<Receiver<ReceivedApdu>, Error>
Start the network layer. Returns a receiver for incoming APDUs.
This starts the underlying transport and spawns a dispatch task that decodes incoming NPDUs and extracts APDUs.
Sourcepub async fn send_apdu(
&self,
apdu: &[u8],
destination_mac: &[u8],
expecting_reply: bool,
priority: NetworkPriority,
) -> Result<(), Error>
pub async fn send_apdu( &self, apdu: &[u8], destination_mac: &[u8], expecting_reply: bool, priority: NetworkPriority, ) -> Result<(), Error>
Send an APDU to a specific local destination by MAC address.
Sourcepub async fn broadcast_apdu(
&self,
apdu: &[u8],
expecting_reply: bool,
priority: NetworkPriority,
) -> Result<(), Error>
pub async fn broadcast_apdu( &self, apdu: &[u8], expecting_reply: bool, priority: NetworkPriority, ) -> Result<(), Error>
Broadcast an APDU on the local network.
Sourcepub async fn broadcast_global_apdu(
&self,
apdu: &[u8],
expecting_reply: bool,
priority: NetworkPriority,
) -> Result<(), Error>
pub async fn broadcast_global_apdu( &self, apdu: &[u8], expecting_reply: bool, priority: NetworkPriority, ) -> Result<(), Error>
Broadcast an APDU globally (DNET=0xFFFF, hop_count=255).
Unlike broadcast_apdu() which only reaches the local subnet, this
sets DNET=0xFFFF so routers will forward to all reachable networks.
Sourcepub async fn broadcast_to_network(
&self,
apdu: &[u8],
dest_network: u16,
expecting_reply: bool,
priority: NetworkPriority,
) -> Result<(), Error>
pub async fn broadcast_to_network( &self, apdu: &[u8], dest_network: u16, expecting_reply: bool, priority: NetworkPriority, ) -> Result<(), Error>
Broadcast an APDU to a specific remote network via routers.
Like broadcast_global_apdu() but targets a single network number
instead of all networks (DNET=0xFFFF).
Sourcepub async fn send_apdu_routed(
&self,
apdu: &[u8],
dest_network: u16,
dest_mac: &[u8],
router_mac: &[u8],
expecting_reply: bool,
priority: NetworkPriority,
) -> Result<(), Error>
pub async fn send_apdu_routed( &self, apdu: &[u8], dest_network: u16, dest_mac: &[u8], router_mac: &[u8], expecting_reply: bool, priority: NetworkPriority, ) -> Result<(), Error>
Send an APDU to a remote device through a local router.
The NPDU is sent via unicast to router_mac (the next-hop router on
the local network), but the NPDU header addresses the final destination
with dest_network / dest_mac.