Commit 6c0b9342 authored by martin hou's avatar martin hou

feat: 增加WebUSB写超时设置

parent 7689555d
......@@ -302,6 +302,12 @@ declare class Jensen {
// 更新设备UAC固件
updateUAC: (data: Uint8Array, seconds?: number) => Promise<ReturnStruct['common']>;
// 设置WebUSB超时时间
setWebUSBTimeout: (timeout: number, seconds?: number) => Promise<ReturnStruct['common']>;
// 获取WebUSB超时时间
getWebUSBTimeout: (seconds?: number) => Promise<{ timeout: number }>;
dump: (void);
}
......
......@@ -39,6 +39,8 @@ const BLUETOOTH_STATUS = 0x1003;
const TEST_SN_WRITE = 0xf007;
const RECORD_TEST_START = 0xf008;
const RECORD_TEST_END = 0xf009;
const WRITE_WEBUSB_TIMEOUT = 0xf010;
const READ_WEBUSB_TIMEOUT = 0xf011;
const COMMAND_NAMES = {
[INVAILD]: 'invalid-0',
......@@ -703,6 +705,16 @@ Jensen.prototype.getBluetoothStatus = async function (seconds) {
return this.send(new Command(BLUETOOTH_STATUS), seconds);
};
Jensen.prototype.setWebUSBTimeout = async function (timeout, seconds)
{
return this.send(new Command(WRITE_WEBUSB_TIMEOUT).body([timeout]), seconds);
};
Jensen.prototype.getWebUSBTimeout = async function (seconds)
{
return this.send(new Command(READ_WEBUSB_TIMEOUT), seconds);
};
Jensen.prototype.listFiles = async function () {
let tag = 'filelist-' + this.serialNumber;
if (this[tag] != null) return null;
......@@ -1518,5 +1530,11 @@ Jensen.registerHandler(REQUEST_UAC_UPDATE, (msg) => {
return { code : rst, result : txt };
});
Jensen.registerHandler(UAC_UPDATE, commonMessageParser);
Jensen.registerHandler(WRITE_WEBUSB_TIMEOUT, commonMessageParser);
Jensen.registerHandler(READ_WEBUSB_TIMEOUT, (msg) => {
let timeout = ((msg.body[0] & 0xff) << 24) | ((msg.body[1] & 0xff) << 16) | ((msg.body[2] & 0xff) << 8) | (msg.body[3] & 0xff);
return { timeout: timeout };
});
export { Jensen };
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