|
|
|
|
@ -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}
|
|
|
|
|
|