修改蓝牙发现逻辑自动连接过的不再被发现的问题,上架驳回问题处理

This commit is contained in:
liub
2025-09-26 13:50:29 +08:00
parent 21e468c79f
commit 3ac113de3f
6 changed files with 104 additions and 47 deletions

View File

@ -285,6 +285,7 @@
ble.removeReceiveCallback(pagePath);
clearTimeout(this.Statu.timeInteval);
this.device.macAddress=null;
this.Statu.timeInteval=null;
uni.$emit("refreshDeviceList");
setTimeout(() => {

View File

@ -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) {

View File

@ -467,7 +467,8 @@
if (this.$refs.swipeAction) {
this.$refs.swipeAction.closeAll();
}
console.log("111111",this.deviceId);
console.log("ble==null,",ble)
ble && ble.DropDevice(this.deviceId.id);
} else {
uni.showToast({

View File

@ -72,8 +72,8 @@
data() {
return {
showView: false,
phone: '13800138002', //手机号码
code: "123456", //验证码
phone: '', //手机号码
code: "", //验证码
password: "",
agreed: false,
isCounting: false,