|
|
|
|
@ -124,7 +124,7 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
|
"12CAA", // 面罩前缀名
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
currentDeviceType: "WE200", // 现在的设备类型: WE200 WL200
|
|
|
|
|
currentDeviceType: "", // 现在的设备类型: WE200 WL200
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -195,18 +195,19 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 重新连接 */
|
|
|
|
|
// againConnection() {
|
|
|
|
|
// this.setState({
|
|
|
|
|
// connectionStatus: false,
|
|
|
|
|
// islian: false,
|
|
|
|
|
// error: false,
|
|
|
|
|
// });
|
|
|
|
|
// Taro.closeBluetoothAdapter({
|
|
|
|
|
// complete: () => {
|
|
|
|
|
// this.bluetoothInit();
|
|
|
|
|
// },
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
againConnection() {
|
|
|
|
|
this.setState({
|
|
|
|
|
hasVersionInfo: false, // 重置已获取版本信息状态
|
|
|
|
|
connectionStatus: false,
|
|
|
|
|
islian: false,
|
|
|
|
|
error: false,
|
|
|
|
|
});
|
|
|
|
|
Taro.closeBluetoothAdapter({
|
|
|
|
|
complete: () => {
|
|
|
|
|
this.bluetoothInit();
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// skip() {
|
|
|
|
|
// this.setState({
|
|
|
|
|
@ -333,15 +334,18 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
|
];
|
|
|
|
|
for (let i = 0; i < item.devices.length; i++) {
|
|
|
|
|
let devicesName = item.devices[i].localName || item.devices[i].name;
|
|
|
|
|
console.log("devicesName", devicesName);
|
|
|
|
|
console.log("tranType", tranType);
|
|
|
|
|
// 是否匹配可连接设备
|
|
|
|
|
let isAvailable = tranType.some(
|
|
|
|
|
(item) => devicesName && devicesName.indexOf(item) > -1
|
|
|
|
|
);
|
|
|
|
|
console.log("isAvailable", isAvailable);
|
|
|
|
|
// 判断设备是否可连接
|
|
|
|
|
if (item.devices[i].connectable && isAvailable) {
|
|
|
|
|
// 如果是已连接WE200后,再次搜索,则只能连接WL200
|
|
|
|
|
if (this.state.currentDeviceType === "WE200") {
|
|
|
|
|
if (!devicesName.includes("12CAA")) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 缓存当前连接设备名 可能是发箍或面罩
|
|
|
|
|
setStorageSync("currentDevicesName", devicesName);
|
|
|
|
|
console.log("连接的设备信息", item.devices[i], devicesName);
|
|
|
|
|
@ -506,6 +510,10 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "BleStatusSync": // 设备连接状态
|
|
|
|
|
console.log(
|
|
|
|
|
"设备连接状态jsonStatus.connectMessage",
|
|
|
|
|
jsonStatus.connectMessage
|
|
|
|
|
);
|
|
|
|
|
if (jsonStatus.connectMessage?.connectType == "CONNECTED") {
|
|
|
|
|
switch (jsonStatus.connectMessage?.deviceName) {
|
|
|
|
|
case OtaDeviceTypeEnum.WE100:
|
|
|
|
|
@ -531,7 +539,20 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else if (jsonStatus?.commandType === "InfoQuery") {
|
|
|
|
|
console.log("查询版本信息", jsonStatus);
|
|
|
|
|
console.log("查询版本信息:", jsonStatus);
|
|
|
|
|
console.log("当前设备:", jsonStatus.otaDeviceType);
|
|
|
|
|
console.log("当前设备版本号:", jsonStatus.versionNo);
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
jsonStatus.otaDeviceType === "WE100" ||
|
|
|
|
|
jsonStatus.otaDeviceType === "WE200"
|
|
|
|
|
) {
|
|
|
|
|
console.log("closeBLEConnection");
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.againConnection();
|
|
|
|
|
}, 1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (jsonStatus.infoQueryType) {
|
|
|
|
|
case "versionInfo":
|
|
|
|
|
if (this.state.hasVersionInfo) return;
|
|
|
|
|
@ -559,6 +580,7 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
|
// 版本号需要更新: 告诉父级页面,关闭连接弹窗,显示更新弹窗
|
|
|
|
|
this.props.upgradeFun();
|
|
|
|
|
} else {
|
|
|
|
|
console.log("不需要升级,跳转进入仪器详情页");
|
|
|
|
|
// 不需要升级,跳转进入仪器详情页
|
|
|
|
|
if (isGetVersionTimer) clearTimeout(isGetVersionTimer);
|
|
|
|
|
this.pairingChange(this.state);
|
|
|
|
|
@ -639,9 +661,15 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
|
// 8.发送指令:获取仪器版本号
|
|
|
|
|
sendGetVersion() {
|
|
|
|
|
const { deviceInfo } = this.props;
|
|
|
|
|
const isFRDevice = ["FR200", "FR380", "FR390"].includes(deviceInfo.model);
|
|
|
|
|
// log.info(commandMap.sendVersionCommand, `仪器:${deviceInfo.model}`);
|
|
|
|
|
console.log(commandMap.sendVersionCommand, `仪器:${deviceInfo.model}`);
|
|
|
|
|
let model = deviceInfo.model;
|
|
|
|
|
if (model == "WL200") {
|
|
|
|
|
if (!this.isWL200()) {
|
|
|
|
|
model = "WE200";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const isFRDevice = ["FR200", "FR380", "FR390"].includes(model);
|
|
|
|
|
console.log(commandMap.sendVersionCommand, `仪器:${model}`);
|
|
|
|
|
if (isFRDevice) {
|
|
|
|
|
writeBLECharacteristicValue({
|
|
|
|
|
//发送获取仪器版本号
|
|
|
|
|
@ -1019,11 +1047,19 @@ class ConnectionBluetoot extends Component<any, any> {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
pairingChange = (data) => {
|
|
|
|
|
this.props.pairingChange(data);
|
|
|
|
|
console.log("pairingChange");
|
|
|
|
|
let { currentDeviceType } = this.state;
|
|
|
|
|
if (currentDeviceType !== "WE100" && currentDeviceType !== "WE200") {
|
|
|
|
|
this.props.pairingChange(data);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
offlineChange = (data) => {
|
|
|
|
|
this.props.offlineChange(data);
|
|
|
|
|
console.log("offlineChange");
|
|
|
|
|
let { currentDeviceType } = this.state;
|
|
|
|
|
if (currentDeviceType !== "WE100" && currentDeviceType !== "WE200") {
|
|
|
|
|
this.props.offlineChange(data);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
|