Przeglądaj źródła

feature: 添加测试数据部份数据

332777428@qq.com 5 miesięcy temu
rodzic
commit
c71effecd4

+ 3 - 0
pages/deviceConnect2/deviceConnect2.js

@@ -180,6 +180,9 @@ Page({
     var that = this;
     const devicesList = that.data.devicesList;
     if (devicesList.length < 1) {
+      var url = "../deviceConnect4/deviceConnect4";
+      var param = "?deviceId=" + deviceId;
+      route_util.jumpParams(url, param);
       wx.showToast({
         title: '请短按设备配对键',
         icon: 'none',

+ 39 - 10
pages/deviceConnect4/deviceConnect4.js

@@ -39,6 +39,7 @@ Page({
     }
 
     // AIrSMArT_861210052356337===D0:31:10:86:AC:9A
+    /// 纯蓝牙:MW_BLE CC:90:DD:88:C7:E8
     var name = options.name;
     var deviceId = options.deviceId;
     that.setData({
@@ -46,22 +47,50 @@ Page({
       connectedDeviceId: deviceId,
     });
 
+    // var device = {
+    //   "mac": name,
+    //   "deviceId": deviceId
+    // };
+
     var device = {
-      "mac": name,
-      "deviceId": deviceId
+      "mac": "MW_BLE",
+      "deviceId": "CC:90:DD:88:C7:E8"
     };
 
     console.log("gadsfasdfadfaf===00==");
 
-    BtHelper.getInstance().connect(device, function (isConnected, device) {
-      if (isConnected) {
+    // BtHelper.getInstance().connect(device, function (isConnected, device) {
+    //   if (isConnected) {
 
-      }
-    }, true, device);
-    // BleUtil.getInstance().startConnect(device, function (changed) {
-    //   if (changed) {
-    //     BleUtil.getInstance().sendData(device, app.globalData.ssid, app.globalData.pwdData);
     //   }
-    // });
+    // }, true, device);
+
+    BtHelper.getInstance().startScan(device,
+      async function (b) {
+          console.log("gadsfasdfadfaf===xxx==" + b);
+          if (b) {
+            setTimeout(function () {
+              console.log("gadsfasdfadfaf===yyy==");
+
+              BleUtil.getInstance().startConnect(device, function (changed) {
+                if (changed) {
+                  BleUtil.getInstance().sendData(device, app.globalData.ssid, app.globalData.pwdData);
+                }
+              });
+            }, 10 * 1000);
+          }
+
+        },
+        async function (res) {
+          console.log("gadsfasdfadfaf===yyy==");
+          await BtHelper.getInstance().stopSearch();
+          BleUtil.getInstance().startConnect(device, function (changed) {
+            if (changed) {
+              BleUtil.getInstance().sendData(device, app.globalData.ssid, app.globalData.pwdData);
+            }
+          });
+        }
+    );
+
   },
 })

+ 1 - 1
pages/index/index.js

@@ -973,7 +973,7 @@ Page({
   },
 
   ///点击banner事件
-  onTapBanner() {
+  onTapBanner(e) {
     var that = this;
     var item = e.currentTarget.dataset.item;
   },

+ 1 - 0
utils/blue_ble/manager.js

@@ -428,6 +428,7 @@ class Manager {
     var that = this;
     const time_util = require('./../../utils/time_util');
     var characteristics = res.characteristics;
+    console.log("gadsfasdfadfaf===啊啊啊啊==" + JSON.stringify(characteristics));
     if (characteristics.length <= 0) {
       failed();
       return;

+ 2 - 2
utils/blue_ble/util.js

@@ -1,6 +1,7 @@
 const Manager = require('./manager');
 const BtParse = require('../../devices/bluetooth/bt_parse');
 
+/// MW-X4 (BZK)
 class BleUtil {
   static _instance = new BleUtil();
 
@@ -80,7 +81,7 @@ class BleUtil {
       return;
     }
 
-    var serviceId = "";
+    var serviceId = serviceId = services[0].uuid;
     for (let i = 0; i < services.length; i++) {
       if (services[i].uuid.toUpperCase().indexOf("FFE5") != -1 ||
         services[i].uuid.toUpperCase().indexOf("1111") != -1
@@ -88,7 +89,6 @@ class BleUtil {
         serviceId = services[i].uuid;
         break;
       }
-      serviceId = services[i].uuid;
     }
 
     that.manager.setWriteServiceId(serviceId);