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
//! # Huawei LTE Dongle API
//!
//! A robust async Rust client library for interacting with Huawei LTE dongles and routers.
//!
//! This library provides a type-safe, async interface to the XML-based API used by Huawei HiLink
//! devices such as the E3372, E5577, B525 and many others. It handles authentication, session
//! management, and CSRF token rotation automatically.
//!
//! ## Features
//!
//! - **Async/await** - Built on tokio for efficient async I/O
//! - **Automatic retry** - Configurable retry logic with exponential backoff
//! - **Session management** - Automatic CSRF token handling and refresh
//! - **Type safety** - Strongly typed requests and responses
//! - **Error handling** - Comprehensive error types with automatic recovery
//! - **Device compatibility** - Handles quirks across different firmware versions
//!
//! ## Quick Start
//!
//! ```no_run
//! use huawei_dongle_api::{Client, Config};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Create a client with default config
//! let client = Client::new(Config::default())?;
//!
//! // Get device information (no auth required)
//! let device_info = client.device().information().await?;
//! println!("Device: {}", device_info.device_name);
//!
//! // Check connection status (auth required - handled automatically)
//! let status = client.monitoring().status().await?;
//! println!("Connected: {}", status.is_connected());
//!
//! Ok(())
//! }
//! ```
//!
//! ## Authentication
//!
//! Most read operations don't require authentication, but monitoring status, SMS operations,
//! and configuration changes do. The library handles authentication automatically if no user/password is set:
//!
//! ```no_run
//! # use huawei_dongle_api::{Client, Config};
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! let client = Client::new(Config::default())?;
//!
//! // Login (only needed for password-protected operations)
//! client.auth().login("admin", "password").await?;
//!
//! // Now you can access protected endpoints
//! use huawei_dongle_api::models::{SmsListRequest, SmsBoxType, SmsSortType};
//! let request = SmsListRequest::new(1, 20, SmsBoxType::LocalInbox, SmsSortType::ByTime, false, true);
//! let sms_list = client.sms().list(&request).await?;
//!
//! // Logout when done
//! client.auth().logout().await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Configuration
//!
//! The client can be configured with custom timeouts, retry policies, and base URLs:
//!
//! ```no_run
//! use huawei_dongle_api::{Client, Config};
//! use std::time::Duration;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! let config = Config::builder()
//! .base_url("http://192.168.8.1")
//! .timeout(Duration::from_secs(30))
//! .max_retries(5)
//! .retry_delay(Duration::from_millis(500))
//! .build();
//!
//! let client = Client::new(config?)?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Error Handling
//!
//! The library provides detailed error types and handles common issues automatically:
//!
//! - CSRF token expiry - automatically refreshes and retries
//! - Session timeout - re-authenticates if needed
//! - Network errors - retries with exponential backoff
//! - Device quirks - handles different response formats
//!
//! ## Supported APIs
//!
//! - **Device** - Information, reboot, power control
//! - **Monitoring** - Connection status, signal strength, network info
//! - **SMS** - List, send, delete messages
//! - **Network** - Mode selection, operator info, signal details
//! - **DHCP** - IP configuration, DNS settings
//! - **Authentication** - Login/logout, password encoding
pub use Client;
pub use Config;
pub use ;