|
@@ -181,50 +181,58 @@ class bleManager {
|
|
// 开始搜索蓝牙设备
|
|
// 开始搜索蓝牙设备
|
|
async startScan(connectWillDevice, boolean, callBackConnect) {
|
|
async startScan(connectWillDevice, boolean, callBackConnect) {
|
|
var that = this;
|
|
var that = this;
|
|
- const route_util = require('../utils/route_util');
|
|
|
|
- const route_constant = require('../utils/route_constant');
|
|
|
|
- const indexRoot = route_constant.indexRoot;
|
|
|
|
- const connectBleRoot = route_constant.connectBleRoot;
|
|
|
|
- var lastPageRoute = route_util.getLastPageRoute();
|
|
|
|
- if (lastPageRoute != indexRoot && lastPageRoute != connectBleRoot) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!that.isAvailable) {
|
|
|
|
- if (lastPageRoute == connectBleRoot) {
|
|
|
|
- wx.showToast({
|
|
|
|
- title: '蓝牙未打开',
|
|
|
|
- icon: "none",
|
|
|
|
- duration: 2000
|
|
|
|
- })
|
|
|
|
|
|
+ if (that.doStartScaning == true) {
|
|
|
|
+ if (boolean != null) {
|
|
|
|
+ boolean(false);
|
|
}
|
|
}
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ that.doStartScaning = true;
|
|
|
|
+
|
|
|
|
+ // const route_util = require('../utils/route_util');
|
|
|
|
+ // const route_constant = require('../utils/route_constant');
|
|
|
|
+ // const indexRoot = route_constant.indexRoot;
|
|
|
|
+ // const connectBleRoot = route_constant.connectBleRoot;
|
|
|
|
+ // var lastPageRoute = route_util.getLastPageRoute();
|
|
|
|
+ // if (lastPageRoute != indexRoot && lastPageRoute != connectBleRoot) {
|
|
|
|
+ // return;
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ // if (!that.isAvailable) {
|
|
|
|
+ // if (lastPageRoute == connectBleRoot) {
|
|
|
|
+ // wx.showToast({
|
|
|
|
+ // title: '蓝牙未打开',
|
|
|
|
+ // icon: "none",
|
|
|
|
+ // duration: 2000
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+ // return;
|
|
|
|
+ // }
|
|
|
|
|
|
///蓝牙连接 做限制
|
|
///蓝牙连接 做限制
|
|
- if (lastPageRoute == indexRoot) {
|
|
|
|
- if (that.doStartScaning == true) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ // if (lastPageRoute == indexRoot) {
|
|
|
|
+ // if (that.doStartScaning == true) {
|
|
|
|
+ // return;
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
|
|
- that.doStartScaning = true;
|
|
|
|
- var currentMill = that.getCurrentMills();
|
|
|
|
- var waitMills = 0;
|
|
|
|
- var reduce = currentMill - that.requestBlueTime;
|
|
|
|
- const delayMiliis = 5 * 1000;
|
|
|
|
- if (reduce > 0 && reduce < delayMiliis) {
|
|
|
|
- waitMills = delayMiliis - reduce;
|
|
|
|
- }
|
|
|
|
|
|
+ // that.doStartScaning = true;
|
|
|
|
+ // var currentMill = that.getCurrentMills();
|
|
|
|
+ // var waitMills = 0;
|
|
|
|
+ // var reduce = currentMill - that.requestBlueTime;
|
|
|
|
+ // const delayMiliis = 5 * 1000;
|
|
|
|
+ // if (reduce > 0 && reduce < delayMiliis) {
|
|
|
|
+ // waitMills = delayMiliis - reduce;
|
|
|
|
+ // }
|
|
|
|
|
|
// if (waitMills > 0) {
|
|
// if (waitMills > 0) {
|
|
// await that.delay(waitMills);
|
|
// await that.delay(waitMills);
|
|
// }
|
|
// }
|
|
|
|
|
|
- if (callBackConnect == null && lastPageRoute == connectBleRoot) {
|
|
|
|
- that.doStartScaning = false;
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
+ // if (callBackConnect == null && lastPageRoute == connectBleRoot) {
|
|
|
|
+ // that.doStartScaning = false;
|
|
|
|
+ // return;
|
|
|
|
+ // }
|
|
|
|
|
|
wx.stopBluetoothDevicesDiscovery({
|
|
wx.stopBluetoothDevicesDiscovery({
|
|
success: (res) => {
|
|
success: (res) => {
|