Explorar el Código

feature: 过滤数据

Damon hace 7 meses
padre
commit
2ed3f3f583
Se han modificado 1 ficheros con 41 adiciones y 33 borrados
  1. 41 33
      devices/ble_manager.js

+ 41 - 33
devices/ble_manager.js

@@ -181,50 +181,58 @@ class bleManager {
   // 开始搜索蓝牙设备
   async startScan(connectWillDevice, boolean, callBackConnect) {
     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;
     }
+    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) {
     //   await that.delay(waitMills);
     // }
 
-    if (callBackConnect == null && lastPageRoute == connectBleRoot) {
-      that.doStartScaning = false;
-      return;
-    }
+    // if (callBackConnect == null && lastPageRoute == connectBleRoot) {
+    //   that.doStartScaning = false;
+    //   return;
+    // }
 
     wx.stopBluetoothDevicesDiscovery({
       success: (res) => {