1
0
forked from dyf/APP

蓝牙发现服务重试时间逐步增加

This commit is contained in:
liub
2025-10-23 10:42:30 +08:00
parent 2d3b896243
commit 2339c1c8d0

View File

@ -548,7 +548,7 @@ class BleHelper {
console.log("蓝牙连接状态变化了", res); console.log("蓝牙连接状态变化了", res);
// 检查状态是否真的发生了变化 // 检查状态是否真的发生了变化
if (bleDeviceStates[res.deviceId] === res.connected) { if (bleDeviceStates[res.deviceId] === res.connected) {
console.error('专业给Uniapp填坑,连接状态'); console.error('专业给Uniapp填坑,连接状态重复回调');
return; return;
} }
@ -925,7 +925,7 @@ class BleHelper {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
Promise.race([p1, p2]).then(resolve).catch(ex => { Promise.race([p1, p2]).then(resolve).catch(ex => {
if (ex.code == -1) { if (ex.code == -1) {
console.error('专业给Uniapp填坑,停止搜索'); console.error('专业给Uniapp填坑,停止搜索永无回调处理');
resolve(); resolve();
return; return;
} }
@ -1037,7 +1037,7 @@ class BleHelper {
Promise.race([p1, p2]).then(succ).catch(ex => { Promise.race([p1, p2]).then(succ).catch(ex => {
// console.error("异常了:",ex); // console.error("异常了:",ex);
if (ex.code == -1) { if (ex.code == -1) {
console.error('专业给Uniapp填坑,订阅成功'); console.error('专业给Uniapp填坑,订阅消息永无回调了');
succ(); succ();
return; return;
} }
@ -1222,7 +1222,7 @@ class BleHelper {
} }
setTimeout(function() { setTimeout(function() {
startgetService(id); startgetService(id);
}, 100); }, 100+repeatCnt*300);
} }
}, },
fail: (ex) => { fail: (ex) => {
@ -1697,7 +1697,7 @@ class BleHelper {
Promise.race([timeOut(ms), promise]).then(resolve).catch((ex) => { Promise.race([timeOut(ms), promise]).then(resolve).catch((ex) => {
// console.error("ex=", ex); // console.error("ex=", ex);
if (ex.code == -1) { if (ex.code == -1) {
console.error('专业给Uniapp填坑,发送成功'); console.error('专业给Uniapp填坑,发送消息永无回调');
resolve(ex); resolve(ex);
} else { } else {
reject(ex); reject(ex);