Commit d0e57980 authored by martin hou's avatar martin hou

fix: 增加对HiDock H1 Lite的兼容

parent 00330103
......@@ -161,6 +161,7 @@ function Jensen(log, conn) {
if (productId == 0x0103) return 'hidock-h1e';
if (productId == 0x2040) return 'hidock-p1';
if (productId == 0x2041) return 'hidock-p1:mini';
if (productId == 0x0104) return 'hidock-h1:lite';
return 'unknown';
}
......@@ -774,12 +775,12 @@ Jensen.prototype.restoreFactorySettings = async function (seconds) {
};
Jensen.prototype.scanDevices = async function (seconds) {
if (this.model.indexOf('hidock-p1') == -1) return null;
if (this.model.indexOf('hidock-p1') == -1 && this.model !== 'hidock-h1:lite') return null;
return this.send(new Command(BLUETOOTH_SCAN), seconds || 35);
};
Jensen.prototype.connectBTDevice = async function (mac, seconds) {
if (this.model.indexOf('hidock-p1') == -1) return null;
if (this.model.indexOf('hidock-p1') == -1 && this.model !== 'hidock-h1:lite') return null;
let marr = mac.split('-');
if (marr.length != 6) throw new Error('invalid mac');
let addr = [];
......@@ -788,50 +789,50 @@ Jensen.prototype.connectBTDevice = async function (mac, seconds) {
};
Jensen.prototype.disconnectBTDevice = async function (seconds) {
if (this.model.indexOf('hidock-p1') == -1) return null;
if (this.model.indexOf('hidock-p1') == -1 && this.model !== 'hidock-h1:lite') return null;
return this.send(new Command(BLUETOOTH_CMD).body([0x01]), seconds);
};
Jensen.prototype.getBluetoothStatus = async function (seconds) {
if (this.model.indexOf('hidock-p1') == -1) return null;
if (this.model.indexOf('hidock-p1') == -1 && this.model !== 'hidock-h1:lite') return null;
if (this.isLiveMode()) return null;
return this.send(new Command(BLUETOOTH_STATUS), seconds);
};
// 发起蓝牙扫描请求
Jensen.prototype.startBluetoothScan = async function (count, seconds) {
if (this.model.indexOf('hidock-p1') == -1) return null;
if (this.model.indexOf('hidock-p1') == -1 && this.model !== 'hidock-h1:lite') return null;
count = count & 0xff;
return this.send(new Command(BT_SCAN).body([0x01, count]), seconds);
};
// 停止蓝牙扫描
Jensen.prototype.stopBluetoothScan = async function (seconds) {
if (this.model.indexOf('hidock-p1') == -1) return null;
if (this.model.indexOf('hidock-p1') == -1 && this.model !== 'hidock-h1:lite') return null;
return this.send(new Command(BT_SCAN).body([0x00, 0x00]), seconds);
};
// 获取蓝牙设备列表
Jensen.prototype.getScanResults = async function (seconds) {
if (this.model.indexOf('hidock-p1') == -1) return null;
if (this.model.indexOf('hidock-p1') == -1 && this.model !== 'hidock-h1:lite') return null;
return this.send(new Command(BT_DEV_LIST), seconds);
};
// 获取已配对的蓝牙设备列表
Jensen.prototype.getPairedDevices = async function (seconds) {
if (this.model.indexOf('hidock-p1') == -1) return null;
if (this.model.indexOf('hidock-p1') == -1 && this.model !== 'hidock-h1:lite') return null;
return this.send(new Command(BT_GET_PAIRED_DEV_LIST), seconds);
};
// 清空已配对的蓝牙设备列表
Jensen.prototype.clearPairedDevices = async function (seconds) {
if (this.model.indexOf('hidock-p1') == -1) return null;
if (this.model.indexOf('hidock-p1') == -1 && this.model !== 'hidock-h1:lite') return null;
return this.send(new Command(BT_REMOVE_PAIRED_DEV).body([0x00]), seconds);
}
// 设备回连
Jensen.prototype.reconnectDevice = async function (mac, seconds) {
if (this.model.indexOf('hidock-p1') == -1) return null;
if (this.model.indexOf('hidock-p1') == -1 && this.model !== 'hidock-h1:lite') return null;
let marr = mac.split('-');
if (marr.length != 6) throw new Error('invalid mac');
let addr = [];
......
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