Compare commits

..

4 Commits

Author SHA1 Message Date
738ce209a6 跟朱工合并7305的功能
# Conflicts:
#	utils/BleHelper.js
#	utils/BleReceive.js
2025-10-23 16:10:53 +08:00
1ac41b3ed5 蓝牙接收数据统一处理修改 2025-10-23 15:40:17 +08:00
f51b6c5a85 一点小优化,从设备详情去绑定蓝牙设备,成功后更新设备详情的连接状态 2025-10-23 14:54:12 +08:00
2339c1c8d0 蓝牙发现服务重试时间逐步增加 2025-10-23 10:42:30 +08:00
6 changed files with 20 additions and 16 deletions

View File

@ -731,6 +731,7 @@
events: { events: {
BindOver: function(data) { BindOver: function(data) {
console.log(data) console.log(data)
these.formData.bleStatu=true;
} }
}, },
success: function(res) { success: function(res) {

View File

@ -692,6 +692,7 @@ console.log("res=",res);
events: { events: {
BindOver: function(data) { BindOver: function(data) {
console.log(data) console.log(data)
these.formData.bleStatu=true;
} }
}, },
success: function(res) { success: function(res) {

View File

@ -643,6 +643,7 @@
events: { events: {
BindOver: function(data) { BindOver: function(data) {
console.log(data) console.log(data)
these.formData.bleStatu=true;
} }
}, },
success: function(res) { success: function(res) {

View File

@ -466,10 +466,12 @@
return f; return f;
}, },
bleValueNotify: function(receive, device, path) { bleValueNotify: function(receive, device, path) {
if (this.Status.pageHide) { if (this.Status.pageHide) {
return; return;
} }
let json = recei.ReceiveData(receive, device, path); let json = recei.ReceiveData(receive, device, path);
if (!json) { if (!json) {
return; return;
} }

View File

@ -470,6 +470,8 @@
} }
hideLoading(these); hideLoading(these);
eventChannel.emit('BindOver',these.device);
ble.updateCache(); ble.updateCache();
uni.navigateBack(); uni.navigateBack();
return true; return true;

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;
} }
@ -729,12 +729,13 @@ class BleHelper {
this.updateCache(); this.updateCache();
} }
} }
console.log("str=", str); // console.log("str1=", str);
} catch (ex) { } catch (ex) {
console.error("将数据转文本失败", ex); console.error("将数据转文本失败", ex);
} }
try { try {
console.log("11111");
let recData = { let recData = {
deviceId: receive.deviceId, deviceId: receive.deviceId,
serviceId: receive.serviceId, serviceId: receive.serviceId,
@ -925,7 +926,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 +1038,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 +1223,8 @@ class BleHelper {
} }
setTimeout(function() { setTimeout(function() {
startgetService(id); startgetService(id);
}, 1000);
}, 100+repeatCnt*300);
} }
}, },
fail: (ex) => { fail: (ex) => {
@ -1411,14 +1413,9 @@ class BleHelper {
// 处理 MTU 设置 // 处理 MTU 设置
if (plus.os.name === 'Android') { if (plus.os.name === 'Android') {
this.setMtu(deviceId).then(() => { this.setMtu(deviceId);
resolve(true);
}).catch(() => {
resolve(true); //mtu设置失败也算成功
})
} else {
resolve(true);
} }
resolve(true);
}).catch((ex) => { }).catch((ex) => {
reject(this.getError(ex)); reject(this.getError(ex));
@ -1702,7 +1699,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);