installer: add pinephone and pinephonepro support

This commit is contained in:
oopsbagel
2025-07-17 17:28:42 -07:00
committed by Cooper Quintin
parent d3bd8d9dfc
commit 8583064e46
9 changed files with 337 additions and 26 deletions

View File

@@ -4,6 +4,7 @@ use std::str::FromStr;
use std::time::Duration;
use anyhow::{Context, Result, bail};
use nusb::Device;
use reqwest::Client;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpStream;
@@ -132,3 +133,20 @@ pub async fn http_ok_every(
}
Ok(())
}
/// General function to open a USB device
pub fn open_usb_device(vid: u16, pid: u16) -> Result<Option<Device>> {
let devices = match nusb::list_devices() {
Ok(d) => d,
Err(_) => return Ok(None),
};
for device in devices {
if device.vendor_id() == vid && device.product_id() == pid {
match device.open() {
Ok(d) => return Ok(Some(d)),
Err(e) => bail!("device found but failed to open: {}", e),
}
}
}
Ok(None)
}