Sfoglia il codice sorgente

feature: 处理乐鑫连接,订阅问题收集

Damon 7 mesi fa
parent
commit
2842da53a5
6 ha cambiato i file con 168 aggiunte e 156 eliminazioni
  1. 1 0
      .gitignore
  2. 1 1
      pages/connectBle/connectBle.js
  3. 51 155
      pages/index/index.js
  4. 29 0
      utils/lexin/service.js
  5. 9 0
      utils/lexin/connect.js
  6. 77 0
      utils/lexin/scan.js

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+/.idea/

+ 1 - 1
pages/connectBle/connectBle.js

@@ -75,7 +75,7 @@ Page({
       if (data) {
         that.data.connectDevice.connectType = 1;
         that.data.connectDevice.state = 'online';
-        getCurrentPages()[0].addConnectBlueDevice(that.data.connectDevice);
+        getCurrentPages()[0].addBlueDevice(that.data.connectDevice);
         route_util.goBackRoute(route_constant.indexRoot);
       }
     });

File diff suppressed because it is too large
+ 51 - 155
pages/index/index.js


File diff suppressed because it is too large
+ 29 - 0
utils/lexin/service.js


+ 9 - 0
utils/lexin/connect.js

@@ -0,0 +1,9 @@
+module.exports = {
+  toAboutUs: toAboutUs,
+}
+
+function toAboutUs() {
+  const route_util = require('../route_util');
+  const route_constant = require('../route_constant');
+  route_util.jump(route_constant.about);
+};

+ 77 - 0
utils/lexin/scan.js

@@ -0,0 +1,77 @@
+module.exports = {
+  compareList: compareList,
+}
+
+function compareList(deviceList, changeCallback, addBlueCallback, autoConnected, deviceListSelect) {
+  if (deviceList.length > 0) {
+    const {
+      BtHelper
+    } = require('../../devices/bt_helper.js');
+    if (BtHelper.getInstance().getCallBackConnect() == null) {
+      var compareList = BtHelper.getInstance().getCompareList();
+      var dissmissDevice = BtHelper.getInstance().getDissmissDevice();
+
+      ///去掉未连接的离线的
+      for (var i = 0; i < dissmissDevice.length; i++) {
+        for (var j = 0; j < compareList.length; j++) {
+          if (compareList[j].deviceId == dissmissDevice[i].deviceId) {
+            compareList.splice(j, 1);
+            break;
+          }
+        }
+      }
+
+      if (compareList.length > 0) {
+        ///对比在线的蓝牙设备
+        var isChanged = false;
+        for (var i = 0; i < deviceList.length; i++) {
+          var tempItem = deviceList[i];
+          if (tempItem.connectType != 3) {
+            var has = false;
+            for (var j = 0; j < compareList.length; j++) {
+              // "state":"online" "offline" MW-SR1(4G_WIFI)
+              if (tempItem.deviceId === compareList[j].deviceId) {
+                has = true;
+                break;
+              }
+            }
+
+            if (has) {
+              if (tempItem.state != "online") {
+                isChanged = true;
+                tempItem.state = "online";
+              }
+            } else {
+              if (tempItem.state != "offline") {
+                isChanged = true;
+                tempItem.state = "offline";
+              }
+            }
+          }
+        }
+
+        if (isChanged) {
+          changeCallback(deviceList);
+        }
+
+        ///没有连接则连接第一个在线的蓝牙
+        if (!autoConnected && deviceListSelect == null) {
+          var list = getCurrentPages()[0].getDeviceList();
+          for (var i = 0; i < list.length; i++) {
+            var item = list[i];
+            if (item.connectType == 1 && item.state == "online") {
+              item.name = item.devName;
+              BtHelper.getInstance().connect(item, function (data) {
+                if (data) {
+                  addBlueCallback(item);
+                }
+              });
+              break;
+            }
+          }
+        }
+      }
+      BtHelper.getInstance().startScan(null, null, null);
+    }
+  }
+};