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
//! A device abstraction for extra setup fields used by [`WifiAutoEsp`](crate::wifi_auto::WifiAutoEsp).
//!
//! See the [`WifiAutoEsp` struct example](crate::wifi_auto::WifiAutoEsp) for the full setup.
//!
//! This module provides ready-to-use field types that can be passed to
//! [`WifiAutoEsp::new`](crate::wifi_auto::WifiAutoEsp::new) for collecting additional
//! configuration beyond WiFi credentials.
//!
//! There are two levels of customization:
//!
//! 1. Use built-in helpers like [`TextField`] and [`TimezoneField`].
//! 2. Define your own field type by implementing [`WifiAutoField`]. See example there.
//!
//! # Example
//!
//! ```rust,no_run
//! # #![no_std]
//! # #![no_main]
//! use device_envoy_esp::{
//! Error, Result,
//! button::{ButtonEsp, PressedTo},
//! flash_block::FlashBlockEsp,
//! wifi_auto::{WifiAuto as _, WifiAutoEvent, WifiAutoEsp},
//! wifi_auto::fields::{TextField, TextFieldStatic, TimezoneField, TimezoneFieldStatic},
//! };
//!
//! async fn example(
//! spawner: embassy_executor::Spawner,
//! p: esp_hal::peripherals::Peripherals,
//! ) -> Result<()> {
//! let mut button6 = ButtonEsp::new(p.GPIO6, PressedTo::Ground);
//! let [wifi_flash, website_flash, timezone_flash] = FlashBlockEsp::new_array::<3>(p.FLASH)?;
//!
//! static WEBSITE_STATIC: TextFieldStatic<32> = TextField::new_static();
//! let website_field = TextField::new(
//! &WEBSITE_STATIC,
//! website_flash,
//! "website",
//! "Website",
//! "google.com",
//! );
//!
//! static TIMEZONE_STATIC: TimezoneFieldStatic = TimezoneField::new_static();
//! let timezone_field = TimezoneField::new(&TIMEZONE_STATIC, timezone_flash);
//!
//! let wifi_auto = WifiAutoEsp::new(
//! p.WIFI,
//! wifi_flash,
//! "DeviceEnvoySetup",
//! [website_field, timezone_field],
//! spawner,
//! )?;
//!
//! let _stack = wifi_auto
//! .connect(&mut button6, async |wifi_auto_event| -> Result<(), device_envoy_esp::Error> {
//! match wifi_auto_event {
//! WifiAutoEvent::CaptivePortalReady => {}
//! WifiAutoEvent::Connecting { .. } => {}
//! WifiAutoEvent::ConnectionFailed => {}
//! }
//! Ok(())
//! })
//! .await?;
//!
//! let _website = website_field.text()?.unwrap_or_default();
//! let _offset_minutes = timezone_field
//! .offset_minutes()?
//! .ok_or(Error::MissingCustomWifiAutoField)?;
//!
//! Ok(())
//! }
//! ```
use crateError;
use crateFlashBlockEsp;
use __impl_wifi_auto_fields;
use ;
__impl_wifi_auto_fields!;