restore behavior when no device found as normal offline state instead of an error

This commit is contained in:
Fabrice Bellamy
2026-01-20 21:48:58 +01:00
parent 1a0d0446f3
commit f96ab341b1
2 changed files with 9 additions and 3 deletions
+3 -1
View File
@@ -4,6 +4,8 @@ use anyhow::{Result, anyhow};
use rand::Rng;
use std::time::Duration;
use crate::error::PFError;
// HID Transport Constants
const HID_REPORT_SIZE: usize = 64;
const HID_USAGE_PAGE_FIDO: u16 = 0xF1D0;
@@ -35,7 +37,7 @@ impl HidTransport {
.find(|d| d.usage_page() == HID_USAGE_PAGE_FIDO)
.ok_or_else(|| {
log::warn!("No FIDO device found with Usage Page 0xF1D0.");
anyhow!("No FIDO device found. Is it plugged in?")
PFError::NoDevice
})?;
log::debug!(
+6 -2
View File
@@ -149,8 +149,12 @@ pub fn read_device_details() -> Result<FullDeviceStatus, PFError> {
log::info!("Starting FIDO device details read...");
let transport = HidTransport::open().map_err(|e| {
log::error!("Failed to open HID transport: {}", e);
PFError::Device(e.to_string())
if let Some(PFError::NoDevice) = e.downcast_ref::<PFError>() {
PFError::NoDevice
} else {
log::error!("Failed to open HID transport: {}", e);
PFError::Device(e.to_string())
}
})?;
// --- 1. Get Info ---