get device VID, PID and product name in fido::read_device_details()

This commit is contained in:
Fabrice Bellamy
2026-01-20 16:00:28 +01:00
parent a12fec8532
commit 765f248472
2 changed files with 24 additions and 2 deletions
+17 -1
View File
@@ -16,6 +16,9 @@ const CTAPHID_KEEPALIVE: u8 = 0xBB;
pub struct HidTransport {
device: hidapi::HidDevice,
cid: u32,
pub vid: u16,
pub pid: u16,
pub product_name: String,
}
impl HidTransport {
@@ -41,6 +44,13 @@ impl HidTransport {
info.product_id()
);
let vid = info.vendor_id();
let pid = info.product_id();
let product_name = info
.product_string()
.unwrap_or("Unknown FIDO Device")
.to_string();
let device = info.open_device(&api).map_err(|e| {
log::error!("Failed to open HID device: {}", e);
e
@@ -53,7 +63,13 @@ impl HidTransport {
})?;
log::info!("HID Transport established successfully. CID: 0x{:08X}", cid);
Ok(Self { device, cid })
Ok(Self {
device,
cid,
vid,
pid,
product_name,
})
}
fn init_channel(device: &hidapi::HidDevice) -> Result<u32> {
+7 -1
View File
@@ -292,7 +292,13 @@ pub fn read_device_details() -> Result<FullDeviceStatus, PFError> {
Vec::new()
});
let mut config = AppConfig::default();
let mut config = AppConfig {
vid: format!("{:04X}", transport.vid),
pid: format!("{:04X}", transport.pid),
product_name: transport.product_name.clone(),
..Default::default()
};
if let Ok(Value::Map(m)) = from_slice(&phy_res) {
log::debug!("Parsed Physical Config map successfully");
// These keys might need adjustment based on exact firmware response structure