Browse Source

feature: 君正方案与乐鑫方案跳转处理

332777428@qq.com 4 months atrás
parent
commit
b4b8ee38d5

+ 5 - 10
pages/deviceConnect2/deviceConnect2.js

@@ -109,12 +109,6 @@ Page({
             var isLexin = name.indexOf(lexin_devices.leXin) !== -1;
             var isJungzheng1 = junzheng_util.isJungzheng1(name);
             var isJungzheng2 = junzheng_util.isJungzheng2(name);
-            if (isJungzheng1 || isJungzheng2) {
-              console.log("gasdfqwerqwerqrwqr===00==" + v.name);
-            } else if (isLexin) {
-              console.log("gasdfqwerqwerqrwqr===11==" + v.name);
-            }
-            // return isLexin;
             return isLexin || isJungzheng1 || isJungzheng2;
             ///2AXD
             // return v.name == "AIrSMArT_d0311004155e";
@@ -154,7 +148,7 @@ Page({
               isOnBluetooth: false,
             });
             var param = JSON.stringify(that.data.connectDevice);
-            wx.navigateTo({
+            wx.redirectTo({
               url: '../deviceConnect3/deviceConnect3?deviceId=' + options.data.deviceId + '&name=' + options.data.name + "&param=" + param,
             });
           }, 200);
@@ -219,9 +213,10 @@ Page({
     var isJungzheng2 = junzheng_util.isJungzheng2(name);
 
     if (isJungzheng1 || isJungzheng2) {
-      var url = "../deviceConnect4/deviceConnect4";
-      var param = "?deviceId=" + deviceId + '&name=' + name;
-      route_util.jumpParams(url, param);
+      var param = JSON.stringify(that.data.connectDevice);
+      wx.redirectTo({
+        url: '../deviceConnect4/deviceConnect4?deviceId=' + deviceId + '&name=' + name + "&param=" + param,
+      });
       return;
     }
 

+ 8 - 7
pages/deviceConnect3/deviceConnect3.js

@@ -128,12 +128,14 @@ Page({
             });
 
             setTimeout(() => {
-              clearTimeout(errTi);
-              clearInterval(percentIn);
-              that.setData({
-                percent: 100,
-                ruterStatus: 1,
-              });
+              if (percentIn != null) {
+                clearTimeout(errTi);
+                clearInterval(percentIn);
+                that.setData({
+                  percent: 100,
+                  ruterStatus: 1,
+                });
+              }
             }, 500);
           }
         }
@@ -141,7 +143,6 @@ Page({
 
         ///设备连接状态回调
       case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED:
-        console.log("gadfqwerqwerqr==4444==" + JSON.stringify(options.result));
         that.setData({
           connected: options.result
         });

+ 42 - 52
pages/deviceConnect4/deviceConnect4.js

@@ -1,8 +1,7 @@
 const app = getApp();
 import strings from '../../utils/strings.js';
-const {
-  BtHelper
-} = require('../../devices/bt_helper');
+import route_util from '../../utils/route_util.js';
+import route_constant from '../../utils/route_constant.js'
 const {
   BleUtil
 } = require('../../utils/blue_ble/util');
@@ -82,57 +81,48 @@ Page({
         });
         clearInterval(percentIn);
       }
-    });
+    }, function (connected) {
+      var deviceId = that.data.name;
+      var device = {
+        connectType: 3,
+        devName: "",
+        state: "online",
+        name: deviceId,
+        deviceId: deviceId,
+        mac: deviceId,
+        imageUrl: that.data.imageUrl,
+        // imageUrl: "./../../img/min.png",
+      }
+      getCurrentPages()[0].addWifiDevice(device);
+      // [{"deviceId":"BLUFI_7cdfa1fcbb24","name":"BLUFI_7cdfa1fcbb24","state":"online"}]
+      // 记住密码
+      wx.setStorage({
+        key: "wifiInfo",
+        data: JSON.stringify({
+          "password": app.globalData.pwdData,
+          "ssid": app.globalData.ssid
+        }),
+      });
 
-    // BtHelper.getInstance().startScan(device,
-    //   async function (b) {
-    //       if (!b) {
-    //         that.setData({
-    //           connected: false
-    //         })
-    //         that.setData({
-    //           ruterStatus: 2
-    //         });
-    //       }
+      setTimeout(() => {
+        if (percentIn != null) {
+          clearInterval(percentIn);
+          that.setData({
+            percent: 100,
+            ruterStatus: 1,
+          });
+        }
+      }, 1000);
+    });
+  },
 
-    //       setTimeout(function () {
-    //         BleUtil.getInstance().startConnect(device, function (changed) {
-    //           if (changed) {
-    //             BleUtil.getInstance().sendData(device, app.globalData.ssid, app.globalData.pwdData);
-    //           }
-    //         });
-    //       }, 10 * 1000);
-    //     },
-    //     async function (res) {
-    //       var deviceId = that.data.name;
-    //       var device = {
-    //         connectType: 3,
-    //         devName: "",
-    //         state: "online",
-    //         name: deviceId,
-    //         deviceId: deviceId,
-    //         mac: deviceId,
-    //         imageUrl: that.data.imageUrl,
-    //         // imageUrl: "./../../img/min.png",
-    //       }
-    //       getCurrentPages()[0].addWifiDevice(device);
-    //       // 记住密码
-    //       wx.setStorage({
-    //         key: "wifiInfo",
-    //         data: JSON.stringify({
-    //           "password": app.globalData.pwdData,
-    //           "ssid": app.globalData.ssid
-    //         }),
-    //       });
+  egen() {
+    wx.navigateBack({
+      delta: 1
+    })
+  },
 
-    //       setTimeout(() => {
-    //         clearInterval(percentIn);
-    //         that.setData({
-    //           percent: 100,
-    //           ruterStatus: 1,
-    //         });
-    //       }, 500);
-    //     }
-    // );
+  goIndex() {
+    route_util.goBackRoute(route_constant.indexRoot);
   },
 })

+ 7 - 7
utils/blue_ble/manager.js

@@ -497,20 +497,20 @@ class Manager {
   }
 
   ///收取到的数据转换为文字
-  onBLECharacteristicValueChange(callback) {
+  onBLECharacteristicValueChange(device, callback) {
     wx.onBLECharacteristicValueChange(function (characteristic) {
       //characteristic: {"value":{},"deviceId":"22:10:14:95:F0:1E","serviceId":"0000FFE5-0000-1000-8000-00805F9B34FB","characteristicId":"0000FFE5-0001-1000-8000-00805F9B34FB"}
-      // const hex_util = require('../hex_util');
-      // var receiveText = hex_util.buf2string(characteristic);
-      let buffer = characteristic.value
-      let dataView = new DataView(buffer)
-      let dataResult = []
+      const hex_util = require('../hex_util');
+      var buffer = characteristic.value
+      var dataView = new DataView(buffer)
+      var dataResult = []
       for (let i = 0; i < dataView.byteLength; i++) {
         dataResult.push(dataView.getUint8(i))
       }
+      var value = hex_util.buf2string(dataResult);
       ///109,113,116,116
       ///114,101,99,118,95,102,105,110,105,115,104
-      callback(dataResult);
+      callback(value);
     });
   }
 

+ 9 - 6
utils/blue_ble/util.js

@@ -59,7 +59,7 @@ class BleUtil {
   }
 
   ///开始连接设备
-  async startConnect(device, onChanged) {
+  async startConnect(device, onChanged, connected) {
     var that = this;
     await that.stopScan();
     await that.disconnect(device);
@@ -101,14 +101,17 @@ class BleUtil {
           return;
         }
 
+        onChanged(true);
         ///数据接收
-        that.manager.onBLECharacteristicValueChange(function (value) {
-          BtParse.parseTLV(value);
+        that.manager.onBLECharacteristicValueChange(device, function (value) {
+          // BtParse.parseTLV(value);
+          if (value == "mqtt") {
+
+          } else if (value == "recv_finish") {
+            connected(true);
+          }
         });
 
-        setTimeout(() => {
-          onChanged(true);
-        }, 300);
       });
   }
 

+ 2 - 1
utils/lexin/devices.js

@@ -15,8 +15,9 @@ const clientTypes = ["MW-2AX(WIFI)", "MW-2AX(WIFI-N)", "MW-2AX(A)",
   "MW-SR1(4G_WIFI_MEIZU01)",
   "MW-Mate X(4G_WIFI)",
   "MW-X4 (BZK)",
-  ///君正
+  ///君正 
   "MW-2AXD",
+  "MW-2XD(COZE)",
 ];
 
 module.exports = {

+ 3 - 0
utils/lexin/message.js

@@ -67,9 +67,12 @@ function getDeviceInfo(payloads) {
           ///猫王妙播音响·X4 (BZK)
           ///设置图片
           var classifyProducts = app.globalData.classifyProducts;
+          console.log("sdfasdfa==00==" + classifyProducts.length);
           if (!strings.isEmpty(classifyProducts)) {
             for (var i = 0; i < classifyProducts.length; i++) {
               var productItem = classifyProducts[i];
+              console.log("sdfasdfa==111==" + productItem.clientType);
+              console.log("sdfasdfa==222==" + ProdModel);
               if (productItem.clientType == ProdModel) {
                 device.devName = productItem.name;
                 device.imageUrl = productItem.img;

+ 14 - 0
utils/route_util.js

@@ -7,6 +7,7 @@ module.exports = {
   jumpParams: jumpParams,
   goBack: goBack,
   redirectTo: redirectTo,
+  redirectToParam: redirectToParam,
 }
 
 ///获取最后一个界面的路由名称
@@ -45,6 +46,7 @@ async function jumpParams(url, param) {
   }
 };
 
+
 //跳转,并且摧毁当前界面
 async function redirectTo(url) {
   await wx.redirectTo({
@@ -52,6 +54,18 @@ async function redirectTo(url) {
   });
 };
 
+//跳转,并且摧毁当前界面
+async function redirectToParam(url, param) {
+  if (param) {
+    await wx.redirectTo({
+      url: url + param,
+    });
+  } else {
+    await redirectTo(url);
+  }
+};
+
+
 //返回页面个数
 async function goBack(pages) {
   if (pages == null) pages == 1;