Skip to main content

BACnetClient

Struct BACnetClient 

Source
pub struct BACnetClient<T: TransportPort> { /* private fields */ }
Expand description

BACnet client with low-level and high-level request APIs.

Implementations§

Source§

impl BACnetClient<BipTransport>

Source

pub fn bip_builder() -> BipClientBuilder

Create a BIP-specific builder with interface/port/broadcast fields.

Source

pub fn builder() -> BipClientBuilder

Source

pub async fn read_bdt(&self, target: &[u8]) -> Result<Vec<BdtEntry>, Error>

Read the Broadcast Distribution Table from a BBMD.

Source

pub async fn write_bdt( &self, target: &[u8], entries: &[BdtEntry], ) -> Result<BvlcResultCode, Error>

Write the Broadcast Distribution Table to a BBMD.

Source

pub async fn read_fdt(&self, target: &[u8]) -> Result<Vec<FdtEntryWire>, Error>

Read the Foreign Device Table from a BBMD.

Source

pub async fn delete_fdt_entry( &self, target: &[u8], ip: [u8; 4], port: u16, ) -> Result<BvlcResultCode, Error>

Delete a Foreign Device Table entry on a BBMD.

Source

pub async fn register_foreign_device_bvlc( &self, target: &[u8], ttl: u16, ) -> Result<BvlcResultCode, Error>

Register as a foreign device with a BBMD and return the result code.

Source§

impl<T: TransportPort + 'static> BACnetClient<T>

Source

pub fn generic_builder() -> ClientBuilder<T>

Create a generic builder that accepts a pre-built transport.

Source

pub async fn start(config: ClientConfig, transport: T) -> Result<Self, Error>

Start the client: bind transport, start network layer, spawn dispatch.

Source

pub fn local_mac(&self) -> &[u8]

Get the client’s local MAC address.

Source

pub async fn confirmed_request( &self, destination_mac: &[u8], service_choice: ConfirmedServiceChoice, service_data: &[u8], ) -> Result<Bytes, Error>

Send a confirmed request and wait for the response.

Returns the service response data (empty for SimpleAck). Automatically uses segmented transfer when the payload exceeds the remote device’s max APDU length.

Source

pub async fn confirmed_request_routed( &self, router_mac: &[u8], dest_network: u16, dest_mac: &[u8], service_choice: ConfirmedServiceChoice, service_data: &[u8], ) -> Result<Bytes, Error>

Send a confirmed request routed through a BACnet router.

The NPDU is sent as a unicast to router_mac with DNET/DADR set so the router forwards it to dest_network/dest_mac.

Source

pub async fn unconfirmed_request( &self, destination_mac: &[u8], service_choice: UnconfirmedServiceChoice, service_data: &[u8], ) -> Result<(), Error>

Send an unconfirmed request (fire-and-forget) to a specific destination.

Source

pub async fn broadcast_unconfirmed( &self, service_choice: UnconfirmedServiceChoice, service_data: &[u8], ) -> Result<(), Error>

Broadcast an unconfirmed request on the local network.

Source

pub async fn broadcast_global_unconfirmed( &self, service_choice: UnconfirmedServiceChoice, service_data: &[u8], ) -> Result<(), Error>

Broadcast an unconfirmed request globally (DNET=0xFFFF).

Source

pub async fn broadcast_network_unconfirmed( &self, service_choice: UnconfirmedServiceChoice, service_data: &[u8], dest_network: u16, ) -> Result<(), Error>

Broadcast an unconfirmed request to a specific remote network.

Source

pub async fn read_property( &self, destination_mac: &[u8], object_identifier: ObjectIdentifier, property_identifier: PropertyIdentifier, property_array_index: Option<u32>, ) -> Result<ReadPropertyACK, Error>

Read a property from a remote device.

Source

pub async fn read_property_from_device( &self, device_instance: u32, object_identifier: ObjectIdentifier, property_identifier: PropertyIdentifier, property_array_index: Option<u32>, ) -> Result<ReadPropertyACK, Error>

Read a property from a discovered device, auto-routing if needed.

Source

pub async fn read_property_routed( &self, router_mac: &[u8], dest_network: u16, dest_mac: &[u8], object_identifier: ObjectIdentifier, property_identifier: PropertyIdentifier, property_array_index: Option<u32>, ) -> Result<ReadPropertyACK, Error>

Read a property from a device on a remote BACnet network via a router.

Source

pub async fn write_property( &self, destination_mac: &[u8], object_identifier: ObjectIdentifier, property_identifier: PropertyIdentifier, property_array_index: Option<u32>, property_value: Vec<u8>, priority: Option<u8>, ) -> Result<(), Error>

Write a property on a remote device.

Source

pub async fn read_property_multiple( &self, destination_mac: &[u8], specs: Vec<ReadAccessSpecification>, ) -> Result<ReadPropertyMultipleACK, Error>

Read multiple properties from one or more objects on a remote device.

Source

pub async fn write_property_multiple( &self, destination_mac: &[u8], specs: Vec<WriteAccessSpecification>, ) -> Result<(), Error>

Write multiple properties on one or more objects on a remote device.

Source

pub async fn read_property_multiple_from_device( &self, device_instance: u32, specs: Vec<ReadAccessSpecification>, ) -> Result<ReadPropertyMultipleACK, Error>

Read multiple properties from a discovered device, auto-routing if needed.

Source

pub async fn write_property_to_device( &self, device_instance: u32, object_identifier: ObjectIdentifier, property_identifier: PropertyIdentifier, property_array_index: Option<u32>, property_value: Vec<u8>, priority: Option<u8>, ) -> Result<(), Error>

Write a property on a discovered device, auto-routing if needed.

Source

pub async fn write_property_multiple_to_device( &self, device_instance: u32, specs: Vec<WriteAccessSpecification>, ) -> Result<(), Error>

Write multiple properties on a discovered device, auto-routing if needed.

Source

pub async fn read_property_from_devices( &self, requests: Vec<DeviceReadRequest>, max_concurrent: Option<usize>, ) -> Vec<DeviceReadResult>

Read a property from multiple discovered devices concurrently.

All requests are dispatched concurrently (up to max_concurrent, default 32) and results are returned in completion order. Each device is resolved from the device table and auto-routed if behind a router.

Source

pub async fn read_property_multiple_from_devices( &self, requests: Vec<DeviceRpmRequest>, max_concurrent: Option<usize>, ) -> Vec<DeviceRpmResult>

Read multiple properties from multiple devices concurrently (RPM batch).

Sends an RPM to each device concurrently. This is the most efficient way to poll many properties across many devices — RPM batches within a single device, and this method batches across devices.

Source

pub async fn write_property_to_devices( &self, requests: Vec<DeviceWriteRequest>, max_concurrent: Option<usize>, ) -> Vec<DeviceWriteResult>

Write a property on multiple devices concurrently.

All writes are dispatched concurrently (up to max_concurrent, default 32). Results are returned in completion order.

Source

pub async fn who_is( &self, low_limit: Option<u32>, high_limit: Option<u32>, ) -> Result<(), Error>

Send a WhoIs broadcast to discover devices.

Source

pub async fn who_is_directed( &self, destination_mac: &[u8], low_limit: Option<u32>, high_limit: Option<u32>, ) -> Result<(), Error>

Send a directed (unicast) WhoIs to a specific device.

Source

pub async fn who_is_network( &self, dest_network: u16, low_limit: Option<u32>, high_limit: Option<u32>, ) -> Result<(), Error>

Send a WhoIs broadcast to a specific remote network.

Source

pub async fn who_has( &self, object: WhoHasObject, low_limit: Option<u32>, high_limit: Option<u32>, ) -> Result<(), Error>

Send a WhoHas broadcast to find an object by identifier or name.

Source

pub async fn subscribe_cov( &self, destination_mac: &[u8], subscriber_process_identifier: u32, monitored_object_identifier: ObjectIdentifier, confirmed: bool, lifetime: Option<u32>, ) -> Result<(), Error>

Subscribe to COV notifications for an object on a remote device.

Source

pub async fn unsubscribe_cov( &self, destination_mac: &[u8], subscriber_process_identifier: u32, monitored_object_identifier: ObjectIdentifier, ) -> Result<(), Error>

Cancel a COV subscription on a remote device.

Source

pub async fn delete_object( &self, destination_mac: &[u8], object_identifier: ObjectIdentifier, ) -> Result<(), Error>

Delete an object on a remote device.

Source

pub async fn create_object( &self, destination_mac: &[u8], object_specifier: ObjectSpecifier, initial_values: Vec<BACnetPropertyValue>, ) -> Result<Bytes, Error>

Create an object on a remote device.

Source

pub async fn device_communication_control( &self, destination_mac: &[u8], enable_disable: EnableDisable, time_duration: Option<u16>, password: Option<String>, ) -> Result<(), Error>

Send DeviceCommunicationControl to a remote device.

Source

pub async fn reinitialize_device( &self, destination_mac: &[u8], reinitialized_state: ReinitializedState, password: Option<String>, ) -> Result<(), Error>

Send ReinitializeDevice to a remote device.

Source

pub async fn get_event_information( &self, destination_mac: &[u8], last_received_object_identifier: Option<ObjectIdentifier>, ) -> Result<Bytes, Error>

Get event information from a remote device.

Source

pub async fn acknowledge_alarm( &self, destination_mac: &[u8], acknowledging_process_identifier: u32, event_object_identifier: ObjectIdentifier, event_state_acknowledged: u32, acknowledgment_source: &str, ) -> Result<(), Error>

Acknowledge an alarm on a remote device.

Source

pub async fn read_range( &self, destination_mac: &[u8], object_identifier: ObjectIdentifier, property_identifier: PropertyIdentifier, property_array_index: Option<u32>, range: Option<RangeSpec>, ) -> Result<ReadRangeAck, Error>

Read a range of items from a list or log-buffer property.

Source

pub async fn atomic_read_file( &self, destination_mac: &[u8], file_identifier: ObjectIdentifier, access: FileAccessMethod, ) -> Result<Bytes, Error>

Read file data from a remote device (stream or record access).

Source

pub async fn atomic_write_file( &self, destination_mac: &[u8], file_identifier: ObjectIdentifier, access: FileWriteAccessMethod, ) -> Result<Bytes, Error>

Write file data to a remote device (stream or record access).

Source

pub async fn add_list_element( &self, destination_mac: &[u8], object_identifier: ObjectIdentifier, property_identifier: PropertyIdentifier, property_array_index: Option<u32>, list_of_elements: Vec<u8>, ) -> Result<(), Error>

Add elements to a list property on a remote device.

Source

pub async fn remove_list_element( &self, destination_mac: &[u8], object_identifier: ObjectIdentifier, property_identifier: PropertyIdentifier, property_array_index: Option<u32>, list_of_elements: Vec<u8>, ) -> Result<(), Error>

Remove elements from a list property on a remote device.

Source

pub async fn time_synchronization( &self, destination_mac: &[u8], date: Date, time: Time, ) -> Result<(), Error>

Send a TimeSynchronization request (unconfirmed, no response expected).

Source

pub async fn utc_time_synchronization( &self, destination_mac: &[u8], date: Date, time: Time, ) -> Result<(), Error>

Send a UTCTimeSynchronization request (unconfirmed, no response expected).

Source

pub fn cov_notifications(&self) -> Receiver<COVNotificationRequest>

Get a receiver for incoming COV notifications. Each call returns a new independent receiver.

Source

pub async fn discovered_devices(&self) -> Vec<DiscoveredDevice>

Get a snapshot of all discovered devices.

Source

pub async fn get_device(&self, instance: u32) -> Option<DiscoveredDevice>

Look up a discovered device by instance number.

Source

pub async fn clear_devices(&self)

Clear the discovered devices table.

Source

pub async fn add_device(&self, instance: u32, mac: &[u8]) -> Result<(), Error>

Manually register a device in the device table.

Useful for adding known devices without requiring WhoIs/IAm exchange. Sets default values for max_apdu_length (1476), segmentation (NONE), and vendor_id (0) since these are unknown without IAm.

Source

pub async fn stop(&mut self) -> Result<(), Error>

Stop the client, aborting the dispatch task.

Auto Trait Implementations§

§

impl<T> Freeze for BACnetClient<T>

§

impl<T> !RefUnwindSafe for BACnetClient<T>

§

impl<T> Send for BACnetClient<T>

§

impl<T> Sync for BACnetClient<T>

§

impl<T> Unpin for BACnetClient<T>

§

impl<T> UnsafeUnpin for BACnetClient<T>

§

impl<T> !UnwindSafe for BACnetClient<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more