1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
//! # BACnet-RS: A Complete BACnet Protocol Stack Implementation in Rust
//!
//! BACnet-RS is a comprehensive implementation of the BACnet (Building Automation and Control Networks)
//! protocol stack written in Rust. It provides a complete, standards-compliant BACnet implementation
//! suitable for both embedded systems and full-featured applications.
//!
//! ## Features
//!
//! - **Complete Protocol Stack**: Full implementation of BACnet layers (Application, Network, Data Link)
//! - **Multiple Data Link Support**: BACnet/IP, Ethernet, MS/TP, and more
//! - **Standards Compliant**: Implements ASHRAE Standard 135-2020
//! - **No-std Compatible**: Works in embedded environments without heap allocation
//! - **Async Support**: Optional async/await support with Tokio integration
//! - **Comprehensive Services**: Read/Write properties, Who-Is/I-Am, object discovery, and more
//! - **Debugging Tools**: Built-in protocol analyzers and debug formatters
//! - **Performance Monitoring**: Statistics collection and performance metrics
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use bacnet_rs::client::BacnetClient;
//! use std::net::{SocketAddr, IpAddr, Ipv4Addr};
//!
//! fn example() -> Result<(), Box<dyn std::error::Error>> {
//! // Create a BACnet client
//! let client = BacnetClient::new()?;
//!
//! // Discover a device at a specific address
//! let target_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(192, 168, 1, 100)), 47808);
//! let device = client.discover_device(target_addr)?;
//! println!("Found device: {}", device.vendor_name);
//!
//! // Read object list from the device
//! let objects = client.read_object_list(target_addr, device.device_id)?;
//! println!("Device has {} objects", objects.len());
//!
//! Ok(())
//! }
//! ```
//!
//! ## Architecture
//!
//! The library is organized into several key modules:
//!
//! - [`datalink`]: Data link layer implementations (BACnet/IP, Ethernet, MS/TP)
//! - [`network`]: Network layer for routing and addressing
//! - [`transport`]: Transport layer with reliability and flow control
//! - [`service`]: BACnet services (confirmed and unconfirmed)
//! - [`object`]: BACnet object types and property handling
//! - [`client`]: High-level client API for applications
//! - [`util`]: Utilities for CRC, encoding, and debugging
//!
//! ## Data Link Types
//!
//! BACnet-RS supports multiple data link layer protocols:
//!
//! - **BACnet/IP**: UDP-based communication over IP networks (most common)
//! - **BACnet/Ethernet**: Direct Ethernet frame communication
//! - **MS/TP**: Master-Slave Token Passing over RS-485 serial networks
//! - **Point-to-Point**: Direct serial communication
//!
//! ## Examples
//!
//! The crate includes comprehensive examples in the `examples/` directory:
//!
//! - **Basic Examples**: Simple device creation and communication
//! - **Networking Examples**: Who-Is scans, transport demonstrations
//! - **Object Examples**: Device and object discovery, property reading
//! - **Debugging Examples**: Protocol analysis and debug formatting
//!
//! Run examples with:
//! ```bash
//! cargo run --example whois_scan
//! cargo run --example device_objects
//! ```
//!
//! ## Features
//!
//! - `std` (default): Enable standard library support
//! - `async` (default): Enable async/await support with Tokio
//! - `serde` (default): Enable serialization support
//! - `no-std`: Disable standard library for embedded use
//!
//! ## License
//!
//! Licensed under either of
//! - Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE))
//! - MIT License ([LICENSE-MIT](LICENSE-MIT))
//!
//! at your option.
extern crate alloc;
/// Application layer protocol services and message handling
/// Data link layer implementations for various BACnet physical networks
/// BACnet encoding and decoding utilities for application tags and values
/// Network layer for BACnet routing, addressing, and message forwarding
/// BACnet object definitions, properties, and type system
/// BACnet service definitions for confirmed and unconfirmed operations
/// Transport layer providing reliability, segmentation, and flow control
/// Utility functions for CRC calculations, debugging, and performance monitoring
/// BACnet vendor identification and device information
/// High-level client API for BACnet communication (requires std feature)
/// Property value decoders for various BACnet data types
// Re-export main types for convenient access
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
/// BACnet protocol version as defined in ASHRAE 135
pub const BACNET_PROTOCOL_VERSION: u8 = 1;
/// Maximum Application Protocol Data Unit size in bytes
/// This is the largest APDU that can be transmitted in a single BACnet message
pub const BACNET_MAX_APDU: usize = 1476;
/// Maximum Message Protocol Data Unit size in bytes
/// This includes the NPDU header and APDU payload
pub const BACNET_MAX_MPDU: usize = 1497;