修复蓝牙连接锁未释放的问题
This commit is contained in:
@ -40,17 +40,25 @@
|
||||
</view>
|
||||
<view class="device-name">
|
||||
<view>设备:{{item.deviceName}}</view>
|
||||
|
||||
<view class="ID">
|
||||
<view class="ID"
|
||||
v-if="item.communicationMode==0 || item.communicationMode==2">
|
||||
ID:{{item.deviceImei}}
|
||||
ID:{{item.deviceImei?item.deviceImei:item.deviceMac}}
|
||||
</view>
|
||||
|
||||
|
||||
<view class="ID">
|
||||
|
||||
<view class="center p10">
|
||||
<view
|
||||
:class="{'onlines':item.onlineStatus==1,'offlines':item.onlineStatus==0}">
|
||||
{{item.onlineStatus==1?'在线':'离线'}}
|
||||
</view>
|
||||
<view class="splitLine"></view>
|
||||
|
||||
<view>电量:{{item.battery || '0'}}%</view>
|
||||
</view>
|
||||
<view class="ID" v-else>ID:{{item.deviceMac}}</view>
|
||||
<!-- 在线状态 -->
|
||||
<view class="onlines" v-if="item.onlineStatus==1">在线</view>
|
||||
<!-- 离线状态 -->
|
||||
<view class="offlines" v-if="item.onlineStatus==0">离线</view>
|
||||
<view>电量:{{item.battery || '0'}}%</view>
|
||||
|
||||
<!-- <view @click.stop="Disc()">识别</view> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -154,6 +162,10 @@
|
||||
import bleTool from '@/utils/BleHelper.js';
|
||||
import MescrollUni from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-uni.vue'
|
||||
import BleReceive from '@/utils/BleReceive';
|
||||
import {
|
||||
MsgError
|
||||
} from '@/utils/MsgPops';
|
||||
import MqttClient from '@/utils/mqtt.js';
|
||||
|
||||
var pagePath = 'pages/common/index';
|
||||
var ble = null;
|
||||
@ -707,6 +719,62 @@
|
||||
}
|
||||
this.$set(this.deviceList[index], 'showOption', 'none');
|
||||
},
|
||||
Disc(item, index) { //发送识别指令
|
||||
let json = {
|
||||
ins_disc: 1
|
||||
};
|
||||
|
||||
let bleSend = () => {
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
return v.macAddress == item.deviceMac;
|
||||
});
|
||||
if (f) {
|
||||
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
|
||||
index++;
|
||||
setTimeout(sendNextPacket, 300);
|
||||
}).catch(err => {
|
||||
if (item.communicationMode == 1) {
|
||||
MsgError(err.msg, '', this);
|
||||
return;
|
||||
}
|
||||
mqSend();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let mqSend = () => {
|
||||
let Send = () => {
|
||||
let flag = mq.publish("B/" + item.deviceImei, JSON.stringify(json));
|
||||
if (!flag) {
|
||||
MsgError("识别设备失败,请检查手机网络连接", '', this);
|
||||
}
|
||||
}
|
||||
if (!mq) {
|
||||
mq = new MqttClient();
|
||||
mq.connect(() => {
|
||||
console.log("MQTT连接成功")
|
||||
Send();
|
||||
});
|
||||
return ;
|
||||
}
|
||||
Send();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (item.communicationMode == 1 || item.communicationMode == 2) {
|
||||
bleSend.catch(ex => {
|
||||
mqSend();
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (item.communicationMode == 0) {
|
||||
mqSend();
|
||||
return;
|
||||
}
|
||||
},
|
||||
// 列表跳转
|
||||
handleFile(item, index) {
|
||||
if (item.showOption == 'right') {
|
||||
@ -966,7 +1034,8 @@
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
}
|
||||
.device-card.active{
|
||||
|
||||
.device-card.active {
|
||||
background-color: #2a2a2a !important;
|
||||
}
|
||||
|
||||
@ -1316,4 +1385,17 @@
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.splitLine {
|
||||
background: linear-gradient(90.00deg, rgba(0, 0, 0, 0), rgba(255, 255, 255, 1) 44.525%, rgba(255, 254.75, 254.75, 0) 92%);
|
||||
opacity: 0.2;
|
||||
width: 25rpx;
|
||||
height: 4rpx;
|
||||
margin: 0rpx 10rpx;
|
||||
transform: rotate(90.00deg);
|
||||
}
|
||||
|
||||
.p10 {
|
||||
padding-left: 20rpx;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user