From 69c4b094320b6809803fea6e23913cb9c8ef2a08 Mon Sep 17 00:00:00 2001 From: Fang-Pen Lin Date: Tue, 7 Jan 2025 01:06:59 -0800 Subject: [PATCH] Make auth method optional --- src/config.rs | 5 ++--- src/main.rs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/config.rs b/src/config.rs index c7fb752..3c4ba9f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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, @@ -20,7 +19,7 @@ pub enum AuthMethod { #[derive(Deserialize)] pub struct Wifi { pub ssid: String, - pub auth_method: AuthMethod, + pub auth_method: Option, // 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, diff --git a/src/main.rs b/src/main.rs index 6c8ec88..4aa61f0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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, )?;