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
//! A device abstraction for extra setup fields used by [`WifiAutoRp`](crate::wifi_auto::WifiAutoRp).
//!
//! See the [`WifiAutoRp` struct example](crate::wifi_auto::WifiAutoRp) for the full setup.
//!
//! This module provides ready-to-use field types that can be passed to
//! [`WifiAutoRp::new`](crate::wifi_auto::WifiAutoRp::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`](crate::wifi_auto::WifiAutoField). See example there.
//!
//! # Example
//!
//! ```rust,no_run
//! # #![no_std]
//! # #![no_main]
//! # use panic_probe as _;
//! use device_envoy_rp::{
//! Error, Result,
//! button::PressedTo,
//! button_watch,
//! flash_block::FlashBlockRp,
//! wifi_auto::{WifiAuto as _, WifiAutoEvent, WifiAutoRp},
//! wifi_auto::fields::{TextField, TextFieldStatic, TimezoneField, TimezoneFieldStatic},
//! };
//!
//! button_watch! {
//! ButtonWatch13 {
//! pin: PIN_13,
//! }
//! }
//!
//! async fn example(
//! spawner: embassy_executor::Spawner,
//! p: embassy_rp::Peripherals,
//! ) -> Result<()> {
//! let [wifi_flash, website_flash, timezone_flash] = FlashBlockRp::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 button_watch13 = ButtonWatch13::new(p.PIN_13, PressedTo::Ground, spawner).await?;
//! let wifi_auto = WifiAutoRp::new(
//! p.PIN_23,
//! p.PIN_24,
//! p.PIN_25,
//! p.PIN_29,
//! p.PIO0,
//! p.DMA_CH0,
//! wifi_flash,
//! "DeviceEnvoySetup",
//! [website_field, timezone_field],
//! spawner,
//! )?;
//!
//! let _stack = wifi_auto
//! .connect(&mut *button_watch13, |wifi_auto_event| async move {
//! 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 crateFlashBlockRp;
use __impl_wifi_auto_fields;
use ;
__impl_wifi_auto_fields!;