feat: more tracing and cleaner code
This commit is contained in:
parent
588ff0964f
commit
3f05f4e004
@ -22,9 +22,23 @@ fn toggle_hotspot(enable: bool) -> Result<(), Error> {
|
|||||||
let mut hotspot = WiFi::new(Some(config));
|
let mut hotspot = WiFi::new(Some(config));
|
||||||
|
|
||||||
if enable {
|
if enable {
|
||||||
hotspot.create_hotspot("MARLIN", "M4rl!nB0x", None)?;
|
match hotspot.create_hotspot("MARLIN", "M4rl!nB0x", None) {
|
||||||
|
Ok(true) => info!("Hotspot enabled"),
|
||||||
|
Ok(false) => info!("Hotspot already enabled"),
|
||||||
|
Err(err) => {
|
||||||
|
error!("Failed to create hotspot: {err:?}");
|
||||||
|
return Err(Error::Wifi(err));
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
hotspot.stop_hotspot()?;
|
match hotspot.stop_hotspot() {
|
||||||
|
Ok(true) => info!("Hotspot disabled"),
|
||||||
|
Ok(false) => info!("Hotspot already disabled"),
|
||||||
|
Err(err) => {
|
||||||
|
error!("Failed to stop hotspot: {err:?}");
|
||||||
|
return Err(Error::Wifi(err));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -127,10 +141,8 @@ pub fn run(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Card::ToggleHotspot => {
|
Card::ToggleHotspot => {
|
||||||
let msg = if hotspot_enabled { "disable" } else { "enable" };
|
if toggle_hotspot(!hotspot_enabled).is_err() {
|
||||||
match toggle_hotspot(!hotspot_enabled) {
|
play_sound(&sink, FAILURE_SOUND);
|
||||||
Ok(()) => info!("hotspot {msg}d"),
|
|
||||||
Err(err) => error!("Failed to {msg} hotspot: {err}"),
|
|
||||||
}
|
}
|
||||||
if hotspot_enabled {
|
if hotspot_enabled {
|
||||||
match tx_manager_shutdown.send(()) {
|
match tx_manager_shutdown.send(()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user