From c8b58c1a588df623b27f2afce323903a4cc41ea5 Mon Sep 17 00:00:00 2001
From: sjchen <13418980720@163.com>
Date: Thu, 9 Jan 2025 20:28:32 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B8=85=E7=A9=BA=E5=8E=86?=
=?UTF-8?q?=E5=8F=B2=E6=95=B0=E6=8D=AE=E7=9A=84=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
index/index.js | 16 ++++++++++++----
index/index.wxml | 1 +
utils/DataPacket.js | 14 ++++++++++++++
3 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/index/index.js b/index/index.js
index 1407447..9b83709 100644
--- a/index/index.js
+++ b/index/index.js
@@ -80,8 +80,8 @@ Page({
console.log("advertisData: ",hexStr)
// 连接指定设备
// if(device.deviceId=="03:02:02:07:65:98"){
- if(device.deviceId=="03:02:02:07:5F:AF"){
- // if(device.deviceId=="03:02:02:07:64:B4"){
+ // if(device.deviceId=="03:02:02:07:5F:AF"){
+ if(device.deviceId=="03:02:02:07:64:B4"){
this.connectToDevice(device.deviceId);
}
});
@@ -335,7 +335,7 @@ Page({
sendHealthCommand(){
// 指令依次是:心率,血氧、血压、体温、睡眠、步数
// 0x55,0x66,0x56,0x65,0x53,0x52
- const commands = [0x53];
+ const commands = [0x55];
// 递归发送命令并加上 5 秒延迟
function sendNextCommand(index = 0) {
if (index >= commands.length) return; // 所有命令发送完毕,结束
@@ -389,7 +389,15 @@ Page({
},
-
+ /**
+ * 清除历史数据
+ */
+ removeHistoryData(){
+ let basicPacket = DataPacket.removeHistoryData();
+ let hex = this.uint8ArrayToHex(basicPacket);
+ console.log('绑定时清除历史数据:', hex);
+ SendCommandUtil.sendPackage(this.data.deviceId,basicPacket);
+ },
/**
* 佩戴管理设置
*/
diff --git a/index/index.wxml b/index/index.wxml
index fbbed66..bd48c8b 100644
--- a/index/index.wxml
+++ b/index/index.wxml
@@ -8,5 +8,6 @@
+
\ No newline at end of file
diff --git a/utils/DataPacket.js b/utils/DataPacket.js
index 06a2772..dc1fa08 100644
--- a/utils/DataPacket.js
+++ b/utils/DataPacket.js
@@ -448,6 +448,20 @@ const DataPacket = {
return fullPackage;
},
+ /**
+ * 清空历史数据
+ */
+ removeHistoryData(){
+ const packet = new Uint8Array(16);
+ packet[0] = 0x61;
+ packet[1] = 0x00;
+ packet.fill(0x00, 2, 15);
+ // 计算并设置 CRC 校验字节
+ const crc = calculateCRC(packet.subarray(0, 15));
+ packet[15] = crc;
+ return packet;
+ }
+
}