Browse Source

feature: 解决设备君正连接报错问题

332777428@qq.com 5 tháng trước cách đây
mục cha
commit
65849a3fea

+ 15 - 9
pages/deviceConnect3/deviceConnect3.wxss

@@ -1,36 +1,42 @@
-/* pages/deviceRoter3/deviceRoter3.wxss */
-.lodRuter{
+.lodRuter {
   margin-top: 54rpx;
 }
-.lodRuter text{
+
+.lodRuter text {
   text-align: center;
   width: 100%;
   display: block;
   margin-bottom: 34rpx;
 }
-.suRuter{
+
+.suRuter {
   margin-top: 54rpx;
   display: flex;
   justify-content: center;
 }
-.suRuter image{
+
+.suRuter image {
   width: 48rpx;
 }
-.suRuter text{
+
+.suRuter text {
   color: #353535;
   font-size: 36rpx;
   margin-left: 20rpx;
 }
-.errorPs{
+
+.errorPs {
   margin-top: 150rpx;
 }
-.errorPs >text{
+
+.errorPs>text {
   color: #353535;
   font-size: 28rpx;
   font-weight: bold;
   line-height: 40rpx;
 }
-.errorPs >view{
+
+.errorPs>view {
   color: #353535;
   font-size: 28rpx;
   line-height: 40rpx;

+ 1 - 0
pages/deviceConnect4/deviceConnect4.js

@@ -49,6 +49,7 @@ Page({
     console.log("gadsfasdfadfaf===000==" + JSON.stringify(device));
     BleUtil.getInstance().startConnect(device, function (changed) {
       console.log("gadsfasdfadfaf===111==" + changed);
+      BleUtil.getInstance().sendData(device, "哈哈哈哈哈哈");
     });
 
   },

+ 34 - 2
pages/deviceConnect4/deviceConnect4.wxml

@@ -1,2 +1,34 @@
-<!--pages/deviceConnect4/deviceConnect4.wxml-->
-<text>pages/deviceConnect4/deviceConnect4.wxml</text>
+<view class="deviceRoter deviceRoter3">
+  <nav-bar bind:goBack="_goBack" nav-bgc-class="ex-nav-bgc-class" nav-title-class="ex-nav-title-class" ex-back-pre="ex-back-pre" navbar-data='{{nvabarData}}'></nav-bar>
+  <view class="roterps">
+    <view class="devicePic">
+      <image mode="widthFix" src="{{imageUrl}}"></image>
+    </view>
+    <view class="lodRuter" wx:if="{{ruterStatus === 0}}">
+      <text>正在连接中,请保持设备开机状态…</text>
+      <progress color="#6547A3" percent="{{percent}}" show-info stroke-width="3" />
+    </view>
+    <view class="suRuter" wx:elif="{{ruterStatus === 1}}">
+      <image style="height:48rpx; width:48rpx;" mode="aspectFit" src="./../../img/h.png"></image>
+      <text>连接成功</text>
+    </view>
+    <view class="suRuter" wx:elif="{{ruterStatus === 2}}">
+      <image style="height:48rpx; width:48rpx;" mode="aspectFit" src="./../../img/i.png"></image>
+      <text>连接失败</text>
+    </view>
+    <view class="errorPs" wx:if="{{ruterStatus === 2}}">
+      <text>请尝试:</text>
+      <view>· 部分设备配网需开启GPS定位。</view>
+      <view>· 尝试重启手机蓝牙,如蓝牙已连接其他设备,请先断开。</view>
+      <view>
+        · 连接设备WiFi可能为5GHz WiFi,设备无法连接,请切换至
+        <text style="color: #6547A3">2.4GHz WiFi</text>
+      </view>
+    </view>
+  </view>
+  <view class="subBtn">
+    <view wx:if="{{ruterStatus === 0}}" class="btn" style="opacity: 0.6">连接中...</view>
+    <view wx:elif="{{ruterStatus === 1}}" class="btn" bindtap="goIndex">完成</view>
+    <view wx:else style="background-color: #353535;" class="btn" bindtap="egen">重新连接</view>
+  </view>
+</view>

+ 15 - 9
pages/deviceConnect4/deviceConnect4.wxss

@@ -1,36 +1,42 @@
-/* pages/deviceRoter3/deviceRoter3.wxss */
-.lodRuter{
+.lodRuter {
   margin-top: 54rpx;
 }
-.lodRuter text{
+
+.lodRuter text {
   text-align: center;
   width: 100%;
   display: block;
   margin-bottom: 34rpx;
 }
-.suRuter{
+
+.suRuter {
   margin-top: 54rpx;
   display: flex;
   justify-content: center;
 }
-.suRuter image{
+
+.suRuter image {
   width: 48rpx;
 }
-.suRuter text{
+
+.suRuter text {
   color: #353535;
   font-size: 36rpx;
   margin-left: 20rpx;
 }
-.errorPs{
+
+.errorPs {
   margin-top: 150rpx;
 }
-.errorPs >text{
+
+.errorPs>text {
   color: #353535;
   font-size: 28rpx;
   font-weight: bold;
   line-height: 40rpx;
 }
-.errorPs >view{
+
+.errorPs>view {
   color: #353535;
   font-size: 28rpx;
   line-height: 40rpx;

+ 2 - 2
pages/index/index.js

@@ -981,8 +981,8 @@ Page({
   ///添加设备
   jumpToAddDevice() {
     var that = this;
-    route_util.jump("../deviceConnect4/deviceConnect4");
-    return;
+    // route_util.jump("../deviceConnect4/deviceConnect4");
+    // return;
     var isLogin = that.getIsLogin();
     if (!isLogin) {
       route_util.jump(route_constant.login);

+ 2 - 0
utils/blue_ble/manager.js

@@ -328,9 +328,11 @@ class Manager {
       wx.getBLEDeviceServices({
         deviceId: deviceId,
         success: function (res) {
+          console.log("gadsfasdfadfaf===xxxx==" + JSON.stringify(res));
           resolve(res.services);
         },
         fail: function (res) {
+          console.log("gadsfasdfadfaf===yyy==" + JSON.stringify(res));
           resolve(null);
         }
       });

+ 12 - 5
utils/blue_ble/util.js

@@ -1,18 +1,15 @@
 const Manager = require('./manager');
 
-module.exports = {
-  BleUtil
-}
-
 class BleUtil {
   static _instance = new BleUtil();
+
   static getInstance() {
     return BleUtil._instance;
   }
 
   constructor() {
     var that = this;
-    that.Manager = new Manager();
+    that.manager = new Manager();
   }
 
   ///获取比较的数据
@@ -67,6 +64,7 @@ class BleUtil {
 
     var res = await that.manager.startConnect(device);
     if (!res) {
+      console.log("gadsfasdfadfaf===aaaa==");
       onChanged(false, device);
       return;
     }
@@ -74,6 +72,7 @@ class BleUtil {
     const strings = require('./../../utils/strings');
     var services = await that.manager.getNotifyServices(device);
     if (strings.isEmpty(services)) {
+      console.log("gadsfasdfadfaf===bbb==");
       onChanged(false);
       return;
     }
@@ -82,6 +81,7 @@ class BleUtil {
       async function (notifyServiceId, notifyCharaterId) {
           var isTrue = that.manager.monitorCharacteristicValueChange(device, notifyServiceId, notifyCharaterId);
           if (!isTrue) {
+            console.log("gadsfasdfadfaf===ccc==");
             onChanged(false);
             return;
           }
@@ -116,6 +116,7 @@ class BleUtil {
           });
         },
         function () {
+          console.log("gadsfasdfadfaf===ddd==");
           onChanged(false);
           return;
         });
@@ -123,7 +124,10 @@ class BleUtil {
 
   ///发送数据
   async sendData(device, text) {
+    var that = this;
+    console.log("gadsfasdfadfaf===222==" + text);
     var isTrue = await that.manager.sendData(device, text);
+    console.log("gadsfasdfadfaf===333==" + isTrue);
     ///发送数据成功
     if (isTrue) {
 
@@ -135,4 +139,7 @@ class BleUtil {
     var that = this;
     await that.manager.disconnect(device);
   }
+}
+module.exports = {
+  BleUtil
 }