mirror of
https://github.com/librekeys/picoforge.git
synced 2026-07-28 08:01:19 -07:00
get device VID, PID and product name in fido::read_device_details()
This commit is contained in:
@@ -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> {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user