From ff22881d57b53bcafb4b271185aeaf75310f27b9 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 5 Feb 2024 16:32:52 -0800 Subject: [PATCH] Fix detection of connection to devices in bootloader mode' --- src/api/focus.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/api/focus.js b/src/api/focus.js index 2fd8fa69d..9872fce0c 100644 --- a/src/api/focus.js +++ b/src/api/focus.js @@ -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;