Skip to content

Commit

Permalink
Make auth method optional
Browse files Browse the repository at this point in the history
  • Loading branch information
fangpenlin committed Jan 7, 2025
1 parent 8ab2d8e commit 69c4b09
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ use std::fmt::{Debug, Formatter};
use std::fs::File;
use std::io::Read;

#[derive(Default, Debug, Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize)]
pub enum AuthMethod {
None,
WEP,
WPA,
#[default]
WPA2Personal,
WPAWPA2Personal,
WPA2Enterprise,
Expand All @@ -20,7 +19,7 @@ pub enum AuthMethod {
#[derive(Deserialize)]
pub struct Wifi {
pub ssid: String,
pub auth_method: AuthMethod,
pub auth_method: Option<AuthMethod>,
// TODO: provide a default way of not storing plaintext? while the key is probably going to
// be in the repo or somewhere, but at least they need to know in order to decode?
pub password: Option<String>,
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async fn run_async(spawner: LocalSpawner) -> Result<(), anyhow::Error> {
&WifiConfig {
ssid: config.wifi.ssid.clone(),
password: config.wifi.password.clone(),
auth_method: Some(AuthMethod::from(&config.wifi.auth_method)),
auth_method: config.wifi.auth_method.as_ref().map(AuthMethod::from),
},
peripherals.modem,
)?;
Expand Down

0 comments on commit 69c4b09

Please sign in to comment.