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
//! Bluetooth device management via BlueZ D-Bus.
//!
//! # Quick Start
//!
//! ```rust,no_run
//! use wayle_bluetooth::BluetoothService;
//!
//! # async fn example() -> Result<(), wayle_bluetooth::Error> {
//! let bt = BluetoothService::new().await?;
//!
//! // Check adapter state
//! if bt.available.get() {
//! println!("Bluetooth available, powered: {}", bt.enabled.get());
//! }
//!
//! // List paired devices
//! for device in bt.devices.get().iter() {
//! let name = device.name.get().unwrap_or_default();
//! println!("{}: {}", name, device.address.get());
//! }
//! # Ok(())
//! # }
//! ```
//!
//! # Watching for Changes
//!
//! ```rust,no_run
//! use wayle_bluetooth::BluetoothService;
//! use futures::StreamExt;
//!
//! # async fn example() -> Result<(), wayle_bluetooth::Error> {
//! # let bt = BluetoothService::new().await?;
//! // React to new devices
//! let mut stream = bt.devices.watch();
//! while let Some(devices) = stream.next().await {
//! println!("Device count: {}", devices.len());
//! }
//! # Ok(())
//! # }
//! ```
//!
//! # Discovery and Pairing
//!
//! ```rust,no_run
//! # use wayle_bluetooth::BluetoothService;
//! # use std::time::Duration;
//! # async fn example() -> Result<(), wayle_bluetooth::Error> {
//! # let bt = BluetoothService::new().await?;
//! // Scan for 30 seconds
//! bt.start_timed_discovery(Duration::from_secs(30)).await?;
//!
//! // Connect to a device
//! for device in bt.devices.get().iter() {
//! if device.name.get().as_deref() == Some("My Headphones") {
//! device.connect().await?;
//! }
//! }
//! # Ok(())
//! # }
//! ```
//!
//! # Reactive Properties
//!
//! All fields are [`Property<T>`](wayle_core::Property):
//! - `.get()` - Current value snapshot
//! - `.watch()` - Stream yielding on changes
//!
//! # Service Fields
//!
//! | Field | Type | Description |
//! |-------|------|-------------|
//! | `adapters` | `Vec<Arc<Adapter>>` | All Bluetooth adapters |
//! | `primary_adapter` | `Option<Arc<Adapter>>` | Active adapter for operations |
//! | `devices` | `Vec<Arc<Device>>` | All discovered devices |
//! | `available` | `bool` | Whether any adapter is present |
//! | `enabled` | `bool` | Whether any adapter is powered |
//! | `connected` | `Vec<String>` | Addresses of connected devices |
//! | `pairing_request` | `Option<PairingRequest>` | Pending pairing request |
//!
//! # Control Methods
//!
//! - [`enable()`](BluetoothService::enable) / [`disable()`](BluetoothService::disable) - Power adapter
//! - [`start_discovery()`](BluetoothService::start_discovery) / [`stop_discovery()`](BluetoothService::stop_discovery) - Scan
//! - [`start_timed_discovery()`](BluetoothService::start_timed_discovery) - Scan with timeout
//!
//! Device-level: `connect()`, `disconnect()`, `pair()`, `forget()`
/// Bluetooth domain models for adapters and devices.
/// BlueZ type definitions for adapter/device properties.
pub use Error;
pub use BluetoothService;
;