Просмотр исходного кода

feature:增加OTA界面的开关,修改蓝牙的指令转换

zeng.chen 8 месяцев назад
Родитель
Сommit
34c2e941b5

+ 7 - 5
devices/bluetooth/bt_cmd.js

@@ -129,7 +129,7 @@ class BtCmd {
             const hours = Math.floor(time / day);
             const minutes = Math.floor((time % day) / hour);
             const seconds = Math.floor((time % day % hour));
-//            console.log(`${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`);
+            //            console.log(`${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`);
             console.log("休眠:", hour, minutes, seconds)
             return this._build(CmdRtc.setSleepAfterPlayPause, [hours, minutes, seconds]);
         } else {
@@ -301,7 +301,7 @@ class BtCmd {
         const length = cmd.length + 1;
         const l = this._int2Hex(length);
         cmd.splice(5, 0, l);
-        return new Uint8Array(cmd);
+        return cmd;
     }
 
     // 打印cmd
@@ -323,9 +323,11 @@ class BtCmd {
     }
 
     static _int2Hex(num) {
-        let value = num ?? 0
-        let hexStr = value.toString(16).toUpperCase(); // 转换为16进制字符串并转为大写
-        return hexStr.padStart(2, '0');
+        let value = num ?? 0;
+        let hexStr = value.toString(16).toUpperCase();
+        hexStr = hexStr.padStart(2, '0');
+        let hexNum = parseInt(hexStr, 16);
+        return hexNum;
     }
 
     static _int2HexString(value) {

+ 5 - 4
devices/bt_helper.js

@@ -447,6 +447,7 @@ class BtHelper {
   }
   async send(cmd, type) {
     if (cmd) {
+      console.log("发送数据:", cmd)
       this.queueManager.addTask(cmd)
     }
     // QueueManager.instance.addTask({ task: cmd });
@@ -503,11 +504,11 @@ class BtHelper {
     // } else {
     // that.send(BtCmd.setDevTime());
 
-    that.send(BtCmd.queryKwh());
+    // that.send(BtCmd.queryKwh());
     that.getSleep();
-    that.getAlert();
-    that.send(BtCmd.queryRGB());
-    that.getVolume();
+    // that.getAlert();
+    // that.send(BtCmd.queryRGB());
+    // that.getVolume();
     // that.setVolume(8)
     that.getPauseSleep();
 

+ 2 - 1
pages/deviceDetail/detail.js

@@ -84,7 +84,8 @@ Page({
    */
   onLoad: function (options) {
     // let device = JSON.parse(options.param);
-    let device = getApp().globalData.mDeviceList[0];
+    console.log(getApp().globalData.mDeviceList.length)
+    let device = getApp().globalData.mDeviceList[0] ?? JSON.parse(options.param);
     if (device.connectType != '1') {
       return
     }

+ 1 - 1
pages/index/index.js

@@ -675,7 +675,7 @@ Page({
       return;
     }
 
-    if (item.connect != "1") {
+    if (item.connectType != "1") {
       return
     }
     ///去蓝牙连接处理

+ 2 - 1
pages/ota/ota.js

@@ -285,7 +285,8 @@ Page({
     device.clientType = device.clientType ?? device.ProdModel
     this.setData({
       otaData: otaData,
-      device: device
+      device: device,
+      isShowOta: device.clientType === 'MW-S2(BLE)'
     })
 
     let _this = this;

+ 3 - 1
pages/ota/ota.wxml

@@ -14,7 +14,9 @@
         <text class="label">MAC地址</text>
         <text class="arrow">{{device.mac}}</text>
     </view>
-    <view class="button main_color" bind:tap="startOtaTap">{{buttonTips}}</view>
+    <view wx:if="{{isShowOta}}" class="button main_color" bind:tap="startOtaTap">
+        {{buttonTips}}
+    </view>
 </view>
 <view wx:if="{{otaStatus === 3}}" class="background">
     <view class="content">