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
//! # curl_smile
//!
//! Rust API for Keepsmile Bluetooth LE lights. Uses `btleplug` for cross-platform BLE support.
//!
//! ## Example
//!
//! This is the same example as `examples/use_curl_smile_demo.rs` in the repository: demos how to scan, connect,
//! update state, send commands, disconnect.
//!
//! ```no_run
//! use curl_smile::btle_communication::btle_api::{
//! connect_to_btle_device, disconnect_from_btle_device, find_supported_devices,
//! };
//! use curl_smile::core::Intent::{Brightness, Rgb, SwitchOn};
//! use curl_smile::core::light_state::LightState;
//!
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! let devices = find_supported_devices().await?;
//!
//! for d in devices {
//! connect_to_btle_device(&d).await?;
//!
//! let mut state = LightState::new();
//! state.update(SwitchOn(true));
//! state.update(Brightness { brightness: 0x30 });
//! state.update(Rgb {
//! red: 0x0e,
//! green: 0x00,
//! blue: 0xaa,
//! });
//!
//! d.send_commands(&state).await?;
//! disconnect_from_btle_device(&d).await?;
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! ## Modules
//!
//! - `core`: high-level types.
//! - `btle_communication`: BLE scanning/connection.
//! - `hardware_abstraction_layer`: defines supported-devices and related GATT profile.
//! - `hardware_abstraction_layer/compiler`: converts state into command bytes for a target device.
//!
//! ## Supported devices
//!
//! See the repository README for the current supported-device list. Applications
//! should use `find_supported_devices()` rather than scanning for arbitrary peripherals.
pub use ;