修改蓝牙发现逻辑自动连接过的不再被发现的问题,上架驳回问题处理
This commit is contained in:
@ -152,11 +152,36 @@
|
||||
},
|
||||
onLoad() {
|
||||
these = this;
|
||||
this.EquipMents = [];
|
||||
ble = bleTool.getBleTool();
|
||||
//已连接过但删除了设备
|
||||
let delArr = ble.data.deletedEqs.map(v => {
|
||||
return {
|
||||
"deviceId": v.deviceId,
|
||||
"name": v.name,
|
||||
"RSSI": -99,
|
||||
"localName": v.name,
|
||||
}
|
||||
});
|
||||
//已连接过但没绑定过的设备
|
||||
let noDev=ble.data.LinkedList.filter(v=>{
|
||||
return !(v.device && v.device.id);
|
||||
}).map(v => {
|
||||
return {
|
||||
"deviceId": v.deviceId,
|
||||
"name": v.name,
|
||||
"RSSI": -99,
|
||||
"localName": v.name,
|
||||
}
|
||||
});
|
||||
delArr=delArr.concat(noDev);
|
||||
|
||||
console.log("可能搜不到的设备=", delArr);
|
||||
this.EquipMents = delArr;
|
||||
|
||||
|
||||
|
||||
ble.addDeviceFound((arr) => {
|
||||
|
||||
// console.log("发现新设备,",arr);
|
||||
arr = arr.devices;
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
|
||||
@ -164,12 +189,16 @@
|
||||
if (!arr[i].name) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let f = these.EquipMents.find(function(v) {
|
||||
return v.deviceId == arr[i].deviceId;
|
||||
});
|
||||
|
||||
if (!f) {
|
||||
|
||||
if (arr[i].deviceId == '35:06:00:EF:46:51') {
|
||||
console.log("EquipMents=", these.EquipMents);
|
||||
console.log("arr[i]=", arr[i]);
|
||||
}
|
||||
these.EquipMents.push(arr[i]);
|
||||
} else {
|
||||
|
||||
@ -207,6 +236,7 @@
|
||||
|
||||
|
||||
// this.EquipMents = [];
|
||||
|
||||
this.PairEquip = [];
|
||||
ble && ble.StartSearch().then(res => {
|
||||
console.log("开始搜索成功", res);
|
||||
@ -216,11 +246,6 @@
|
||||
these.showOpenSetting();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
methods: {
|
||||
isItemLink: function(item, index) {
|
||||
@ -260,19 +285,19 @@
|
||||
}
|
||||
return false;
|
||||
});
|
||||
let removeLink=()=>{
|
||||
ble.subScribe(deviceId,false);//取消订阅消息
|
||||
ble.DropDevice(deviceId);//从缓存中删除该设备
|
||||
ble.disconnectDevice(deviceId);//断开与该设备的连接
|
||||
|
||||
let index=this.PairEquip.findIndex(function(v) {
|
||||
let removeLink = () => {
|
||||
ble.subScribe(deviceId, false); //取消订阅消息
|
||||
ble.DropDevice(deviceId); //从缓存中删除该设备
|
||||
ble.disconnectDevice(deviceId); //断开与该设备的连接
|
||||
these.device.deviceMac="";
|
||||
let index = this.PairEquip.findIndex(function(v) {
|
||||
return v.deviceId == deviceId;
|
||||
});
|
||||
if(index>-1){
|
||||
this.PairEquip.splice(index,1);
|
||||
if (index > -1) {
|
||||
this.PairEquip.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
console.log("f=", f);
|
||||
if (f.macAddress) {
|
||||
|
||||
@ -282,7 +307,7 @@
|
||||
updateLoading(these, {
|
||||
text: "设备Mac地址错误,请重选设备连接"
|
||||
});
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
hideLoading(these);
|
||||
}, 1000)
|
||||
@ -300,9 +325,9 @@
|
||||
|
||||
|
||||
this.Status.intval = null;
|
||||
|
||||
|
||||
this.Status.intval = setInterval(() => {
|
||||
this.Status.time = this.Status.time-1;
|
||||
this.Status.time = this.Status.time - 1;
|
||||
if (this.Status.time < 0) {
|
||||
|
||||
clearInterval(this.Status.intval)
|
||||
@ -315,15 +340,15 @@
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if(!f.macAddress){
|
||||
if (!f.macAddress) {
|
||||
removeLink();
|
||||
updateLoading(these, {
|
||||
updateLoading(these, {
|
||||
text: "出现错误,未收到设备Mac地址"
|
||||
});
|
||||
|
||||
setTimeout(()=>{
|
||||
|
||||
setTimeout(() => {
|
||||
hideLoading(these)
|
||||
},1000);
|
||||
}, 1000);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -387,7 +412,7 @@
|
||||
}
|
||||
ble.LinkBlue(item.deviceId).then((res) => {
|
||||
console.log("连接成功");
|
||||
|
||||
ble.StopSearch();
|
||||
resolve(res);
|
||||
}).catch((ex) => {
|
||||
if (index == total) {
|
||||
|
||||
Reference in New Issue
Block a user