Procházet zdrojové kódy

feature: 连接wifi先断开蓝牙,连接蓝牙,先断开wifi

Damon před 7 měsíci
rodič
revize
d05268d1fb

+ 3 - 1
pages/connectBle/connectBle.js

@@ -53,8 +53,10 @@ Page({
     );
   },
 
-  connectToDvice() {
+  async connectToDvice() {
     var that = this;
+    ///断开蓝牙连接
+    await BtHelper.getInstance().disconnect();
     BtHelper.getInstance().connect(that.data.connectDevice, function (data) {
       console.log("连接成功:", data)
       that.setStatus(data ? 3 : 4)

+ 8 - 55
pages/deviceConnect3/deviceConnect3.js

@@ -108,62 +108,15 @@ Page({
           if (options.data.progress == 100) {
             clearTimeout(errTi);
             clearInterval(percentIn);
-            // 更新数据
-            wx.getStorage({
-              key: 'devicelist',
-              success(res) {
-                if (res.data) {
-                  let arr = JSON.parse(res.data);
-                  // 同一个设备
-                  const devicelist = arr.filter((v) => v.deviceId === _this.data.name);
-                  if (devicelist.length > 0) {
-                    arr = arr.filter((v) => v.deviceId !== _this.data.name);
-                  };
 
-                  // [{"deviceId":"BLUFI_7cdfa1fcbb24","name":"BLUFI_7cdfa1fcbb24","state":"online"}]
-                  arr.unshift({
-                    /// Wifi mqtt-连接
-                    connectType: 3,
-                    deviceId: _this.data.name,
-                    name: _this.data.name,
-                    state: "online",
-                    image: "./../../img/min.png",
-                  });
-
-                  getCurrentPages()[0].addConnectWifiDevice(arr);
-                  _this.setData({
-                    percent: 100,
-                    ruterStatus: 1
-                  });
-                  // wx.setStorage({
-                  //   key: "devicelist",
-                  //   data: JSON.stringify(arr),
-                  //   success() {
-                  //     _this.setData({
-                  //       percent: 100,
-                  //       ruterStatus: 1
-                  //     });
-                  //   }
-                  // })
-                }
-              },
-              fail() {
-                wx.setStorage({
-                  key: "devicelist",
-                  data: JSON.stringify([{
-                    name: _this.data.name,
-                    deviceId: _this.data.name,
-                    state: "online"
-                  }]),
-                  success() {
-                    _this.setData({
-                      percent: 100,
-                      ruterStatus: 1
-                    });
-                  }
-                })
-              }
-            })
+            // [{"deviceId":"BLUFI_7cdfa1fcbb24","name":"BLUFI_7cdfa1fcbb24","state":"online"}]
+            getCurrentPages()[0].addConnectWifiDevice({
+              deviceId: _this.data.name,
+            });
+            _this.setData({
+              percent: 100,
+              ruterStatus: 1
+            });
             // 记住密码
             wx.setStorage({
               key: "wifiInfo",

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 105 - 75
pages/index/index.js