|
|
|
@ -32,22 +32,30 @@ import {
|
|
|
|
getofflineData,
|
|
|
|
getofflineData,
|
|
|
|
hex2int,
|
|
|
|
hex2int,
|
|
|
|
getTimeCode,
|
|
|
|
getTimeCode,
|
|
|
|
|
|
|
|
isNeedToUpdate,
|
|
|
|
} from "@/utils/util";
|
|
|
|
} from "@/utils/util";
|
|
|
|
const log = require("@/utils/log");
|
|
|
|
const log = require("@/utils/log");
|
|
|
|
import commandMap from "@/utils/commandMap";
|
|
|
|
import commandMap from "@/utils/commandMap";
|
|
|
|
import { bleCommandSamples } from "./test";
|
|
|
|
import { bleCommandSamples } from "./test";
|
|
|
|
|
|
|
|
|
|
|
|
import { DeviceToolKit as DeviceToolKitWE100 } from "@flossom-npm/iot-translater-we100";
|
|
|
|
import { DeviceToolKit as DeviceToolKitWE100 } from "@flossom-npm/iot-translater-we100";
|
|
|
|
const deviceToolKitInstanceWL200 = new DeviceToolKitWE100("WE100", "WL200");
|
|
|
|
const deviceToolKitInstanceWL200 = new DeviceToolKitWE100("WL200", "WL200");
|
|
|
|
deviceToolKitInstanceWL200.setDebug(true);
|
|
|
|
deviceToolKitInstanceWL200.setDebug(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const _deviceToolKitInstanceWL200 = new DeviceToolKitWE100("WE100", "WL200");
|
|
|
|
|
|
|
|
|
|
|
|
const deviceToolKitInstanceM01 = new DeviceToolKitWE100("WE100", "M01");
|
|
|
|
const deviceToolKitInstanceM01 = new DeviceToolKitWE100("WE100", "M01");
|
|
|
|
deviceToolKitInstanceM01.setDebug(true);
|
|
|
|
deviceToolKitInstanceM01.setDebug(true);
|
|
|
|
|
|
|
|
|
|
|
|
const deviceToolKitInstanceFR200 = new DeviceToolKitFR200("FR200");
|
|
|
|
const deviceToolKitInstanceFR200 = new DeviceToolKitFR200("FR200");
|
|
|
|
|
|
|
|
|
|
|
|
import { DeviceToolKit as DeviceToolKitFR200 } from "@flossom-npm/iot-translater";
|
|
|
|
import { DeviceToolKit as DeviceToolKitFR200 } from "@flossom-npm/iot-translater";
|
|
|
|
import { showModal, msg } from "@/utils/traoAPI";
|
|
|
|
import {
|
|
|
|
|
|
|
|
showModal,
|
|
|
|
|
|
|
|
msg,
|
|
|
|
|
|
|
|
setStorageSync,
|
|
|
|
|
|
|
|
getStorageSync,
|
|
|
|
|
|
|
|
} from "@/utils/traoAPI";
|
|
|
|
|
|
|
|
|
|
|
|
// const { InstrumentTypeEnum, OtaDeviceTypeEnum } = app.globalData;
|
|
|
|
// const { InstrumentTypeEnum, OtaDeviceTypeEnum } = app.globalData;
|
|
|
|
import InstrumentTypeEnum from "../InstrumentTypeEnum";
|
|
|
|
import InstrumentTypeEnum from "../InstrumentTypeEnum";
|
|
|
|
@ -72,10 +80,10 @@ let sendgetversionTimer: any = null;
|
|
|
|
let sendGetVersionTimerNum = 0;
|
|
|
|
let sendGetVersionTimerNum = 0;
|
|
|
|
|
|
|
|
|
|
|
|
let searchBluetootTimers: any = null; // 搜索蓝牙定时器
|
|
|
|
let searchBluetootTimers: any = null; // 搜索蓝牙定时器
|
|
|
|
let searchBluetootTimersNum = 0; // 搜索蓝牙秒数
|
|
|
|
let searchBluetootTimersNum = 15; // 搜索蓝牙秒数 15秒
|
|
|
|
|
|
|
|
|
|
|
|
let connectionTimer: any = null; // 连接蓝牙定时器
|
|
|
|
let connectionTimer: any = null; // 连接蓝牙定时器
|
|
|
|
let connectionTimerNum = 0;
|
|
|
|
let connectionTimerNumber = 10000; // 连接蓝牙超时毫秒
|
|
|
|
|
|
|
|
|
|
|
|
let sendPairingTimer: any = null; // 发送配对
|
|
|
|
let sendPairingTimer: any = null; // 发送配对
|
|
|
|
|
|
|
|
|
|
|
|
@ -106,6 +114,16 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
offlineDataindex: 0, //离线记录发送下标index
|
|
|
|
offlineDataindex: 0, //离线记录发送下标index
|
|
|
|
versionInfo: {}, //版本号
|
|
|
|
versionInfo: {}, //版本号
|
|
|
|
offlineDataList: [], //离线数据
|
|
|
|
offlineDataList: [], //离线数据
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prefix: "12CAA", // WL200蓝牙搜索前缀
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// WL200匹配
|
|
|
|
|
|
|
|
tranType: [
|
|
|
|
|
|
|
|
"WE100", // 发箍
|
|
|
|
|
|
|
|
"WE200", // 发箍
|
|
|
|
|
|
|
|
"WL200", // 发箍
|
|
|
|
|
|
|
|
"12CAA", // 面罩前缀名
|
|
|
|
|
|
|
|
],
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -122,6 +140,14 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
|
|
|
|
|
|
|
|
async initData() {}
|
|
|
|
async initData() {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isWL200() {
|
|
|
|
|
|
|
|
let currentDevicesName = getStorageSync("currentDevicesName");
|
|
|
|
|
|
|
|
if (currentDevicesName.indexOf("12CAA") > -1) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
close() {
|
|
|
|
close() {
|
|
|
|
clearInterval(sendPairingTimer);
|
|
|
|
clearInterval(sendPairingTimer);
|
|
|
|
clearInterval(sendgetversionTimer);
|
|
|
|
clearInterval(sendgetversionTimer);
|
|
|
|
@ -267,7 +293,7 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
"searchBluetootTimersNum value => ",
|
|
|
|
"searchBluetootTimersNum value => ",
|
|
|
|
searchBluetootTimersNum
|
|
|
|
searchBluetootTimersNum
|
|
|
|
);
|
|
|
|
);
|
|
|
|
if (searchBluetootTimersNum === 8) {
|
|
|
|
if (searchBluetootTimersNum === 15) {
|
|
|
|
clearInterval(searchBluetootTimers);
|
|
|
|
clearInterval(searchBluetootTimers);
|
|
|
|
this.setState({
|
|
|
|
this.setState({
|
|
|
|
error: true,
|
|
|
|
error: true,
|
|
|
|
@ -289,43 +315,36 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
onBluetoothDeviceFound() {
|
|
|
|
onBluetoothDeviceFound() {
|
|
|
|
Taro.onBluetoothDeviceFound((item: any) => {
|
|
|
|
Taro.onBluetoothDeviceFound((item: any) => {
|
|
|
|
console.log("蓝牙查找item", item, item.devices[0].name);
|
|
|
|
console.log("蓝牙查找item", item, item.devices[0].name);
|
|
|
|
/*
|
|
|
|
|
|
|
|
* 这里增加判断,类型不同识别的设备名称不一样
|
|
|
|
|
|
|
|
* type1 FR200
|
|
|
|
|
|
|
|
* type2 WM100
|
|
|
|
|
|
|
|
* type3 we100
|
|
|
|
|
|
|
|
* type4 FR380
|
|
|
|
|
|
|
|
* */
|
|
|
|
|
|
|
|
// const tranType = {
|
|
|
|
|
|
|
|
// 1: "FR200",
|
|
|
|
|
|
|
|
// 3: "WE200", // WL200
|
|
|
|
|
|
|
|
// 4: "FR380",
|
|
|
|
|
|
|
|
// 5: "FR390",
|
|
|
|
|
|
|
|
// 6: "WE200", // M01
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
// let type = this.props.yiqiInfo.model || "FR200";
|
|
|
|
|
|
|
|
let type = "WE200";
|
|
|
|
|
|
|
|
// this.props.yiqiInfo.model = type;
|
|
|
|
|
|
|
|
console.log("this.props.yiqiInfo.model", this.props.yiqiInfo.model);
|
|
|
|
|
|
|
|
console.info("搜索到到蓝牙设备 value => ", item.devices[0]?.name);
|
|
|
|
console.info("搜索到到蓝牙设备 value => ", item.devices[0]?.name);
|
|
|
|
|
|
|
|
console.log(">>>>>>>当前传入设备类型>>>>>", this.props.yiqiInfo.model);
|
|
|
|
|
|
|
|
// 先匹配到哪个连接哪个
|
|
|
|
|
|
|
|
let tranType = [
|
|
|
|
|
|
|
|
this.props.yiqiInfo.model, // 当前传入设备类型
|
|
|
|
|
|
|
|
...this.state.tranType,
|
|
|
|
|
|
|
|
];
|
|
|
|
for (let i = 0; i < item.devices.length; i++) {
|
|
|
|
for (let i = 0; i < item.devices.length; i++) {
|
|
|
|
if (
|
|
|
|
let devicesName = item.devices[i].localName || item.devices[i].name;
|
|
|
|
item.devices[i].connectable &&
|
|
|
|
console.log("devicesName", devicesName);
|
|
|
|
(item.devices[i].localName
|
|
|
|
console.log("tranType", tranType);
|
|
|
|
? item.devices[i].localName
|
|
|
|
// 是否匹配可连接设备
|
|
|
|
: item.devices[i].name
|
|
|
|
let isAvailable = tranType.some(
|
|
|
|
).indexOf(`${type}`) !== -1
|
|
|
|
(item) => devicesName && devicesName.indexOf(item) > -1
|
|
|
|
) {
|
|
|
|
);
|
|
|
|
console.log("连接的设备信息", item.devices[i], type);
|
|
|
|
console.log("isAvailable", isAvailable);
|
|
|
|
|
|
|
|
// 判断设备是否可连接
|
|
|
|
|
|
|
|
if (item.devices[i].connectable && isAvailable) {
|
|
|
|
|
|
|
|
// 缓存当前连接设备名 可能是发箍或面罩
|
|
|
|
|
|
|
|
setStorageSync("currentDevicesName", devicesName);
|
|
|
|
|
|
|
|
console.log("连接的设备信息", item.devices[i], devicesName);
|
|
|
|
|
|
|
|
|
|
|
|
let params = {
|
|
|
|
let params = {
|
|
|
|
deviceId: item.devices[i].deviceId,
|
|
|
|
deviceId: item.devices[i].deviceId,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
this.props.setDeviceId(params);
|
|
|
|
this.props.setDeviceId(params); // 设置蓝牙连接设备ID
|
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
clearInterval(searchBluetootTimers);
|
|
|
|
clearInterval(searchBluetootTimers);
|
|
|
|
Taro.stopBluetoothDevicesDiscovery(); //停止搜索蓝牙
|
|
|
|
Taro.stopBluetoothDevicesDiscovery(); //停止搜索蓝牙
|
|
|
|
// app.globalData.deviceInfo.deviceId = item.devices[i].deviceId;
|
|
|
|
|
|
|
|
this.createBLEConnection();
|
|
|
|
this.createBLEConnection();
|
|
|
|
}, 10);
|
|
|
|
}, 10);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
@ -343,10 +362,6 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
} catch (e) {}
|
|
|
|
} catch (e) {}
|
|
|
|
clearTimeout(connectionTimer);
|
|
|
|
clearTimeout(connectionTimer);
|
|
|
|
const { yiqiInfo: deviceInfo } = this.props;
|
|
|
|
const { yiqiInfo: deviceInfo } = this.props;
|
|
|
|
console.log(
|
|
|
|
|
|
|
|
"this.props.bluetoothInfo.deviceId",
|
|
|
|
|
|
|
|
this.props.bluetoothInfo.deviceId
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
/*********开始主动连接*******/
|
|
|
|
/*********开始主动连接*******/
|
|
|
|
createBLEConnection(this.props.bluetoothInfo.deviceId)
|
|
|
|
createBLEConnection(this.props.bluetoothInfo.deviceId)
|
|
|
|
.then((res) => {
|
|
|
|
.then((res) => {
|
|
|
|
@ -362,7 +377,7 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
if (overTimer) clearTimeout(overTimer);
|
|
|
|
if (overTimer) clearTimeout(overTimer);
|
|
|
|
this.failErrorCode(-1, "连接蓝牙失败,请重新开机后重试");
|
|
|
|
this.failErrorCode(-1, "连接蓝牙失败,请重新开机后重试");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 10000);
|
|
|
|
}, connectionTimerNumber);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.getBLEDeviceServices(); //获取特征
|
|
|
|
this.getBLEDeviceServices(); //获取特征
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -424,6 +439,7 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
console.log("onBLECharacteristicValueChange value => ", value);
|
|
|
|
console.log("onBLECharacteristicValueChange value => ", value);
|
|
|
|
let str = ab2hex(value.value); //转为16进制字符串
|
|
|
|
let str = ab2hex(value.value); //转为16进制字符串
|
|
|
|
console.log("转为16进制字符串 str", str);
|
|
|
|
console.log("转为16进制字符串 str", str);
|
|
|
|
|
|
|
|
|
|
|
|
let connectionStatus = [
|
|
|
|
let connectionStatus = [
|
|
|
|
"FR200",
|
|
|
|
"FR200",
|
|
|
|
"WL200",
|
|
|
|
"WL200",
|
|
|
|
@ -434,27 +450,29 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
|
|
|
|
|
|
|
|
let jsonStatus: any = null;
|
|
|
|
let jsonStatus: any = null;
|
|
|
|
let querySubDeviceArrayBuffer;
|
|
|
|
let querySubDeviceArrayBuffer;
|
|
|
|
|
|
|
|
|
|
|
|
if (deviceInfo.model == "WL200") {
|
|
|
|
if (deviceInfo.model == "WL200") {
|
|
|
|
querySubDeviceArrayBuffer =
|
|
|
|
if (this.isWL200()) {
|
|
|
|
deviceToolKitInstanceWL200.toBleCommand(
|
|
|
|
jsonStatus = deviceToolKitInstanceWL200.toJsonStatus(
|
|
|
|
bleCommandSamples.querySubDevice as any
|
|
|
|
value.value
|
|
|
|
);
|
|
|
|
);
|
|
|
|
jsonStatus = deviceToolKitInstanceWL200.toJsonStatus(value.value);
|
|
|
|
querySubDeviceArrayBuffer =
|
|
|
|
// jsonStatus = deviceToolKitInstanceM01.toJsonStatus(value.value);
|
|
|
|
deviceToolKitInstanceWL200.toBleCommand(
|
|
|
|
// querySubDeviceArrayBuffer = deviceToolKitInstanceM01.toBleCommand(
|
|
|
|
bleCommandSamples.querySubDevice as any
|
|
|
|
// bleCommandSamples.querySubDevice as any
|
|
|
|
);
|
|
|
|
// ); // todo
|
|
|
|
} else {
|
|
|
|
|
|
|
|
jsonStatus = deviceToolKitInstanceM01.toJsonStatus(value.value);
|
|
|
|
|
|
|
|
querySubDeviceArrayBuffer =
|
|
|
|
|
|
|
|
deviceToolKitInstanceM01.toBleCommand(
|
|
|
|
|
|
|
|
bleCommandSamples.querySubDevice as any
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
} else if (deviceInfo.model == "M01") {
|
|
|
|
} else if (deviceInfo.model == "M01") {
|
|
|
|
jsonStatus = deviceToolKitInstanceM01.toJsonStatus(value.value);
|
|
|
|
jsonStatus = deviceToolKitInstanceM01.toJsonStatus(value.value);
|
|
|
|
querySubDeviceArrayBuffer = deviceToolKitInstanceM01.toBleCommand(
|
|
|
|
querySubDeviceArrayBuffer = deviceToolKitInstanceM01.toBleCommand(
|
|
|
|
bleCommandSamples.querySubDevice as any
|
|
|
|
bleCommandSamples.querySubDevice as any
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// log.info(
|
|
|
|
|
|
|
|
// commandMap.reciviedBLECommand,
|
|
|
|
|
|
|
|
// `仪器模式: ${deviceInfo.model}`,
|
|
|
|
|
|
|
|
// jsonStatus
|
|
|
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
console.log(
|
|
|
|
console.log(
|
|
|
|
commandMap.reciviedBLECommand,
|
|
|
|
commandMap.reciviedBLECommand,
|
|
|
|
`仪器模式: ${deviceInfo.model}`,
|
|
|
|
`仪器模式: ${deviceInfo.model}`,
|
|
|
|
@ -487,7 +505,7 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
}*/
|
|
|
|
}*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "BleStatusSync":
|
|
|
|
case "BleStatusSync": // 设备连接状态
|
|
|
|
if (jsonStatus.connectMessage?.connectType == "CONNECTED") {
|
|
|
|
if (jsonStatus.connectMessage?.connectType == "CONNECTED") {
|
|
|
|
switch (jsonStatus.connectMessage?.deviceName) {
|
|
|
|
switch (jsonStatus.connectMessage?.deviceName) {
|
|
|
|
case OtaDeviceTypeEnum.WE100:
|
|
|
|
case OtaDeviceTypeEnum.WE100:
|
|
|
|
@ -523,9 +541,24 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
subDeviceConnectedStatus: true,
|
|
|
|
subDeviceConnectedStatus: true,
|
|
|
|
synchronousStatus: true,
|
|
|
|
synchronousStatus: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
const deviceVersionNo = jsonStatus.versionNo;
|
|
|
|
|
|
|
|
const latestVersionNo = deviceInfo.iot_versions;
|
|
|
|
let currentDevicesName = getStorageSync("currentDevicesName");
|
|
|
|
// const isNeedToUpdateBl = isNeedToUpdate(deviceVersionNo, latestVersionNo)
|
|
|
|
let deviceVersionNo = jsonStatus.versionNo;
|
|
|
|
|
|
|
|
let latestVersionNo = deviceInfo.iotVersion;
|
|
|
|
|
|
|
|
if (currentDevicesName.indexOf("12CAA") < -1) {
|
|
|
|
|
|
|
|
latestVersionNo = deviceInfo.we200IotVersion;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const isNeedToUpdateBl = isNeedToUpdate(
|
|
|
|
|
|
|
|
deviceVersionNo,
|
|
|
|
|
|
|
|
latestVersionNo
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
console.log("deviceInfo", deviceInfo);
|
|
|
|
|
|
|
|
console.log("isNeedToUpdateBl", isNeedToUpdateBl);
|
|
|
|
|
|
|
|
if (isNeedToUpdateBl) {
|
|
|
|
|
|
|
|
// 版本号需要更新,显示更新弹窗
|
|
|
|
|
|
|
|
this.props.upgradeFun();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 判断是否需要升级
|
|
|
|
// 判断是否需要升级
|
|
|
|
// M01和WL200 不需要在这里进行蓝牙更新
|
|
|
|
// M01和WL200 不需要在这里进行蓝牙更新
|
|
|
|
// if (isNeedToUpdateBl) {
|
|
|
|
// if (isNeedToUpdateBl) {
|
|
|
|
@ -551,9 +584,12 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
hasSyncRecord: true,
|
|
|
|
hasSyncRecord: true,
|
|
|
|
synchronousStatus: true,
|
|
|
|
synchronousStatus: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
console.log("offlineClockSummary value =>", jsonStatus);
|
|
|
|
console.log(
|
|
|
|
// this.triggerEvent("pairingChange", this.state);
|
|
|
|
"离线汇总offlineClockSummary value =>",
|
|
|
|
this.pairingChange(this.state);
|
|
|
|
jsonStatus
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
// this.triggerEvent("pairingChange", this.state);
|
|
|
|
|
|
|
|
// this.pairingChange(this.state);
|
|
|
|
// TODO 查询离线记录结果
|
|
|
|
// TODO 查询离线记录结果
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
@ -629,25 +665,20 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
value: `dbf0a00300${ccrc8("dbf0a00300")}de`,
|
|
|
|
value: `dbf0a00300${ccrc8("dbf0a00300")}de`,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// const otaDeviceType = deviceInfo.type == instrumentTypeEnum.WL200 ? OtaDeviceTypeEnum.WL200 : OtaDeviceTypeEnum.WE100;
|
|
|
|
const otaDeviceType = this.isWL200()
|
|
|
|
// 通过发箍连 都用we100
|
|
|
|
? OtaDeviceTypeEnum.WL200
|
|
|
|
const otaDeviceType =
|
|
|
|
: OtaDeviceTypeEnum.WE100;
|
|
|
|
deviceInfo.model == InstrumentTypeEnum.WL200
|
|
|
|
|
|
|
|
? OtaDeviceTypeEnum.WE100
|
|
|
|
|
|
|
|
: OtaDeviceTypeEnum.WE100;
|
|
|
|
|
|
|
|
const versionCommand = {
|
|
|
|
const versionCommand = {
|
|
|
|
commandType: "InfoQuery",
|
|
|
|
commandType: "InfoQuery",
|
|
|
|
infoQueryType: "versionInfo",
|
|
|
|
infoQueryType: "versionInfo",
|
|
|
|
otaDeviceType,
|
|
|
|
otaDeviceType,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
// const value =
|
|
|
|
console.log("versionCommand", versionCommand);
|
|
|
|
// deviceInfo.model == InstrumentTypeEnum.WL200
|
|
|
|
|
|
|
|
// ? deviceToolKitInstanceM01.toBleCommand(versionCommand as any)
|
|
|
|
// 区分WL200 和 发箍
|
|
|
|
// : deviceToolKitInstanceM01.toBleCommand(versionCommand as any);
|
|
|
|
const value = this.isWL200()
|
|
|
|
const value =
|
|
|
|
? deviceToolKitInstanceWL200.toBleCommand(versionCommand as any)
|
|
|
|
deviceInfo.type == InstrumentTypeEnum.WL200
|
|
|
|
: deviceToolKitInstanceM01.toBleCommand(versionCommand as any);
|
|
|
|
? deviceToolKitInstanceWL200.toBleCommand(versionCommand as any)
|
|
|
|
|
|
|
|
: deviceToolKitInstanceM01.toBleCommand(versionCommand as any);
|
|
|
|
|
|
|
|
sendCommand({ value });
|
|
|
|
sendCommand({ value });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -710,14 +741,20 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case InstrumentTypeEnum.WL200:
|
|
|
|
case InstrumentTypeEnum.WL200:
|
|
|
|
// console.log("WL200无法配对,只能用M01");
|
|
|
|
|
|
|
|
console.log("正在发送WL200", bleCommandSamples.match);
|
|
|
|
console.log("正在发送WL200", bleCommandSamples.match);
|
|
|
|
// matchArrayBuffer = deviceToolKitInstanceWL200.toBleCommand(
|
|
|
|
let currentDevicesName = getStorageSync("currentDevicesName");
|
|
|
|
// bleCommandSamples.match as any
|
|
|
|
// 区分面罩和发箍
|
|
|
|
// );
|
|
|
|
if (currentDevicesName.indexOf("12CAA") > -1) {
|
|
|
|
matchArrayBuffer = deviceToolKitInstanceM01.toBleCommand(
|
|
|
|
console.log("12CAA");
|
|
|
|
bleCommandSamples.match as any
|
|
|
|
matchArrayBuffer = deviceToolKitInstanceWL200.toBleCommand(
|
|
|
|
);
|
|
|
|
bleCommandSamples.match as any
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
matchArrayBuffer = deviceToolKitInstanceM01.toBleCommand(
|
|
|
|
|
|
|
|
bleCommandSamples.match as any
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case InstrumentTypeEnum.FR380:
|
|
|
|
case InstrumentTypeEnum.FR380:
|
|
|
|
writeBLECharacteristicValue({
|
|
|
|
writeBLECharacteristicValue({
|
|
|
|
@ -905,7 +942,8 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
isGetSubDeviceTimer = setInterval(() => {
|
|
|
|
isGetSubDeviceTimer = setInterval(() => {
|
|
|
|
sendCommand({ value });
|
|
|
|
sendCommand({ value });
|
|
|
|
isGetSubDeviceTimerNum += 1;
|
|
|
|
isGetSubDeviceTimerNum += 1;
|
|
|
|
if (isGetSubDeviceTimerNum == 8) {
|
|
|
|
// 15秒超时
|
|
|
|
|
|
|
|
if (isGetSubDeviceTimerNum === 15) {
|
|
|
|
this.closeQuerySubDevice();
|
|
|
|
this.closeQuerySubDevice();
|
|
|
|
this.setState({
|
|
|
|
this.setState({
|
|
|
|
error: true,
|
|
|
|
error: true,
|
|
|
|
@ -928,7 +966,6 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
isGetVersionTimer = setInterval(() => {
|
|
|
|
isGetVersionTimer = setInterval(() => {
|
|
|
|
if (this.state.hasVersionInfo) {
|
|
|
|
if (this.state.hasVersionInfo) {
|
|
|
|
if (isGetVersionTimer) clearTimeout(isGetVersionTimer);
|
|
|
|
if (isGetVersionTimer) clearTimeout(isGetVersionTimer);
|
|
|
|
// that.sendSyncRecording()
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
sendGetVersionTimerNum += 1;
|
|
|
|
sendGetVersionTimerNum += 1;
|
|
|
|
if (sendGetVersionTimerNum >= 10) {
|
|
|
|
if (sendGetVersionTimerNum >= 10) {
|
|
|
|
@ -937,8 +974,8 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
this.setState({
|
|
|
|
this.setState({
|
|
|
|
connectionStatus: true,
|
|
|
|
connectionStatus: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
console.log("this.pairingChange", this.state);
|
|
|
|
console.log("超时未返回版本号 this.pairingChange", this.state);
|
|
|
|
this.pairingChange(this.state);
|
|
|
|
// this.pairingChange(this.state);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.sendGetVersion();
|
|
|
|
this.sendGetVersion();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -963,10 +1000,9 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
commandType: "InfoQuery",
|
|
|
|
commandType: "InfoQuery",
|
|
|
|
infoQueryType: "offlineClockSummary",
|
|
|
|
infoQueryType: "offlineClockSummary",
|
|
|
|
};
|
|
|
|
};
|
|
|
|
const value =
|
|
|
|
const value = this.isWL200()
|
|
|
|
deviceInfo.model == InstrumentTypeEnum.WL200
|
|
|
|
? deviceToolKitInstanceWL200.toBleCommand(versionCommand as any)
|
|
|
|
? deviceToolKitInstanceWL200.toBleCommand(versionCommand as any)
|
|
|
|
: deviceToolKitInstanceM01.toBleCommand(versionCommand as any);
|
|
|
|
: deviceToolKitInstanceM01.toBleCommand(versionCommand as any);
|
|
|
|
|
|
|
|
sendCommand({ value }).then();
|
|
|
|
sendCommand({ value }).then();
|
|
|
|
if (isGetSyncRecordingTimer) clearTimeout(isGetSyncRecordingTimer);
|
|
|
|
if (isGetSyncRecordingTimer) clearTimeout(isGetSyncRecordingTimer);
|
|
|
|
isGetSyncRecordingTimer = setTimeout(() => {
|
|
|
|
isGetSyncRecordingTimer = setTimeout(() => {
|
|
|
|
|