mirror of
https://github.com/librekeys/picoforge.git
synced 2026-07-28 08:01:19 -07:00
add debug logs in fido code
This commit is contained in:
committed by
Suyog Tandel
parent
858276a3b5
commit
54983836e0
@@ -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 {
|
||||
|
||||
@@ -364,12 +364,19 @@ fn read_physical_config(transport: &HidTransport) -> Result<AppConfig, PFError>
|
||||
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<String>) -> Result<Strin
|
||||
VendorConfigCommand::PhysicalVidPid,
|
||||
Value::Integer(vidpid as i128),
|
||||
)?;
|
||||
} else {
|
||||
log::info!("VID/PID configuration not provided, skipping update.");
|
||||
}
|
||||
|
||||
// LED GPIO config
|
||||
@@ -441,6 +450,8 @@ pub fn write_config(config: AppConfigInput, pin: Option<String>) -> Result<Strin
|
||||
VendorConfigCommand::PhysicalLedGpio,
|
||||
Value::Integer(gpio as i128),
|
||||
)?;
|
||||
} else {
|
||||
log::info!("LED GPIO configuration not provided, skipping update.");
|
||||
}
|
||||
|
||||
// LED brightness config
|
||||
@@ -450,6 +461,8 @@ pub fn write_config(config: AppConfigInput, pin: Option<String>) -> Result<Strin
|
||||
VendorConfigCommand::PhysicalLedBrightness,
|
||||
Value::Integer(brightness as i128),
|
||||
)?;
|
||||
} else {
|
||||
log::info!("LED brightness configuration not provided, skipping update.");
|
||||
}
|
||||
|
||||
// Options config
|
||||
@@ -472,6 +485,8 @@ pub fn write_config(config: AppConfigInput, pin: Option<String>) -> Result<Strin
|
||||
Value::Integer(timeout as i128),
|
||||
)
|
||||
.ok();
|
||||
} else {
|
||||
log::info!("Touch timeout configuration not provided, skipping update.");
|
||||
}
|
||||
|
||||
transport.send_vendor_config(
|
||||
|
||||
Reference in New Issue
Block a user