修复蓝牙连接锁未释放的问题
This commit is contained in:
@ -35,7 +35,8 @@
|
||||
</view>
|
||||
<view class="centertxt ">
|
||||
<view class="name" v-text="item.name"></view>
|
||||
|
||||
|
||||
|
||||
</view>
|
||||
<view class="rightIco center">
|
||||
<image src="/static/images/BLEAdd/linked.png" class="img" mode="aspectFit">
|
||||
@ -48,11 +49,12 @@
|
||||
</view>
|
||||
|
||||
<view class="lblTitle">
|
||||
<text>发现设备:{{deviceCnt}}</text>
|
||||
<text>发现设备:{{EquipMents.length}} 筛选设备:{{deviceCnt}}</text>
|
||||
|
||||
<view @click="refreshBleList()">刷新</view>
|
||||
</view>
|
||||
<view class="">
|
||||
<input class="uni-input" v-model="search" placeholder="名称筛选" />
|
||||
<input class="uni-input" v-model="search" placeholder="名称筛选" />
|
||||
</view>
|
||||
<view class="list searchList">
|
||||
<view class="item" v-on:click="Link(item,index)" v-for="item, index in EquipMents"
|
||||
@ -66,11 +68,13 @@
|
||||
<view class="name">
|
||||
<text>{{item.name?item.name:'Unnamed'}}</text>
|
||||
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="id">
|
||||
<text>信号:{{item.RSSI}}dBm</text>
|
||||
</view>
|
||||
<view class="id" v-if="item.advertisData">
|
||||
<text>广播数据:{{item.advertisData}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="rightIco center">
|
||||
@ -272,7 +276,7 @@
|
||||
}
|
||||
console.log("处理蓝牙不可用");
|
||||
hideLoading(these);
|
||||
|
||||
|
||||
these.PairEquip = [];
|
||||
these.EquipMents = [];
|
||||
uni.showToast({
|
||||
@ -289,11 +293,11 @@
|
||||
these.Status.BottomMenu.show = false;
|
||||
these.PairEquip = [];
|
||||
these.EquipMents = [];
|
||||
|
||||
|
||||
if (these.Status.isPageHidden) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
uni.showToast({
|
||||
icon: 'fail',
|
||||
title: '蓝牙恢复可用'
|
||||
@ -321,7 +325,6 @@
|
||||
|
||||
//搜索到新设备的回调 (Always active)
|
||||
ble.addDeviceFound((arr) => {
|
||||
// console.log("--- 收到原始扫描数据 ---", JSON.stringify(arr));
|
||||
if (these.Status.isPageHidden) {
|
||||
return;
|
||||
}
|
||||
@ -330,7 +333,6 @@
|
||||
}
|
||||
arr = arr.devices;
|
||||
|
||||
// console.log(`本次扫描批次发现 ${arr.length} 个设备`);
|
||||
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
let device = arr[i];
|
||||
@ -338,9 +340,7 @@
|
||||
|
||||
let f = these.EquipMents.find((v, index) => {
|
||||
if (v.deviceId == device.deviceId) {
|
||||
// console.log(
|
||||
// `更新设备信号: ${device.name || device.deviceId}, RSSI: ${device.RSSI}`
|
||||
// );
|
||||
|
||||
these.$set(these.EquipMents[index], 'RSSI', device.RSSI);
|
||||
return true;
|
||||
}
|
||||
@ -348,11 +348,10 @@
|
||||
});
|
||||
|
||||
if (!f) {
|
||||
// console.log("+++ 发现新设备,准备添加到列表:", JSON.stringify(device));
|
||||
|
||||
|
||||
if (these.device && these.device.bluetoothName && device.name) {
|
||||
const bn = these.device.bluetoothName;
|
||||
if (these.device.bluetoothName === device.name ||
|
||||
if (bn === device.name ||
|
||||
(device.name.indexOf(bn) > -1) ||
|
||||
(bn.indexOf(device.name) > -1)) {
|
||||
device.isTarget = true;
|
||||
@ -364,8 +363,11 @@
|
||||
these.EquipMents.push(device);
|
||||
}
|
||||
|
||||
these.EquipMents.sort((a, b) => b.RSSI - a.RSSI); //信号好的排前面,一般信号好的是目标设备
|
||||
|
||||
}
|
||||
|
||||
these.EquipMents.sort((a, b) => b.RSSI - a.RSSI); //信号好的排前面,一般信号好的是目标设备
|
||||
|
||||
}, pagePath);
|
||||
|
||||
//蓝牙连接已恢复的回调
|
||||
@ -625,7 +627,7 @@
|
||||
return;
|
||||
}
|
||||
hideLoading(these);
|
||||
|
||||
these.device.bleId=deviceId;
|
||||
eventChannel.emit('BindOver', these.device);
|
||||
|
||||
ble.updateCache();
|
||||
|
||||
Reference in New Issue
Block a user