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
//! Safe Rust bindings for IEC 60870-5-101/104 protocols.
//!
//! This crate provides safe wrappers around the [lib60870-C](https://github.com/mz-automation/lib60870)
//! library for implementing IEC 60870-5-104 (TCP/IP) communication.
//!
//! ## Features
//!
//! - **Client (Master)**: Connect to IEC 104 servers and send commands
//! - **Server (Slave)**: Accept connections and send spontaneous data
//! - **Safe API**: Automatic memory management, Rust callbacks
//! - **Common types**: Quality descriptors, cause of transmission, timestamps
//!
//! ## Quick Start - Client
//!
//! ```no_run
//! use lib60870::client::{Connection, ConnectionBuilder};
//! use lib60870::types::{CauseOfTransmission, QOI_STATION};
//!
//! let mut conn = ConnectionBuilder::new("127.0.0.1", 2404)
//! .originator_address(3)
//! .build()
//! .expect("Failed to create connection");
//!
//! conn.set_handlers(
//! |event| println!("Event: {:?}", event),
//! |asdu| {
//! println!("Received: {:?}", asdu);
//! for obj in asdu.parse_objects() {
//! println!(" {:?}", obj);
//! }
//! true
//! },
//! );
//!
//! if conn.connect() {
//! conn.send_start_dt();
//! conn.send_interrogation(CauseOfTransmission::Activation, 1, QOI_STATION);
//! std::thread::sleep(std::time::Duration::from_secs(5));
//! }
//! ```
//!
//! ## Quick Start - Server
//!
//! ```no_run
//! use lib60870::server::{Server, ServerBuilder};
//! use lib60870::types::{CauseOfTransmission, Quality};
//!
//! let mut server = ServerBuilder::new()
//! .local_port(2404)
//! .build()
//! .expect("Failed to create server");
//!
//! server.set_connection_event_handler(|event| {
//! println!("Connection event: {:?}", event);
//! });
//!
//! server.set_interrogation_handler(|conn, asdu, qoi| {
//! println!("Interrogation for group {}", qoi);
//! conn.send_act_con(&asdu, false);
//! // Send data...
//! conn.send_act_term(&asdu);
//! true
//! });
//!
//! server.start();
//!
//! // Send spontaneous data
//! loop {
//! server.send_measured_scaled(
//! CauseOfTransmission::Spontaneous,
//! 1, // Common address
//! 100, // IOA
//! 42, // Value
//! Quality::GOOD,
//! );
//! std::thread::sleep(std::time::Duration::from_secs(1));
//! }
//! ```
//!
//! ## Crate Features
//!
//! - `tls` - Enable TLS support (downloads and links mbedtls 2.28)
//! - `debug` - Enable printf debug output in lib60870
//! - `no-threads` - Disable threading support (for embedded systems)
//! - `tcp-keepalive` - Enable TCP keep-alive
//!
//! ## License
//!
//! lib60870 is dual-licensed under GPLv3 and a commercial license.
//! See <https://github.com/mz-automation/lib60870> for details.
// Modules
/// Raw FFI bindings - use only if you need low-level access.
// Convenience re-exports
pub use Asdu;
pub use ;
pub use ;
pub use ;
pub use Timestamp;
pub use ;
/// Get the lib60870 library version.
///
/// Returns a tuple of (major, minor, patch) version numbers.
/// Enable or disable debug output.
///
/// When enabled, lib60870 will print debug messages to stdout.
/// This requires the crate to be built with the `debug` feature.