|
@@ -110,7 +110,7 @@ class bleManager {
|
|
// }
|
|
// }
|
|
console.log("2222:", temp.mac, ":", temp.mac2, ":", temp.deviceId, temp, temp.connectable);
|
|
console.log("2222:", temp.mac, ":", temp.mac2, ":", temp.deviceId, temp, temp.connectable);
|
|
|
|
|
|
- // if ((temp.deviceId === "07:F6:F4:66:FB:FA")) {
|
|
|
|
|
|
+ // if ((temp.deviceId.indexOf("1f:de") ) > -1) {
|
|
// that.callBackConnect(temp);
|
|
// that.callBackConnect(temp);
|
|
// }
|
|
// }
|
|
that.callBackConnect(temp);
|
|
that.callBackConnect(temp);
|
|
@@ -316,6 +316,14 @@ class bleManager {
|
|
|
|
|
|
///做搜索蓝牙适配器权限
|
|
///做搜索蓝牙适配器权限
|
|
const permission_util = require('../utils/permission_util');
|
|
const permission_util = require('../utils/permission_util');
|
|
|
|
+ // var location = await permission_util.getSetting()
|
|
|
|
+ // if (!location) {
|
|
|
|
+ // if (boolean != null) {
|
|
|
|
+ // boolean(false);
|
|
|
|
+ // console.log("没有定位权限")
|
|
|
|
+ // }
|
|
|
|
+ // return
|
|
|
|
+ // }
|
|
var available = await permission_util.openBluetoothAdapter();
|
|
var available = await permission_util.openBluetoothAdapter();
|
|
that.isAvailable = available;
|
|
that.isAvailable = available;
|
|
if (!available) {
|
|
if (!available) {
|
|
@@ -397,9 +405,14 @@ class bleManager {
|
|
that.compareList = [];
|
|
that.compareList = [];
|
|
},
|
|
},
|
|
fail(err) {
|
|
fail(err) {
|
|
- console.log("开始搜索设备失败", res);
|
|
|
|
|
|
+ console.log("开始搜索设备失败", err);
|
|
that.doStartScaning = false;
|
|
that.doStartScaning = false;
|
|
that.requestBlueTime = time_util.getCurrentMills();
|
|
that.requestBlueTime = time_util.getCurrentMills();
|
|
|
|
+ if (err.errMsg.indexOf("location") >= 0) {
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: '搜索失败,请检查下手机设置的微信定位权限是否开启',
|
|
|
|
+ })
|
|
|
|
+ }
|
|
if (boolean != null) {
|
|
if (boolean != null) {
|
|
boolean(false);
|
|
boolean(false);
|
|
}
|
|
}
|
|
@@ -491,6 +504,7 @@ class bleManager {
|
|
that.disconnect({ "deviceId": device.deviceId })
|
|
that.disconnect({ "deviceId": device.deviceId })
|
|
} else {
|
|
} else {
|
|
that.isConnecting = false;
|
|
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 ?? {}
|
|
let publicDevice = that.publicDevice ?? {}
|
|
if (device.deviceId == publicDevice.deviceId) {
|
|
if (device.deviceId == publicDevice.deviceId) {
|
|
@@ -542,7 +556,7 @@ class bleManager {
|
|
if (callback) {
|
|
if (callback) {
|
|
callback(false)
|
|
callback(false)
|
|
}
|
|
}
|
|
- console.log('数据发送失败:', err);
|
|
|
|
|
|
+ console.log('监听到设备状态变化4:', err);
|
|
that.errorDisconnect({ "deviceId": that.publicDevice.deviceId, "state": "offline" })
|
|
that.errorDisconnect({ "deviceId": that.publicDevice.deviceId, "state": "offline" })
|
|
resolve(false);
|
|
resolve(false);
|
|
}
|
|
}
|
|
@@ -749,7 +763,7 @@ class bleManager {
|
|
}
|
|
}
|
|
errorDisconnect(result) {
|
|
errorDisconnect(result) {
|
|
// this.disconnect();
|
|
// this.disconnect();
|
|
- console.log("监听到设备状态变化1:", result.deviceId, result.connected, this.stateChangeCallback);
|
|
|
|
|
|
+ console.log("监听到设备状态变化1:", result.deviceId, result.state, this.stateChangeCallback);
|
|
if (this.stateChangeCallback && result.deviceId) {
|
|
if (this.stateChangeCallback && result.deviceId) {
|
|
this.stateChangeCallback(result);
|
|
this.stateChangeCallback(result);
|
|
}
|
|
}
|