#![doc = include_str!("../README.md")]
#![cfg_attr(not(feature = "std"), no_std)]
pub mod app;
pub mod datalink;
pub mod encoding;
pub mod network;
pub mod object;
pub mod service;
pub mod transport;
pub mod util;
pub mod vendor;
#[cfg(feature = "std")]
pub mod client;
pub mod property;
pub use datalink::{DataLink, DataLinkAddress, DataLinkType};
pub use encoding::{ApplicationTag, EncodingError};
pub use object::{BacnetObject, ObjectType, PropertyIdentifier};
pub use service::{ConfirmedServiceChoice, ServiceError, UnconfirmedServiceChoice};
pub use vendor::{VendorInfo, get_vendor_name, get_vendor_info, format_vendor_display};
#[cfg(feature = "std")]
extern crate std;
#[cfg(not(feature = "std"))]
extern crate alloc;
pub const BACNET_PROTOCOL_VERSION: u8 = 1;
pub const BACNET_MAX_APDU: usize = 1476;
pub const BACNET_MAX_MPDU: usize = 1497;
#[cfg(test)]
mod tests {
use crate::object::ObjectIdentifier;
use crate::util::{crc16_mstp, decode_object_id, encode_object_id};
use crate::{ApplicationTag, EncodingError, ObjectType};
#[cfg(not(feature = "std"))]
use alloc::format;
#[test]
fn test_no_std_types() {
let tag = ApplicationTag::Boolean;
assert_eq!(tag as u8, 1);
let obj_type = ObjectType::AnalogInput;
assert_eq!(obj_type as u16, 0);
let obj_id = ObjectIdentifier::new(ObjectType::Device, 123);
assert_eq!(obj_id.instance, 123);
assert!(obj_id.is_valid());
}
#[test]
fn test_encoding_error() {
let err = EncodingError::BufferOverflow;
let _ = format!("{:?}", err);
}
#[test]
fn test_util_functions() {
let data = b"test";
let crc = crc16_mstp(data);
assert_ne!(crc, 0);
let encoded = encode_object_id(8, 123).unwrap();
let (obj_type, instance) = decode_object_id(encoded);
assert_eq!(obj_type, 8);
assert_eq!(instance, 123);
}
}