Skip to content

Commit 1f4bbb5

Browse files
committed
Fix broken build
1 parent 5bded28 commit 1f4bbb5

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/main.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ fn load_config(config_file: &str) -> Option<Config> {
4848
config
4949
}
5050

51-
impl From<config::AuthMethod> for AuthMethod {
52-
fn from(value: config::AuthMethod) -> Self {
51+
impl From<&config::AuthMethod> for AuthMethod {
52+
fn from(value: &config::AuthMethod) -> Self {
5353
format!("{value:?}").parse().unwrap()
5454
}
5555
}
@@ -73,20 +73,20 @@ async fn run_async(spawner: LocalSpawner) -> Result<(), anyhow::Error> {
7373
let mut button = PinDriver::input(peripherals.pins.gpio14)?;
7474
button.set_pull(Pull::Up)?;
7575

76-
let mut _wifi: Option<WifiSession> = None;
76+
let mut _wifi: Option<Rc<WifiSession>> = None;
7777
let mut _sntp: Option<EspSntp> = None;
7878
if let Some(config) = &config {
7979
let mut wifi = WifiSession::new(
8080
&WifiConfig {
8181
ssid: config.wifi.ssid.clone(),
8282
password: config.wifi.password.clone(),
83-
auth_method: Some((&config.wifi.auth_method).into()),
83+
auth_method: Some(AuthMethod::from(&config.wifi.auth_method)),
8484
},
8585
peripherals.modem,
8686
)?;
8787
wifi.connect().await?;
8888
log::info!("Connected wifi: {:#?}", wifi.get_ip_info());
89-
_wifi = Some(wifi);
89+
_wifi = Some(Rc::new(wifi));
9090

9191
// Keep it around or else the SNTP service will stop
9292
_sntp = Some(EspSntp::new_default()?);
@@ -96,6 +96,7 @@ async fn run_async(spawner: LocalSpawner) -> Result<(), anyhow::Error> {
9696

9797
let captured_mount_path = mount_path.clone();
9898
let mount_path_c_str = CString::new(mount_path.as_bytes())?;
99+
let wifi_ref = _wifi.unwrap().clone();
99100
let device_info_producer: DeviceInfoProducer = Box::new(move || {
100101
let mut total_volume_size: u64 = 0;
101102
let mut free_volume_size: u64 = 0;
@@ -109,7 +110,7 @@ async fn run_async(spawner: LocalSpawner) -> Result<(), anyhow::Error> {
109110
Ok(DeviceInfo {
110111
version: VERSION.to_string(),
111112
// TODO: maybe pass in Rc of wifi instead?
112-
wifi_ip: wifi.get_ip_info().unwrap().ip.to_string(),
113+
wifi_ip: wifi_ref.get_ip_info().unwrap().ip.to_string(),
113114
local_time: OffsetDateTime::now_utc(),
114115
mount_path: captured_mount_path.to_string(),
115116
total_volume_size,

0 commit comments

Comments
 (0)