发箍固件升级完成,wl200测试中,目前缺失wl200固件包

master
blak-kong 2 years ago
parent 148d8bf6a3
commit 6c6b7ab662

@ -37,7 +37,7 @@
"dependencies": { "dependencies": {
"@antmjs/vantui": "^3.2.2", "@antmjs/vantui": "^3.2.2",
"@flossom-npm/iot-translater": "^1.0.8", "@flossom-npm/iot-translater": "^1.0.8",
"@flossom-npm/iot-translater-we100": "^1.0.66", "@flossom-npm/iot-translater-we100": "^1.1.1",
"@reduxjs/toolkit": "^2.0.1", "@reduxjs/toolkit": "^2.0.1",
"@taroify/core": "^0.1.1-alpha.8", "@taroify/core": "^0.1.1-alpha.8",
"@tarojs/components": "3.6.19", "@tarojs/components": "3.6.19",

@ -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(() => {

@ -40,8 +40,12 @@ import OtaDeviceTypeEnum from "../OtaDeviceTypeEnum";
// 临时替代 // 临时替代
var log = console; var log = console;
var deviceToolKitInstance: any = null;
deviceToolKitInstance = new DeviceToolKitWE100("WE100", "WL200"); let deviceToolKitInstance: any = null;
// WE200 M01 M02都是WE200
let deviceToolKitInstanceM01 = new DeviceToolKitWE100("WE100", "M01");
// WL200面罩
let deviceToolKitInstanceWL200 = new DeviceToolKitWE100("WL200", "WL200");
import "./index.less"; import "./index.less";
@ -80,8 +84,24 @@ class UpdateIotWL200 extends Component<any, any> {
this.initData(); this.initData();
} }
isWL200() {
let currentDevicesName = getStorageSync("currentDevicesName");
if (currentDevicesName.indexOf("12CAA") > -1) {
return true;
}
return false;
}
async initData() { async initData() {
console.log("UpdateIotWL200"); console.log("UpdateIotWL200");
if (this.isWL200()) {
console.log("WL200更新");
deviceToolKitInstance = deviceToolKitInstanceWL200;
} else {
console.log("WE100更新");
deviceToolKitInstance = deviceToolKitInstanceM01;
}
let objStr = getStorageSync("instrument_detail"); let objStr = getStorageSync("instrument_detail");
if (objStr) { if (objStr) {
let info = JSON.parse(objStr); let info = JSON.parse(objStr);
@ -89,12 +109,6 @@ class UpdateIotWL200 extends Component<any, any> {
this.setState({ this.setState({
currentDevice: info, currentDevice: info,
}); });
if (info.model == InstrumentTypeEnum.WL200) {
deviceToolKitInstance = new DeviceToolKitWE100("WE100", "WL200");
} else {
deviceToolKitInstance = new DeviceToolKitWE100("WE100", "M01");
}
} }
setTimeout(() => { setTimeout(() => {
this.notifyBLECharacteristicValueChange(); this.notifyBLECharacteristicValueChange();
@ -134,22 +148,22 @@ class UpdateIotWL200 extends Component<any, any> {
*/ */
startOTA() { startOTA() {
this.resetOta(); this.resetOta();
const { currentDevice } = this.state;
let jsoncmd = { let jsoncmd = {
commandType: "OTAStart", commandType: "OTAStart",
otaDeviceType: "", otaDeviceType: "",
versionNo: this.$otaDataGroup.versionNo, versionNo: this.$otaDataGroup.versionNo,
}; };
// 根据设备类型传 otaDeviceType // 根据设备类型传 otaDeviceType
if (currentDevice.model == InstrumentTypeEnum.M01) { if (this.isWL200()) {
jsoncmd.otaDeviceType = OtaDeviceTypeEnum.WE100;
} else {
jsoncmd.otaDeviceType = OtaDeviceTypeEnum.WL200; jsoncmd.otaDeviceType = OtaDeviceTypeEnum.WL200;
} else {
jsoncmd.otaDeviceType = OtaDeviceTypeEnum.WE100;
} }
// deviceToolKitInstance.setDebug(true)
console.log("startOTA jsoncmd", jsoncmd);
//@ts-ignore //@ts-ignore
const value = deviceToolKitInstance.toBleCommand(jsoncmd); const value = deviceToolKitInstance.toBleCommand(jsoncmd as any);
console.log(jsoncmd); console.log(jsoncmd);
sendCommand({ value }).then((res) => { sendCommand({ value }).then((res) => {
this.setState({ this.setState({
@ -173,7 +187,7 @@ class UpdateIotWL200 extends Component<any, any> {
}; };
console.info("OTAPrepare json => ", jsoncmd); console.info("OTAPrepare json => ", jsoncmd);
//@ts-ignore //@ts-ignore
const value = deviceToolKitInstance.toBleCommand(jsoncmd); const value = deviceToolKitInstance.toBleCommand(jsoncmd as any);
sendCommand({ value }); sendCommand({ value });
} }
/** /**
@ -194,7 +208,7 @@ class UpdateIotWL200 extends Component<any, any> {
}; };
console.info("OTAUpdating json => ", jsoncmd); console.info("OTAUpdating json => ", jsoncmd);
//@ts-ignore //@ts-ignore
const value = deviceToolKitInstance.toBleCommand(jsoncmd); const value = deviceToolKitInstance.toBleCommand(jsoncmd as any);
sendCommand({ value }); sendCommand({ value });
} }
/** /**
@ -208,7 +222,7 @@ class UpdateIotWL200 extends Component<any, any> {
clearInterval(this.$checkTimer); clearInterval(this.$checkTimer);
log.info("ota成功日志, 清除计时器"); log.info("ota成功日志, 清除计时器");
//@ts-ignore //@ts-ignore
const value = deviceToolKitInstance.toBleCommand(jsoncmd); const value = deviceToolKitInstance.toBleCommand(jsoncmd as any);
sendCommand({ value }).then((res) => { sendCommand({ value }).then((res) => {
this.resetOta(); this.resetOta();
}); });
@ -231,7 +245,7 @@ class UpdateIotWL200 extends Component<any, any> {
commandType: "OTAQuit", commandType: "OTAQuit",
}; };
//@ts-ignore //@ts-ignore
const value = deviceToolKitInstance.toBleCommand(jsoncmd); const value = deviceToolKitInstance.toBleCommand(jsoncmd as any);
sendCommand({ value }) sendCommand({ value })
.then((res) => { .then((res) => {
this.resetOta(); this.resetOta();
@ -357,7 +371,7 @@ class UpdateIotWL200 extends Component<any, any> {
Taro.onBLECharacteristicValueChange((value) => { Taro.onBLECharacteristicValueChange((value) => {
// let str = ab2hex(value.value); //转为16进制字符串 // let str = ab2hex(value.value); //转为16进制字符串
// console.log('返回',str) // console.log('返回',str)
const jsonStatus = deviceToolKitInstance.toJsonStatus(value.value); const jsonStatus: any = deviceToolKitInstance.toJsonStatus(value.value);
log.info("OTA页面设备响应数据打印==》", JSON.stringify(jsonStatus)); log.info("OTA页面设备响应数据打印==》", JSON.stringify(jsonStatus));
console.info("onBLECharacteristicValueChange json => ", jsonStatus); console.info("onBLECharacteristicValueChange json => ", jsonStatus);
this.$otaDataGroup.currentPackageNo = jsonStatus.currentPackageNo; this.$otaDataGroup.currentPackageNo = jsonStatus.currentPackageNo;
@ -376,7 +390,7 @@ class UpdateIotWL200 extends Component<any, any> {
this.$checkTimer = setInterval(() => { this.$checkTimer = setInterval(() => {
// 超过7s没有回包, 直接断开 // 超过7s没有回包, 直接断开
if (this.$otaDataGroup.countDown <= 0 && this.state.hadStartOta) { if (this.$otaDataGroup.countDown <= 0 && this.state.hadStartOta) {
if (this.state.currentDevice.model == InstrumentTypeEnum.M01) { if (!this.isWL200()) {
this.quitOTA("shutDownMaskTip"); this.quitOTA("shutDownMaskTip");
} else { } else {
this.quitOTA("updateTimeOut"); this.quitOTA("updateTimeOut");
@ -412,6 +426,7 @@ class UpdateIotWL200 extends Component<any, any> {
render() { render() {
let { isShow } = this.props; let { isShow } = this.props;
let { progressbar } = this.state;
return ( return (
<Block> <Block>
<PageMeta pageStyle={isShow ? "overflow: hidden;" : ""} /> <PageMeta pageStyle={isShow ? "overflow: hidden;" : ""} />
@ -437,11 +452,11 @@ class UpdateIotWL200 extends Component<any, any> {
<View className={classnames("common-popup-content", "text-left")}> <View className={classnames("common-popup-content", "text-left")}>
<View className="progress"> <View className="progress">
<Progress <Progress
percentage={0.01 * 100} percentage={progressbar}
strokeWidth="12" strokeWidth="12"
color="linearGradient(to right, #eecda1, #ffe9c7) !important" color="linearGradient(to right, #eecda1, #ffe9c7) !important"
/> />
<View className="percent"> {0.01 * 100}%</View> <View className="percent"> {progressbar}%</View>
</View> </View>
<View className="progress-tips"></View> <View className="progress-tips"></View>
<View className="progress-tips">1.</View> <View className="progress-tips">1.</View>

@ -25,10 +25,12 @@ import PopupBinding from "@/components/popup/popup-binding";
import PopupSiteSwiper from "@/components/popup/popup-site-swiper"; import PopupSiteSwiper from "@/components/popup/popup-site-swiper";
import PopupAlert from "@/components/popup/popup-alert"; import PopupAlert from "@/components/popup/popup-alert";
import PopupConfirm from "@/components/popup/popup-confirm";
import type CustomTabBar from "@/custom-tab-bar"; import type CustomTabBar from "@/custom-tab-bar";
import Navbar from "@/components/navbar/navbar"; import Navbar from "@/components/navbar/navbar";
import ConnectionBluetoot from "@/components/bluetoot/connection"; import ConnectionBluetoot from "@/components/bluetoot/connection";
import UpdateIotWL200 from "@/components/bluetoot/update-wl200/index";
/** 自定义组件 **/ /** 自定义组件 **/
import { import {
@ -134,6 +136,10 @@ class Index extends Component<any, any> {
connectInstrument: {}, connectInstrument: {},
yiqiinfo: {}, yiqiinfo: {},
/* END */ /* END */
// 设备升级弹窗
isShowUpdateVersionTip: false, // 升级提示
isShowVersionUpgrading: false, // 升级中
}; };
} }
@ -650,96 +656,7 @@ class Index extends Component<any, any> {
versionInfo, versionInfo,
}); });
let offlinelist: any = []; let offlinelist: any = [];
offlineDataList.map((item, index) => {
let obj: any = {
clock_day: "",
status: 3,
second: 120,
screne_id: "",
screne_name: "离线打卡",
model_face_ward: 0,
model_face_use: 0,
model_face_type: "",
model_eye_ward: 0,
model_eye_use: 0,
model_eye_type: "",
instrument_id: this.state.connectInstrument.id,
};
//判断日期是否正常,如果不正常不处理 --- 脸部
if (
item.faceyear > 0 &&
item.faceyear <= 99 &&
item.facemonth >= 1 &&
item.facemonth <= 12 &&
item.faceday >= 1 &&
item.faceday <= 31
) {
if (
item.facehour > 0 ||
(item.faceminutes > 0 && item.faceminutes < 60) ||
(item.faceseconds > 0 && item.faceseconds < 60)
) {
//脸部离线记录有值
obj.model_face_use =
Number(item.facehour) * 60 * 60 +
Number(item.faceminutes) * 60 +
Number(item.faceseconds);
obj.model_face_ward = item.faceposition1;
obj.clock_day = `20${String(item.faceyear).padStart(2, "0")}-${String(
item.facemonth
).padStart(2, "0")}-${String(item.faceday).padStart(2, "0")}`;
}
}
//判断日期是否正常,如果不正常不处理 --- 眼部
if (
item.eyeyear > 0 &&
item.eyeyear <= 99 &&
item.eyemonth >= 1 &&
item.eyemonth <= 12 &&
item.eyeday >= 1 &&
item.eyeday <= 31
) {
if (
item.eyehour > 0 ||
(item.eyeminutes > 0 && item.eyeminutes < 60) ||
(item.eyeseconds > 0 && item.eyeseconds < 60)
) {
//眼部离线记录有值
obj.model_eye_use =
Number(item.eyehour) * 60 * 60 +
Number(item.eyeminutes) * 60 +
Number(item.eyeseconds);
obj.model_eye_ward = item.eyeposition1;
obj.clock_day = `20${String(item.eyeyear).padStart(2, "0")}-${String(
item.eyemonth
).padStart(2, "0")}-${String(item.eyeday).padStart(2, "0")}`;
}
}
obj.second = obj.model_face_use + obj.model_eye_use;
if (
item.faceyear > 0 &&
item.faceyear <= 99 &&
(item.facemonth == 1 || item.facemonth <= 12) &&
(item.faceday == 1 || item.faceday <= 31)
) {
let dayTime = new Date(`${obj.clock_day.replace(/-/g, "/")}`).getTime(); //离线记录的日期
let now = new Date(
`${new Date().getFullYear()}/${String(
new Date().getMonth() + 1
).padStart(2, "0")}/${String(new Date().getDate()).padStart(2, "0")}`
).getTime(); //当前日期
/**
* 7线
*
*/
if (dayTime <= now && dayTime >= now - 24 * 60 * 60 * 1000 * 6) {
offlinelist.push(obj);
}
}
});
console.log(offlinelist); console.log(offlinelist);
}; };
@ -752,8 +669,25 @@ class Index extends Component<any, any> {
connectionConfirm = async () => { connectionConfirm = async () => {
this.connectionClose(); this.connectionClose();
}; };
/*蓝牙 END*/ /*蓝牙 END*/
/** iot版本升级 */
// 是否更新弹窗
upgradeFun = () => {
this.setState({ isShowUpdateVersionTip: true, isConnectShow: false });
};
cancelUpdateVersionTip = () => {
this.setState({ isShowUpdateVersionTip: false });
};
confirmUpdateVersionTip = () => {
// 开始升级
this.setState({
isShowUpdateVersionTip: false,
isShowVersionUpgrading: true,
});
};
/** iot版本升级 END */
render() { render() {
let { let {
calendarComplete, calendarComplete,
@ -777,6 +711,10 @@ class Index extends Component<any, any> {
instrumentInfo, instrumentInfo,
instrumentList, instrumentList,
// 升级弹窗
isShowUpdateVersionTip,
isShowVersionUpgrading,
// 蓝牙连接 // 蓝牙连接
isConnectShow, isConnectShow,
connectInstrument, connectInstrument,
@ -785,6 +723,26 @@ class Index extends Component<any, any> {
return ( return (
<Block> <Block>
<View catchMove> <View catchMove>
{isShowVersionUpgrading && (
<UpdateIotWL200 isShow={isShowVersionUpgrading} />
)}
<PopupConfirm
isLarge
isClose
isShow={isShowUpdateVersionTip}
title="提示"
content={
<Block>
<View></View>
<View></View>
</Block>
}
textAlgin="center"
cancelButtonText="取消"
confirmButtonText="确定"
close={this.cancelUpdateVersionTip}
confirm={this.confirmUpdateVersionTip}
/>
<PopupAlert <PopupAlert
isShow={isNotRegister} isShow={isNotRegister}
isClose={true} isClose={true}
@ -868,6 +826,7 @@ class Index extends Component<any, any> {
confirm={this.connectionConfirm} confirm={this.connectionConfirm}
offlineChange={this.offlineChange} offlineChange={this.offlineChange}
pairingChange={this.pairingChange} pairingChange={this.pairingChange}
upgradeFun={this.upgradeFun}
/> />
)} )}
{/* <ConnectionBluetoot /> */} {/* <ConnectionBluetoot /> */}

@ -584,6 +584,8 @@ class IotCarePlan extends Component<any, any> {
// }); // });
} }
}; };
// 蓝牙特征更改
notifyBLECharacteristicValueChange = () => { notifyBLECharacteristicValueChange = () => {
console.log("notifyBLECharacteristicValueChange deviceInfo 参数为=>"); console.log("notifyBLECharacteristicValueChange deviceInfo 参数为=>");
const bluetoothInfo = this.props.bluetoothInfo; const bluetoothInfo = this.props.bluetoothInfo;

Loading…
Cancel
Save