Commit a0588464 authored by martin hou's avatar martin hou

fix: 增加对Live模式的识别与屏蔽部分轮循指令

parent 758a25b8
import { isNullishCoalesce } from 'typescript';
import { Logger as internalLogger, formatTime, shortcutKeys, sliceTime } from './utils'; import { Logger as internalLogger, formatTime, shortcutKeys, sliceTime } from './utils';
import md5 from 'js-md5'; import md5 from 'js-md5';
...@@ -100,6 +101,7 @@ function Jensen(log, conn) { ...@@ -100,6 +101,7 @@ function Jensen(log, conn) {
let handlers = {}; let handlers = {};
let pid = 0; let pid = 0;
let recvable = false; let recvable = false;
let lastCommand = null;
let self = this; let self = this;
this.data = {}; this.data = {};
...@@ -266,6 +268,10 @@ function Jensen(log, conn) { ...@@ -266,6 +268,10 @@ function Jensen(log, conn) {
return Boolean(current); return Boolean(current);
} }
this.isLiveMode = function() {
return lastCommand == REALTIME_TRANSFER;
}
this.setUSBDevice = function (dev) { this.setUSBDevice = function (dev) {
device = dev; device = dev;
ready = false; ready = false;
...@@ -322,6 +328,7 @@ function Jensen(log, conn) { ...@@ -322,6 +328,7 @@ function Jensen(log, conn) {
} }
await device.transferOut(1, data).catch((e) => crash('sendNext', e)); await device.transferOut(1, data).catch((e) => crash('sendNext', e));
if (cmd.onprogress) cmd.onprogress(1, 1); if (cmd.onprogress) cmd.onprogress(1, 1);
lastCommand = cmd.command;
/* /*
if (data.byteLength < 1000) await device.transferOut(1, data).catch((e) => crash('sendNext', e)); if (data.byteLength < 1000) await device.transferOut(1, data).catch((e) => crash('sendNext', e));
else else
...@@ -769,6 +776,7 @@ Jensen.prototype.disconnectBTDevice = async function (seconds) { ...@@ -769,6 +776,7 @@ Jensen.prototype.disconnectBTDevice = async function (seconds) {
Jensen.prototype.getBluetoothStatus = async function (seconds) { Jensen.prototype.getBluetoothStatus = async function (seconds) {
if (this.model.indexOf('hidock-p1') == -1) return null; if (this.model.indexOf('hidock-p1') == -1) return null;
if (this.isLiveMode()) return null;
return this.send(new Command(BLUETOOTH_STATUS), seconds); return this.send(new Command(BLUETOOTH_STATUS), seconds);
}; };
...@@ -1224,6 +1232,7 @@ Jensen.prototype.getSettings = async function (seconds) { ...@@ -1224,6 +1232,7 @@ Jensen.prototype.getSettings = async function (seconds) {
if ((this.model == 'hidock-h1' || this.model == 'hidock-h1e') && this.versionNumber < 327714) { if ((this.model == 'hidock-h1' || this.model == 'hidock-h1e') && this.versionNumber < 327714) {
return { autoRecord: false, autoPlay: false }; return { autoRecord: false, autoPlay: false };
} }
if (this.isLiveMode()) return null;
return this.send(new Command(GET_SETTINGS), seconds); return this.send(new Command(GET_SETTINGS), seconds);
}; };
...@@ -1262,6 +1271,7 @@ Jensen.prototype.formatCard = function (seconds) { ...@@ -1262,6 +1271,7 @@ Jensen.prototype.formatCard = function (seconds) {
Jensen.prototype.getRecordingFile = function (seconds) { Jensen.prototype.getRecordingFile = function (seconds) {
if ((this.model == 'hidock-h1' || this.model == 'hidock-h1e') && this.versionNumber < 327733) return null; if ((this.model == 'hidock-h1' || this.model == 'hidock-h1e') && this.versionNumber < 327733) return null;
if (this.isLiveMode()) return null;
return this.send(new Command(GET_RECORDING_FILE), seconds); return this.send(new Command(GET_RECORDING_FILE), seconds);
}; };
...@@ -1297,7 +1307,7 @@ Jensen.prototype.getFileBlock = async function (filename, length, ondata) { ...@@ -1297,7 +1307,7 @@ Jensen.prototype.getFileBlock = async function (filename, length, ondata) {
Jensen.prototype.getBatteryStatus = function(seconds) Jensen.prototype.getBatteryStatus = function(seconds)
{ {
if (this.model != 'hidock-p1') return null; if (this.model != 'hidock-p1') return null;
if (this.busy()) if (this.busy() || this.isLiveMode())
{ {
Logger.debug('jensen', 'dispatcher', 'cancel getBatteryStatus cuz busy'); Logger.debug('jensen', 'dispatcher', 'cancel getBatteryStatus cuz busy');
return; return;
......
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