1
0
forked from dyf/APP

修复有时候蓝牙配对成功依然提示未连接的异常

This commit is contained in:
liub
2026-05-20 10:58:55 +08:00
parent 7ed3813e7c
commit 7f56e46ace
19 changed files with 1031 additions and 914 deletions

View File

@ -96,7 +96,7 @@
<view class="mode type " :class="{'active':formData.sta_Ms=='M'}" @click.stop="modeToggle('M')">
<view class="txt center">M</view>
</view>
<view class="mode type" :class="{'active':formData.sta_Ms=='S'}" @click.stop="modeToggle('S')">
<view class="mode type" :class="{'active':formData.sta_Ms=='S'}" @click.stop="modeToggle('S')">
<view class="txt center">S</view>
</view>
@ -562,14 +562,7 @@
if (these.device.deviceImei) {
these.initMQ();
}
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) {
console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
let f = these.getDevice();
if (!f) {
these.showBleUnConnect();
these.getDetail();
@ -1277,9 +1270,9 @@
if (!batchTool) {
batchTool = new SendBatchData(these, f, ble);
}
console.log("batch",batchTool);
console.log("batch", batchTool);
// batchTool.SendUsr(4);
let txts=[these.formData.company, these.formData.name, these.formData.job,this.formData.id]
let txts = [these.formData.company, these.formData.name, these.formData.job, this.formData.id]
batchTool.sendUsrByGBK(txts);
return;
@ -1382,15 +1375,15 @@
let json = {
ins_Ms: newVal
};
console.log("new=", this.formData.sta_Ms);
these.setBleFormData();
console.log("these.formData.sta_Ms=" + these.formData.sta_Ms);
if (ble && f) {
ble.sendString(f.deviceId, json).then(res=>{
ble.sendString(f.deviceId, json).then(res => {
these.formData.sta_Ms = newVal;
}).catch(ex => {
these.mqSend(json);
@ -1467,19 +1460,23 @@
});
},
getDevice: function() {
let f ={deviceId:'123'};
// #ifdef APP
f= ble.data.LinkedList.find((v) => {
if (v.macAddress == these.device.deviceMac) {
if (!this.formData.deviceId) {
this.formData.deviceId = v.deviceId
};
return true;
let f = ble.data.LinkedList.find((v) => {
let flag = v.macAddress == these.device.deviceMac;
if (!flag && v.device) {
flag = v.device.id == these.device.id;
}
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
});
// #endif
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f;
},
@ -1526,25 +1523,25 @@
if (!batchTool) {
batchTool = new SendBatchData(these, f, ble);
}
batchTool.SendMsgByGBK(this.formData.textLines,mq);
batchTool.SendMsgByGBK(this.formData.textLines, mq);
return;
showLoading(this, {
text: "发送中"
});
//握手
let holdHand = (hexs, time) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(true)
}, time);
});
}
//发送3个分包的数据
let task = (allPixels) => {
try {
@ -1641,7 +1638,7 @@
}, 500);
return;
}
console.log("开始发送数据包");
task(results[1].value);
})
@ -1756,7 +1753,7 @@
}
if (res.deviceId == these.formData.deviceId) {
this.formData.bleStatu = true;
}
},