Skip to content

Commit

Permalink
Fix detection of connection to devices in bootloader mode'
Browse files Browse the repository at this point in the history
  • Loading branch information
obra committed Feb 6, 2024
1 parent 2fd6503 commit ff22881
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/api/focus.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,23 @@ class Focus {
}
}

async open(device_identifier, info) {
this._port = device_identifier;
if (!info) throw new Error("Device descriptor argument is mandatory");
async open(port, deviceDescriptor) {
this._port = port;
if (!deviceDescriptor) throw new Error("Device descriptor argument is mandatory");

this.focusDeviceDescriptor = info;
const info = this._port.getInfo();

const dVid = info.usbVendorId;
const dPid = info.usbProductId;

if (
deviceDescriptor.usb.bootloader &&
dPid == deviceDescriptor.usb.bootloader.productId &&
dVid == deviceDescriptor.usb.bootloader.vendorId
) {
deviceDescriptor.bootloader = true;
}
this.focusDeviceDescriptor = deviceDescriptor;

this.resetDeviceState();
return this._port;
Expand Down

0 comments on commit ff22881

Please sign in to comment.