From 295ce15fc4c6fa6b32e88f852f09f3c3ed193716 Mon Sep 17 00:00:00 2001 From: liyi Date: Mon, 4 Aug 2025 15:25:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=A2=9E=E5=8A=A0128bit=E7=9A=84=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=E7=8A=B6=E6=80=81=E5=88=A4=E6=96=AD=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E4=BD=8D=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/blue/blue_manage.dart | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/blue/blue_manage.dart b/lib/blue/blue_manage.dart index 29ea09f3..128cbaee 100755 --- a/lib/blue/blue_manage.dart +++ b/lib/blue/blue_manage.dart @@ -362,6 +362,27 @@ class BlueManage { // 00=未配对,01=已配对 if (pairStatus == '00') { return true; // 未配对才返回true + } else { + // 将十六进制字符串转换为整数(0~255) + int statusValue = int.parse(pairStatus, radix: 16); + // 提取 byte0(配对状态:第1位) + int byte0 = (statusValue >> 0) & 0x01; // 取最低位 + + // 提取 byte1(事件状态:第2位) + int byte1 = (statusValue >> 1) & 0x01; // 取次低位 + + // 判断是否未配对 + bool isPaired = (byte0 == 1); + + // 判断是否有新事件 + bool hasNewEvent = (byte1 == 1); + + // 返回是否未配对(原逻辑) + if (isPaired) { + return true; // 已配对返回false + } else { + return false; // 未配对返回true + } } // 已配对(01)不返回true,继续判断下一个uuid }