Преглед изворни кода

feature: 停止搜索处理

Damon пре 7 месеци
родитељ
комит
54a0193f09
2 измењених фајлова са 19 додато и 5 уклоњено
  1. 19 4
      devices/ble_manager.js
  2. 0 1
      pages/connectBle/connectBle.js

+ 19 - 4
devices/ble_manager.js

@@ -57,7 +57,9 @@ class bleManager {
         if (that.callBackConnect != null) {
           if (that.connectWillDevice != null && res.name == that.connectWillDevice.clientType) {
             res.advertisData = res.advertisData ? that.buf2hex(res.advertisData) : '';
-            that.callBackConnect(res);
+            if (that.callBackConnect != null) {
+              that.callBackConnect(res);
+            }
           }
         } else {
           if (res.name != "") {
@@ -83,9 +85,14 @@ class bleManager {
         if (that.callBackConnect != null) {
           for (var i = 0; i < res.devices.length; i++) {
             var temp = res.devices[i];
+            if (devices.devices[i].name == "MW-SR1(4G_WIFI)") {
+              console.log("gadsfqwerqeddsafdafwqr==111==" + JSON.stringify(devices.devices[i]));
+            }
             if (that.connectWillDevice != null && temp.name == that.connectWillDevice.clientType) {
               temp.advertisData = temp.advertisData ? that.buf2hex(temp.advertisData) : '';
-              that.callBackConnect(temp);
+              if (that.callBackConnect != null) {
+                that.callBackConnect(temp);
+              }
               break;
             }
           }
@@ -115,7 +122,9 @@ class bleManager {
         if (that.callBackConnect != null) {
           if (that.connectWillDevice != null && res[0].name == that.connectWillDevice.clientType) {
             res[0].advertisData = res[0].advertisData ? that.buf2hex(res[0].advertisData) : '';
-            that.callBackConnect(res[0]);
+            if (that.callBackConnect != null) {
+              that.callBackConnect(res[0]);
+            }
           }
         } else {
           if (res[0].name != "") {
@@ -141,14 +150,20 @@ class bleManager {
 
   ///获取已连接的设备
   getConnectedDevices() {
+    var that = this;
     wx.getBluetoothDevices({
       success: (res) => {
         if (res.devices && res.devices.length > 0) {
           for (var i = 0; i < res.devices.length; i++) {
             var temp = res.devices[i];
+            if (res.devices[i].name == "MW-SR1(4G_WIFI)") {
+              console.log("gadsfqwerqeddsafdafwqr==000==" + JSON.stringify(res.devices[i]));
+            }
             if (that.connectWillDevice != null && temp.name == that.connectWillDevice.clientType) {
               temp.advertisData = temp.advertisData ? that.buf2hex(temp.advertisData) : '';
-              that.callBackConnect(temp);
+              if (that.callBackConnect != null) {
+                that.callBackConnect(temp);
+              }
               break;
             }
           }

+ 0 - 1
pages/connectBle/connectBle.js

@@ -37,7 +37,6 @@ Page({
   async startSearch() {
     var that = this;
     that.setStatus(0);
-    await BtHelper.getInstance().stopSearch();
     BtHelper.getInstance().startScan(
       that.data.connectDevice,
       async function (b) {