Skip to main content

BacnetClient

Struct BacnetClient 

Source
pub struct BacnetClient { /* private fields */ }
Expand description

High-level BACnet client for device communication

Implementations§

Source§

impl BacnetClient

Source

pub fn new() -> Result<Self, ClientError>

Create a new BACnet client with default configuration.

Binds to all interfaces on an OS-assigned ephemeral port with a 5 second timeout. Use BacnetClient::builder to customize.

Source

pub fn new_with_local_addr<A: ToSocketAddrs>( addr: A, ) -> Result<Self, ClientError>

Create a new BACnet client with a specific local socket address (any type implementing ToSocketAddrs).

Source

pub fn builder() -> ClientBuilder

Begin building a client with custom configuration.

Source

pub fn timeout(&self) -> Duration

The per-request timeout this client is configured with.

Source

pub fn local_addr(&self) -> Result<SocketAddr, ClientError>

The local socket address the client is bound to.

Source

pub fn discover_device( &self, target_addr: SocketAddr, ) -> Result<DeviceInfo, ClientError>

Discover a device by IP address

Source

pub fn who_is( &self, low_limit: Option<u32>, high_limit: Option<u32>, ) -> Result<Vec<DeviceInfo>, ClientError>

Broadcast a Who-Is on the local subnet and collect every device that answers with an I-Am, until the configured timeout elapses.

low_limit and high_limit bound the device-instance range; pass both to target a range, or None/None to ask every device. Results are de-duplicated by device id.

Unlike discover_device (which unicasts to a single known address), this reaches all devices on the local network.

Source

pub fn who_is_to( &self, target_addr: SocketAddr, low_limit: Option<u32>, high_limit: Option<u32>, ) -> Result<Vec<DeviceInfo>, ClientError>

Send a Who-Is to a specific address (broadcast or unicast) and collect all I-Am replies until the timeout elapses.

This is the explicit-target form of who_is; use it for subnet-directed broadcasts (e.g. 192.168.1.255:47808) or to query a BBMD/foreign-device peer directly.

Source

pub fn read_object_list( &self, target_addr: SocketAddr, device_id: u32, ) -> Result<Vec<ObjectIdentifier>, ClientError>

Read the device’s object list

Source

pub fn read_objects_properties( &self, target_addr: SocketAddr, objects: &[ObjectIdentifier], ) -> Result<Vec<ObjectInfo>, ClientError>

Read properties for multiple objects

Source

pub fn read_property( &self, target_addr: SocketAddr, object: ObjectIdentifier, property: PropertyIdentifier, ) -> Result<Vec<PropertyValue>, ClientError>

Read a property of an object and return all decoded values.

Most properties decode to a single value; arrays and lists (e.g. Object_List, Priority_Array) decode to several, so the full set is returned. Returns ClientError::PropertyError if the device reports the property as unknown, or ClientError::Timeout if there is no response.

Source

pub fn write_property( &self, target_addr: SocketAddr, object: ObjectIdentifier, property: PropertyIdentifier, value: &PropertyValue, priority: Option<u8>, ) -> Result<(), ClientError>

Write a single property of an object.

priority is the BACnet command priority (1-16) for commandable properties such as Present_Value; pass None to omit it. A successful write is acknowledged with a SimpleAck; a device-side failure surfaces as ClientError::PropertyError / ClientError::Rejected / ClientError::Abort.

Source

pub fn write_property_verified( &self, target_addr: SocketAddr, object: ObjectIdentifier, property: PropertyIdentifier, value: &PropertyValue, priority: Option<u8>, ) -> Result<WriteOutcome, ClientError>

Write a property and then read it back to confirm it took effect.

This is the safe way to command a value: it returns

  • Err(..) if the device refused the write (Error/Reject/Abort) or a transfer failed;
  • Ok(WriteOutcome::Verified) if the read-back matches value;
  • Ok(WriteOutcome::NotEffective { read_back }) if the device acknowledged the write but the property still reports a different value (e.g. a higher-priority command is winning, or the property is not commandable at this priority).

Floating-point values are compared with a small tolerance.

A device commonly returns the SimpleAck before Present_Value reflects the new command (priority-array resolution can lag), so the read-back is polled a few times before concluding the write did not take effect.

Auto Trait Implementations§

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, 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.