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 }