From 54983836e09f778fae45098d0402c2ef67c1b09a Mon Sep 17 00:00:00 2001 From: Fabrice Bellamy Date: Sun, 25 Jan 2026 00:46:43 +0100 Subject: [PATCH] add debug logs in fido code --- src-tauri/src/fido/hid.rs | 20 +++++++++++++++++--- src-tauri/src/fido/mod.rs | 17 ++++++++++++++++- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src-tauri/src/fido/hid.rs b/src-tauri/src/fido/hid.rs index 9af5cef..bd41c50 100644 --- a/src-tauri/src/fido/hid.rs +++ b/src-tauri/src/fido/hid.rs @@ -127,6 +127,11 @@ impl HidTransport { let new_cid = u32::from_be_bytes([buf[15], buf[16], buf[17], buf[18]]); log::debug!("Channel negotiation successful. New CID: 0x{:08X}", new_cid); return Ok(new_cid); + } else { + log::trace!( + "Received ignoreable HID packet during CID negotiation: {:02X?}", + &buf[0..16] + ); } } } @@ -168,8 +173,10 @@ impl HidTransport { log::error!("Failed to write initial HID packet: {}", e); return Err(PFError::Io(format!( "Failed to write initial HID packet: {}", - e + e, ))); + } else { + log::trace!("Successfully sent initial HID packet"); } // 2. Continuation Packets @@ -192,8 +199,13 @@ impl HidTransport { ); return Err(PFError::Io(format!( "Failed to write continuation HID packet: {}", - e + e, ))); + } else { + log::trace!( + "Successfully sent continuation HID packet (Seq {})", + sequence - 1 + ); } } @@ -246,8 +258,10 @@ impl HidTransport { log::error!("Device returned CTAP Error code: 0x{:02X}", buf[5]); return Err(PFError::Device(format!( "Device returned CTAP Error: 0x{:02X}", - buf[5] + buf[5], ))); + } else { + log::trace!("Packet received is not a CTAP Error"); } if buf[4] == cmd { diff --git a/src-tauri/src/fido/mod.rs b/src-tauri/src/fido/mod.rs index ccc2bf7..f20534d 100644 --- a/src-tauri/src/fido/mod.rs +++ b/src-tauri/src/fido/mod.rs @@ -364,12 +364,19 @@ fn read_physical_config(transport: &HidTransport) -> Result log::debug!("Parsed Physical Config map successfully"); if let Some(Value::Integer(v)) = m.get(&Value::Text("gpio".into())) { config.led_gpio = *v as u8; + } else { + log::warn!("No led_gpio in CBOR map"); } + if let Some(Value::Integer(v)) = m.get(&Value::Text("brightness".into())) { config.led_brightness = *v as u8; + } else { + log::warn!("No led_brightness in CBOR map"); } } else if !phy_res.is_empty() { - log::warn!("Physical config response was not a valid CBOR map or empty"); + log::warn!("Physical config response was not a valid CBOR map"); + } else { + log::debug!("Physical config response was empty or already handled."); } Ok(config) @@ -432,6 +439,8 @@ pub fn write_config(config: AppConfigInput, pin: Option) -> Result) -> Result) -> Result) -> Result