|
@@ -199,7 +199,10 @@ class bleManager {
|
|
|
// that.disconnect(result)
|
|
|
//断开连接是失败的。
|
|
|
console.log("监听到设备状态变化0:", result.deviceId, JSON.stringify(result));
|
|
|
- that.errorDisconnect({ "deviceId": result.deviceId, "state": result.connected ? "online" : "offline" });
|
|
|
+ that.errorDisconnect({
|
|
|
+ "deviceId": result.deviceId,
|
|
|
+ "state": result.connected ? "online" : "offline"
|
|
|
+ });
|
|
|
|
|
|
|
|
|
|
|
@@ -295,9 +298,9 @@ class bleManager {
|
|
|
}
|
|
|
|
|
|
testData(temp) {
|
|
|
- if ((temp.deviceId === "1A:B4:E0:40:22:8B"
|
|
|
- || temp.deviceId === "F3:55:1F:8D:26:A0"
|
|
|
- || temp.deviceId === "3F2F112F-ACB5-3EB3-30DA-93DE6A86228A")) {
|
|
|
+ if ((temp.deviceId === "1A:B4:E0:40:22:8B" ||
|
|
|
+ temp.deviceId === "F3:55:1F:8D:26:A0" ||
|
|
|
+ temp.deviceId === "3F2F112F-ACB5-3EB3-30DA-93DE6A86228A")) {
|
|
|
return true
|
|
|
}
|
|
|
return false
|
|
@@ -341,10 +344,10 @@ class bleManager {
|
|
|
const indexRoot = route_constant.indexRoot;
|
|
|
const connectBleRoot = route_constant.connectBleRoot;
|
|
|
var lastPageRoute = route_util.getLastPageRoute();
|
|
|
- // if (lastPageRoute != indexRoot && lastPageRoute != connectBleRoot) {
|
|
|
- // console.log("搜索蓝牙设备失败,请返回首页0");
|
|
|
- // return;
|
|
|
- // }
|
|
|
+ if (lastPageRoute != indexRoot && lastPageRoute != connectBleRoot) {
|
|
|
+ console.log("搜索蓝牙设备失败,请返回首页0");
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
///蓝牙连接 做限制
|
|
|
if (lastPageRoute == indexRoot) {
|
|
@@ -501,11 +504,16 @@ class bleManager {
|
|
|
fail: (err) => {
|
|
|
// {errno: 1509007, errCode: -1, errMsg: "createBLEConnection:fail:already connect"}
|
|
|
if (err.errno == 1509007) {
|
|
|
- that.disconnect({ "deviceId": device.deviceId })
|
|
|
+ that.disconnect({
|
|
|
+ "deviceId": device.deviceId
|
|
|
+ })
|
|
|
} else {
|
|
|
that.isConnecting = false;
|
|
|
console.log("监听到设备状态变化3:", err);
|
|
|
- that.errorDisconnect({ "deviceId": device.deviceId, "state": "offline" })
|
|
|
+ that.errorDisconnect({
|
|
|
+ "deviceId": device.deviceId,
|
|
|
+ "state": "offline"
|
|
|
+ })
|
|
|
let publicDevice = that.publicDevice ?? {}
|
|
|
if (device.deviceId == publicDevice.deviceId) {
|
|
|
that.publicDevice = null;
|
|
@@ -557,7 +565,10 @@ class bleManager {
|
|
|
callback(false)
|
|
|
}
|
|
|
console.log('监听到设备状态变化4:', err);
|
|
|
- that.errorDisconnect({ "deviceId": that.publicDevice.deviceId, "state": "offline" })
|
|
|
+ that.errorDisconnect({
|
|
|
+ "deviceId": that.publicDevice.deviceId,
|
|
|
+ "state": "offline"
|
|
|
+ })
|
|
|
resolve(false);
|
|
|
}
|
|
|
});
|
|
@@ -660,7 +671,7 @@ class bleManager {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- connect() { }
|
|
|
+ connect() {}
|
|
|
|
|
|
// 发现特征值 read / write
|
|
|
discoverCharacteristics(deviceId, serviceId) {
|