master
blak-kong 2 years ago
parent 6c6b7ab662
commit aec9e1ee3e

@ -316,10 +316,10 @@ class ConnectionBluetoot extends Component<any, any> {
Taro.onBluetoothDeviceFound((item: any) => {
console.log("蓝牙查找item", item, item.devices[0].name);
console.info("搜索到到蓝牙设备 value => ", item.devices[0]?.name);
console.log(">>>>>>>当前传入设备类型>>>>>", this.props.yiqiInfo.model);
console.log(">>>>>>>当前传入设备类型>>>>>", this.props.deviceInfo.model);
// 先匹配到哪个连接哪个
let tranType = [
this.props.yiqiInfo.model, // 当前传入设备类型
this.props.deviceInfo.model, // 当前传入设备类型
...this.state.tranType,
];
for (let i = 0; i < item.devices.length; i++) {
@ -361,7 +361,7 @@ class ConnectionBluetoot extends Component<any, any> {
await closeBLEConnection(this.props.bluetoothInfo.deviceId);
} catch (e) {}
clearTimeout(connectionTimer);
const { yiqiInfo: deviceInfo } = this.props;
const { deviceInfo } = this.props;
/*********开始主动连接*******/
createBLEConnection(this.props.bluetoothInfo.deviceId)
.then((res) => {
@ -369,9 +369,6 @@ class ConnectionBluetoot extends Component<any, any> {
let { errno, errMsg } = res;
if (errno == 0) {
if (deviceInfo.model === "WL200") {
this.setState({
connectionStatus: true,
});
connectionTimer = setTimeout(() => {
if (!this.state.islian) {
if (overTimer) clearTimeout(overTimer);
@ -422,7 +419,7 @@ class ConnectionBluetoot extends Component<any, any> {
/** 7.通知BLE特征值更改 */
notifyBLECharacteristicValueChange() {
console.log("7.通知BLE特征值更改");
const { yiqiInfo: deviceInfo } = this.props;
const { deviceInfo } = this.props;
const bluetoothInfo = this.props.bluetoothInfo;
notifyBLECharacteristicValueChange({
deviceId: bluetoothInfo.deviceId,
@ -440,14 +437,6 @@ class ConnectionBluetoot extends Component<any, any> {
let str = ab2hex(value.value); //转为16进制字符串
console.log("转为16进制字符串 str", str);
let connectionStatus = [
"FR200",
"WL200",
"FR380",
"FR390",
"M01",
].includes(deviceInfo.model);
let jsonStatus: any = null;
let querySubDeviceArrayBuffer;
@ -488,7 +477,6 @@ class ConnectionBluetoot extends Component<any, any> {
if (overTimer) clearTimeout(overTimer);
this.setState({
connectionSuccess: true,
connectionStatus,
islian: true, // 不需要离线记录但暂未完全删除这部分逻辑所以直接设为true
});
@ -548,34 +536,15 @@ class ConnectionBluetoot extends Component<any, any> {
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 不需要在这里进行蓝牙更新
// if (isNeedToUpdateBl) {
// const pages = getCurrentPages();
// const matchPageList = [{
// route: 'pages/MatrixWL200/pages/index/index'
// },{
// route: 'pages/MatrixM01/pages/index/index'
// }];
// const hadOpen = checkSameKey(pages, matchPageList, 'route');
// if (!hadOpen) {
// this.triggerEvent("pairingChange", { deviceVersionNo });
// this.pairingChange({ deviceVersionNo });
// }
// } else {
// this.sendSyncRecording()
// }
break;
case "offlineClockSummary":
clearTimeout(isGetSyncRecordingTimer);
@ -651,7 +620,7 @@ class ConnectionBluetoot extends Component<any, any> {
// 8.发送指令:获取仪器版本号
sendGetVersion() {
const { yiqiInfo: deviceInfo } = this.props;
const { deviceInfo } = this.props;
const isFRDevice = ["FR200", "FR380", "FR390"].includes(deviceInfo.model);
// log.info(commandMap.sendVersionCommand, `仪器:${deviceInfo.model}`);
console.log(commandMap.sendVersionCommand, `仪器:${deviceInfo.model}`);
@ -730,7 +699,7 @@ class ConnectionBluetoot extends Component<any, any> {
/** 9.发送配对码 */
sendPairingSignal() {
console.log("9.发送配对码 sendPairingSignal");
const { yiqiInfo: deviceInfo } = this.props;
const { deviceInfo } = this.props;
// log.info(commandMap.sendMatchCode, `仪器:${deviceInfo.model}发送匹配码`);
console.log(commandMap.sendMatchCode, `仪器:${deviceInfo.model}发送匹配码`);
let matchArrayBuffer: any = null;
@ -971,9 +940,7 @@ class ConnectionBluetoot extends Component<any, any> {
if (sendGetVersionTimerNum >= 10) {
// 超时未返回版本号
if (isGetVersionTimer) clearTimeout(isGetVersionTimer);
this.setState({
connectionStatus: true,
});
console.log("超时未返回版本号 this.pairingChange", this.state);
// this.pairingChange(this.state);
} else {
@ -995,7 +962,7 @@ class ConnectionBluetoot extends Component<any, any> {
/** 发送同步记录 */
sendSyncRecording() {
const { yiqiInfo: deviceInfo } = this.props;
const { deviceInfo } = this.props;
const versionCommand = {
commandType: "InfoQuery",
infoQueryType: "offlineClockSummary",
@ -1036,18 +1003,16 @@ class ConnectionBluetoot extends Component<any, any> {
};
render() {
let { name, isConnection, connectionStatus, connectionSuccess, error } =
this.state;
let { yiqiInfo } = this.props;
let { name, isConnection, connectionSuccess, error } = this.state;
let { deviceInfo } = this.props;
return (
<Block>
<DeviceConnectPopup
close={this.onClose}
confirm={this.onConfirm}
reconnect={this.onReconnect}
data={yiqiInfo}
data={deviceInfo}
isShow={true}
// connectionStatus={connectionStatus}
connectionSuccess={connectionSuccess}
isConnection={isConnection}
error={error}

@ -318,7 +318,10 @@ class UpdateIotWL200 extends Component<any, any> {
break;
case "OTAUpdateFinish":
console.log("完成OTA传输");
log.info("ota成功日志, 但是这个分支什么都没做");
this.setState({
progressbar: 100,
});
this.finishFun();
// quitOTA()
break;
default:
@ -331,7 +334,7 @@ class UpdateIotWL200 extends Component<any, any> {
getDeviceUpgrade = async () => {
let res: any = await InstrumentInfo.getUpgrade({
instrumentId: this.state.currentDevice.id,
isWe200: true,
isWe200: !this.isWL200(),
});
if (res.data.data == "解析失败") {
// this.showError('文件解析失败');
@ -412,16 +415,17 @@ class UpdateIotWL200 extends Component<any, any> {
Taro.stopPullDownRefresh();
}
onClose = () => {
this.props.close();
onClickStop = (e) => {
e.stopPropagation();
};
onConfirm = () => {
this.props.confirm();
// 错误关闭回调
errorFun = () => {
this.props.errorFun();
};
onClickStop = (e) => {
e.stopPropagation();
// 升级完成回调
finishFun = () => {
this.props.finishFun();
};
render() {

@ -9,6 +9,7 @@ import {
Image,
Swiper,
SwiperItem,
RichText,
} from "@tarojs/components";
/*** redux ***/
@ -58,7 +59,7 @@ import {
const log = require("@/utils/log");
import commandMap from "@/utils/commandMap";
import InstrumentTypeEnum from "@/components/bluetoot/instrumentTypeEnum";
import InstrumentTypeEnum from "@/components/bluetoot/InstrumentTypeEnum";
import OtaDeviceTypeEnum from "@/components/bluetoot/OtaDeviceTypeEnum";
class Index extends Component<any, any> {
@ -133,13 +134,14 @@ class Index extends Component<any, any> {
/** 蓝牙相关 */
isConnectShow: false,
connectInstrument: {},
yiqiinfo: {},
connectInstrument: {}, // 当前连接设备
/* END */
// 设备升级弹窗
isShowUpdateVersionTip: false, // 升级提示
isShowVersionUpgrading: false, // 升级中
isShowVersionUpgradFinish: false, // 升级完成:升级内容公告
versionUpgradFinishNodes: "", // 公告内容
};
}
@ -671,21 +673,60 @@ class Index extends Component<any, any> {
};
/*蓝牙 END*/
/** iot版本升级 */
/** 设备iot固件版本升级 */
// 是否更新弹窗
upgradeFun = () => {
this.setState({ isShowUpdateVersionTip: true, isConnectShow: false });
};
cancelUpdateVersionTip = () => {
// 关闭提示
this.setState({ isShowUpdateVersionTip: false });
};
confirmUpdateVersionTip = () => {
// 开始升级
// 提示升级与开始升级
this.setState({
isShowUpdateVersionTip: false,
isShowVersionUpgrading: true,
});
};
// 完成升级
wl200UpgradeFinishFun = (isWL200) => {
let { connectInstrument } = this.state;
console.log("connectInstrument", connectInstrument);
let content = "";
if (isWL200) {
content = connectInstrument.iotVersionUpgrade;
} else {
content = connectInstrument.we200IotVersionUpgrade;
}
let nodes = decodeURIComponent(content || "");
nodes = nodes.replace(/\<img/gi, '<img style="width:100%;height:auto" ');
nodes = nodes.replace(
/\<table/gi,
'<table style="border-spacing: 0;border-collapse: collapse;border: 1px solid #000" '
);
nodes = nodes.replace(
/\<td/gi,
'<td style="border: 1px solid #000;text-align:center" '
);
this.setState({
isShowVersionUpgrading: false,
versionUpgradFinishNodes: nodes,
});
};
// 升级失败
wl200UpgradeErrorFun = () => {
this.setState({
isShowVersionUpgrading: false,
});
};
// 关闭升级完成公告
onVersionUpgradFinish = () => {
this.setState({
isShowVersionUpgradFinish: false,
});
};
/** iot版本升级 END */
render() {
@ -714,6 +755,8 @@ class Index extends Component<any, any> {
// 升级弹窗
isShowUpdateVersionTip,
isShowVersionUpgrading,
isShowVersionUpgradFinish,
versionUpgradFinishNodes,
// 蓝牙连接
isConnectShow,
@ -723,25 +766,20 @@ class Index extends Component<any, any> {
return (
<Block>
<View catchMove>
{isShowVersionUpgrading && (
<UpdateIotWL200 isShow={isShowVersionUpgrading} />
)}
<PopupConfirm
isLarge
isClose
isShow={isShowUpdateVersionTip}
<PopupAlert
isShow={isBindingError}
title="提示"
content={
<Block>
<View></View>
<View></View>
<View></View>
<View></View>
</Block>
}
confirmButtonText="知道了"
textAlgin="center"
cancelButtonText="取消"
confirmButtonText="确定"
close={this.cancelUpdateVersionTip}
confirm={this.confirmUpdateVersionTip}
isClose={false}
close={this.onBindErrorClose}
confirm={this.onBindErrorConfirm}
/>
<PopupAlert
isShow={isNotRegister}
@ -791,7 +829,7 @@ class Index extends Component<any, any> {
isClose={false}
close={this.onBindErrorClose}
confirm={this.onBindErrorConfirm}
></PopupAlert>
/>
<PopupAlert
isShow={isBeforeBinding}
title="提示"
@ -801,7 +839,7 @@ class Index extends Component<any, any> {
isClose={false}
close={this.onBeforeBindClose}
confirm={this.onBeforeBindConfirm}
></PopupAlert>
/>
{/* <PopupPrivacyTest
closePrivacy={this.closePrivacy.bind(this)}
@ -817,19 +855,60 @@ class Index extends Component<any, any> {
close={this.closeSiteSwiper}
confirm={this.closeSiteSwiper}
/>
</View>
{isConnectShow && (
<ConnectionBluetoot
yiqiInfo={connectInstrument}
close={this.connectionClose}
confirm={this.connectionConfirm}
offlineChange={this.offlineChange}
pairingChange={this.pairingChange}
upgradeFun={this.upgradeFun}
{/* IOT相关弹窗 */}
{isConnectShow && (
<ConnectionBluetoot
deviceInfo={connectInstrument}
close={this.connectionClose}
confirm={this.connectionConfirm}
offlineChange={this.offlineChange}
pairingChange={this.pairingChange}
upgradeFun={this.upgradeFun}
/>
)}
<PopupConfirm
isLarge
isClose
isShow={isShowUpdateVersionTip}
title="提示"
content={
<Block>
<View></View>
<View></View>
</Block>
}
textAlgin="center"
cancelButtonText="取消"
confirmButtonText="确定"
close={this.cancelUpdateVersionTip}
confirm={this.confirmUpdateVersionTip}
/>
)}
{/* <ConnectionBluetoot /> */}
{isShowVersionUpgrading && (
<UpdateIotWL200
isShow={isShowVersionUpgrading}
finishFun={this.wl200UpgradeFinishFun}
errorFun={this.wl200UpgradeErrorFun}
/>
)}
<PopupAlert
isShow={isShowVersionUpgradFinish}
title="升级内容公告"
content={
<Block>
<View className="nodes">
<RichText nodes={versionUpgradFinishNodes} />
</View>
</Block>
}
confirmButtonText="知道了"
textAlgin="left"
isClose
close={this.onVersionUpgradFinish}
confirm={this.onVersionUpgradFinish}
/>
{/* IOT相关弹窗 END */}
</View>
<Navbar
leftSlot={

@ -148,10 +148,6 @@ class IotCarePlan extends Component<any, any> {
model: "",
}, // 当前设备
// 升级弹窗
isShowUpdateVersionTip: false, // 升级提示
isShowVersionUpgrading: false, // 升级中
/** 连接设备 */
hasVersion: false, // 是否已查询到版本号
curDeviceInfo: {}, // 当前设备信息
@ -703,7 +699,6 @@ class IotCarePlan extends Component<any, any> {
this.setState({
hasVersion: true,
});
this.checkOta(jsonStatus.versionNo);
}
break;
// 当前报告
@ -784,25 +779,6 @@ class IotCarePlan extends Component<any, any> {
});
};
checkOta = async (versionNo) => {
const { iotVersion } = this.state.currentDevice;
let isNeedToUpdateBl = isNeedToUpdate(versionNo, iotVersion);
console.log(
`设备版本号: ${versionNo}`,
`后台版本号: ${iotVersion}`,
`是否需要升级: ${isNeedToUpdateBl}`
);
if (isNeedToUpdateBl) {
// 暂停查询, 不然无法升级面罩
this.setState({ isShowUpdateVersionTip: true });
// this.setState({
// isAskedOta: true,
// // currentShowDialog: 'offlineDialog',
// });
// this.confirmOta();
}
};
//待完善,以后同步设备数据到小程序的事件,在这个事件里判断是否需要更新页面(是否需要触发setData)
updateDeviceSyncData = (newData, jsonStatus) => {
DeviceSyncData = {
@ -1477,19 +1453,6 @@ class IotCarePlan extends Component<any, any> {
};
/** 护理记录 End */
/** iot版本升级 */
cancelUpdateVersionTip = () => {
this.setState({ isShowUpdateVersionTip: false });
};
confirmUpdateVersionTip = () => {
// 开始升级
this.setState({
isShowUpdateVersionTip: false,
isShowVersionUpgrading: true,
});
};
/** iot版本升级 END */
render() {
let {
name,
@ -1523,29 +1486,7 @@ class IotCarePlan extends Component<any, any> {
<Navbar titleSlot={title} isBack={true} />
<View catchMove>
{isShowVersionUpgrading && (
<UpdateIotWL200 isShow={isShowVersionUpgrading} />
)}
<PopupCountdown isShow={isShowCountdown} countdown={countdown} />
<PopupConfirm
isLarge
isClose
isShow={isShowUpdateVersionTip}
title="提示"
content={
<Block>
<View></View>
<View></View>
</Block>
}
textAlgin="center"
cancelButtonText="取消"
confirmButtonText="确定"
close={this.cancelUpdateVersionTip}
confirm={this.confirmUpdateVersionTip}
/>
<PopupConfirm
isLarge
isClose

Loading…
Cancel
Save