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
//! Connection monitoring module (FR-010)
//!
//! This module provides connection state monitoring with optional
//! automatic reconnection support.
//!
//! # Overview
//!
//! The monitor module helps track the health of CAN backend connections
//! and optionally handles automatic reconnection when connections are lost.
//!
//! # Components
//!
//! - [`ConnectionMonitor`]: Main monitoring component
//! - [`ConnectionState`]: Current connection state (Connected, Disconnected, Reconnecting)
//! - [`ReconnectConfig`]: Configuration for automatic reconnection
//! - [`MonitorConfig`]: Configuration loaded from TOML files
//!
//! # Connection States
//!
//! - [`ConnectionState::Connected`]: Backend is operational
//! - [`ConnectionState::Disconnected`]: Connection lost, needs re-initialization
//! - [`ConnectionState::Reconnecting`]: Auto-reconnect in progress
//!
//! # Example
//!
//! ```rust
//! use canlink_hal::monitor::{ConnectionMonitor, ConnectionState, ReconnectConfig};
//! use std::time::Duration;
//!
//! // Create monitor without auto-reconnect
//! let monitor = ConnectionMonitor::new(Duration::from_secs(1));
//! assert_eq!(monitor.state(), ConnectionState::Connected);
//!
//! // Create monitor with auto-reconnect
//! let reconnect_config = ReconnectConfig::exponential_backoff(
//! 5, // max retries
//! Duration::from_secs(1), // initial interval
//! 2.0, // backoff multiplier
//! );
//! let monitor = ConnectionMonitor::with_reconnect(
//! Duration::from_secs(1),
//! reconnect_config,
//! );
//! assert!(monitor.auto_reconnect_enabled());
//! ```
//!
//! # Auto-Reconnect
//!
//! When auto-reconnect is enabled, the monitor will automatically attempt
//! to reconnect when a disconnection is detected. The reconnection behavior
//! is controlled by [`ReconnectConfig`]:
//!
//! - `max_retries`: Maximum reconnection attempts (0 = unlimited)
//! - `retry_interval`: Initial delay between attempts
//! - `backoff_multiplier`: Exponential backoff factor
pub use MonitorConfig;
pub use ConnectionMonitor;
pub use ReconnectConfig;
pub use ConnectionState;