Commit d218d287 authored by Skye Yu's avatar Skye Yu

Merge branch 'master' of http://gitlab.sugrsugr.com/skye/jensen

parents bfa884f3 69074dc5
......@@ -26,7 +26,7 @@ declare class JensenType {
init: () => Promise<boolean>;
getDeviceInfo: (time?: number) => Promise<DeviceInfo>;
listFiles: (time?: number) => Promise<FileInfo[]>;
tryconnect: () => Promise<boolean>;
tryconnect: (disableOnConnect?:boolean) => Promise<boolean>;
getFile: (
fileName: string,
length: number,
......
......@@ -98,9 +98,10 @@ function Jensen(log) {
self.versionNumber = null;
};
const setup = async function () {
const setup = async function (disableOnConnect) {
self.versionCode = null;
self.versionNumber = null;
commands.length = 0;
try {
await device.selectConfiguration(1);
await device.claimInterface(0);
......@@ -108,15 +109,14 @@ function Jensen(log) {
self.model = device.productId == 45069 ? 'hidock-h1e' : 'hidock-h1';
} catch (e) {
Logger.error('jensen', 'setup', String(e));
throw e;
}
_check_conn_status();
if (!disableOnConnect) _check_conn_status();
current = null;
recv = false;
ready = true;
Logger.debug('jensen', 'setup', 'setup webusb connection');
try {
self.onconnect?.();
if (!disableOnConnect && !self.isStopConnectionCheck) self.onconnect?.();
} catch (err) {
Logger.error('jensen', 'setup', err);
}
......@@ -151,7 +151,7 @@ function Jensen(log) {
await self.connect();
};
this.tryconnect = async function () {
this.tryconnect = async function (disableOnConnect) {
await this.disconnect();
let devices = await navigator.usb.getDevices();
for (let i = 0; i < devices.length; i++) {
......@@ -160,7 +160,7 @@ function Jensen(log) {
Logger.debug('jensen', 'tryconnect', 'detected: ' + item.productName);
await item.open();
device = item;
await setup();
await setup(disableOnConnect);
return true;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment