100J蓝牙设备上报问题解决
This commit is contained in:
@ -1728,28 +1728,18 @@ class BleHelper {
|
||||
return linkDevice(deviceId);
|
||||
}).then((res) => {
|
||||
|
||||
if (res) { //新连接
|
||||
if (res) { //新连接(含 createBLEConnection 刚成功)
|
||||
// console.log("11111111");
|
||||
if (fIndex == -1) {
|
||||
// console.log("开始获取服务", targetServiceId)
|
||||
return this.getService(deviceId, targetServiceId, writeCharId,
|
||||
notifyCharId); //获取服务
|
||||
} else {
|
||||
if (f.wirteCharactId && f.notifyCharactId) {
|
||||
if (!f.notifyState) {
|
||||
// console.log("开始订阅特征");
|
||||
this.subScribe(deviceId, true);
|
||||
} else {
|
||||
console.log("不订阅消息");
|
||||
}
|
||||
return Promise.resolve(true);
|
||||
} else {
|
||||
console.log("开始获取服务", targetServiceId)
|
||||
return this.getService(deviceId, targetServiceId, writeCharId,
|
||||
notifyCharId);
|
||||
}
|
||||
|
||||
|
||||
// 设备已在 LinkedList(例如缓存/重连):不能仅用缓存的 write/notify UUID 直接订阅。
|
||||
// 重连后须先 getBLEDeviceServices,否则部分机型 notifyBLECharacteristicValueChange 报 no service(10004),notify 收不到任何数据。
|
||||
console.log("已缓存设备重新连接,重新发现服务并订阅", deviceId);
|
||||
return this.getService(deviceId, targetServiceId, writeCharId,
|
||||
notifyCharId);
|
||||
}
|
||||
} else { //已连接过,直接订阅消息
|
||||
// console.log("11111111");
|
||||
|
||||
@ -693,7 +693,8 @@ class BleReceive {
|
||||
let receiveData = {};
|
||||
try {
|
||||
if (!receive.bytes || receive.bytes.length < 3) return receiveData;
|
||||
const parsed = parseBleData(receive.bytes);
|
||||
// 与 HBY100-J 页 bleValueNotify 共用 notify,避免 parseBleData 执行两次:重复日志、FB05 双次 resolve、onNotify 双次
|
||||
const parsed = parseBleData(receive.bytes, { skipSideEffects: true });
|
||||
if (!parsed) return receiveData;
|
||||
if (parsed.longitude !== undefined) receiveData.longitude = parsed.longitude;
|
||||
if (parsed.latitude !== undefined) receiveData.latitude = parsed.latitude;
|
||||
|
||||
Reference in New Issue
Block a user