Skip to content

Commit 937a88f

Browse files
authored
Merge pull request #26 from Jim-Hodapp-Coaching/add_example_secrets
Adds examples/secrets.rs
2 parents 3ead44b + 42b2fc8 commit 937a88f

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

examples/join.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
extern crate esp32_wroom_rp;
1313

14+
include!("secrets/secrets.rs");
15+
1416
// The macro for our start-up function
1517
use cortex_m_rt::entry;
1618

@@ -30,6 +32,7 @@ use hal::pac;
3032

3133
use embedded_hal::delay::blocking::DelayUs;
3234

35+
3336
/// The linker will place this boot block at the start of our program image. We
3437
/// need this to help the ROM bootloader get our code up and running.
3538
#[link_section = ".boot2"]
@@ -127,11 +130,10 @@ fn main() -> ! {
127130
// ACK on pin x (GPIO10)
128131
ack: pins.gpio10.into_mode::<hal::gpio::FloatingInput>(),
129132
};
130-
let ssid: &str = "SSID";
131133
let passphrase: &str = "Passphrase";
132134

133135
let mut wifi = esp32_wroom_rp::wifi::Wifi::init(spi, esp_pins, &mut delay).unwrap();
134-
let result = wifi.join(ssid, passphrase);
136+
let result = wifi.join(SSID, PASSPHRASE);
135137
defmt::info!("Join Result: {:?}", result);
136138

137139
defmt::info!("Entering main loop");
@@ -144,14 +146,14 @@ fn main() -> ! {
144146
delay.delay_ms(sleep).ok().unwrap();
145147

146148
if byte == 3 {
147-
defmt::info!("Connected to Network: {:?}", ssid);
149+
defmt::info!("Connected to Network: {:?}", SSID);
148150

149151
defmt::info!("Sleeping for 5 seconds before disconnecting...");
150152
delay.delay_ms(5000).ok().unwrap();
151153

152154
wifi.leave().ok().unwrap();
153155
} else if byte == 6 {
154-
defmt::info!("Disconnected from Network: {:?}", ssid);
156+
defmt::info!("Disconnected from Network: {:?}", SSID);
155157
}
156158
}
157159
Err(e) => {

examples/secrets/secrets.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//
2+
// secrets.rs - stores WiFi secrets like SSID, passphrase, etc shared across
3+
// all example applications
4+
//
5+
6+
const SSID: &str = "ssid";
7+
const PASSPHRASE: &str = "passphrase";

0 commit comments

Comments
 (0)