Browse Source

fix:修改蓝牙第一次弹框掉线的问题

zeng.chen 5 tháng trước cách đây
mục cha
commit
267b72317d
2 tập tin đã thay đổi với 5 bổ sung4 xóa
  1. 4 3
      devices/ble_manager.js
  2. 1 1
      devices/bt_helper.js

+ 4 - 3
devices/ble_manager.js

@@ -110,7 +110,7 @@ class bleManager {
               // }
               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);
@@ -504,6 +504,7 @@ class bleManager {
             that.disconnect({ "deviceId": device.deviceId })
           } else {
             that.isConnecting = false;
+            console.log("监听到设备状态变化3:", err);
             that.errorDisconnect({ "deviceId": device.deviceId, "state": "offline" })
             let publicDevice = that.publicDevice ?? {}
             if (device.deviceId == publicDevice.deviceId) {
@@ -555,7 +556,7 @@ class bleManager {
           if (callback) {
             callback(false)
           }
-          console.log('数据发送失败:', err);
+          console.log('监听到设备状态变化4:', err);
           that.errorDisconnect({ "deviceId": that.publicDevice.deviceId, "state": "offline" })
           resolve(false);
         }
@@ -762,7 +763,7 @@ class bleManager {
   }
   errorDisconnect(result) {
     // 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) {
       this.stateChangeCallback(result);
     }

+ 1 - 1
devices/bt_helper.js

@@ -93,7 +93,7 @@ class BtHelper {
     that.bleManager.initBluetoothAdapter();
     that.bleManager.onBLEConnectionStateChange();
     that.bleManager.setStateChangeCallback(function (e) {
-      event_bus.fire(CmdEvent.onoffline({ deviceId: e.deviceId, state: e.connected ? "online" : "offline" }));
+      event_bus.fire(CmdEvent.onoffline({ deviceId: e.deviceId, state: e.state == "online" ? "online" : "offline" }));
     });
   }