WIP: get Heltec V3 working

This commit is contained in:
swaits committed 2026-04-07 07:58:57 -06:00
1 parent b2e4bb0476
commit 75d70df294
1 file changed
+24 -1
+24 -1
View File
@@ -13,18 +13,41 @@ pub const USB_VID: u16 = 0x1209;
/// DongLoRa USB Product ID.
pub const USB_PID: u16 = 0x5741;
/// Known USB-UART bridge VID:PIDs found on some board revisions.
const BRIDGE_VID_PIDS: &[(u16, u16)] = &[
(0x10C4, 0xEA60), // CP2102 (Silicon Labs)
(0x1A86, 0x55D4), // CH9102
(0x1A86, 0x7523), // CH340
(0x0403, 0x6001), // FT232R (FTDI)
];
/// Find the DongLoRa serial port by USB VID:PID.
///
/// Checks for native USB CDC-ACM first (VID:PID 1209:5741), then falls
/// back to known USB-UART bridge chips found on some board revisions.
/// Returns the first matching port path, or `None` if no device is found.
pub fn find_port() -> Option<String> {
let ports = serialport::available_ports().ok()?;
// Prefer native USB (our custom VID:PID)
if let Some(port) = ports.iter().find(|p| {
matches!(
&p.port_type,
serialport::SerialPortType::UsbPort(info)
if info.vid == USB_VID && info.pid == USB_PID
)
}) {
return Some(port.port_name.clone());
}
// Fall back to known USB-UART bridge chips
ports
.into_iter()
.find(|p| {
matches!(
&p.port_type,
serialport::SerialPortType::UsbPort(info)
if info.vid == USB_VID && info.pid == USB_PID
if BRIDGE_VID_PIDS.contains(&(info.vid, info.pid))
)
})
.map(|p| p.port_name)