From f21f75d5e496067d2df0653a2ffef784d9b361cd Mon Sep 17 00:00:00 2001 From: wyf <494641114@qq.com> Date: Thu, 21 Aug 2025 17:25:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0ios=E8=93=9D=E7=89=99?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/mht_blueteeth_device_page.dart | 176 +++++++++--------- 1 file changed, 88 insertions(+), 88 deletions(-) diff --git a/lib/pages/mh_page/device/mht_blueteeth_device_page.dart b/lib/pages/mh_page/device/mht_blueteeth_device_page.dart index 874b795..c6903b7 100644 --- a/lib/pages/mh_page/device/mht_blueteeth_device_page.dart +++ b/lib/pages/mh_page/device/mht_blueteeth_device_page.dart @@ -989,97 +989,97 @@ class _MHTBlueteethDevicePageState extends State { } return result.device.remoteId.str.toUpperCase(); } +} - void advertisDataFormatter(var a, item) { - Map obj = {}; - try { - if (a[2] == 1) { - obj['sn'] = a[3]; - obj['deviceId'] = ab2str(a.sublist(4, 10)).toUpperCase(); - obj['b'] = a[10]; - obj['h'] = a[11]; - obj['t'] = a[12]; - item['adData'] = obj; - } else if (a[2] == 2) { - obj['sn'] = a[3]; - obj['deviceId'] = ab2str(a.sublist(4, 10)).toUpperCase(); - obj['b'] = a[10]; - obj['h'] = a[11]; - obj['t'] = a[12]; - obj['net'] = (a[13] & 1) == 1 ? '在线' : '离线'; - obj['flag'] = (a[13] & 2) == 2 ? '异常' : '正常'; - ByteData byteData = ByteData.sublistView( - Uint8List.fromList(a.sublist(14, 18).reversed.toList())); - obj['version'] = byteData.getUint32(0); - item['adData'] = obj; - } else if (a[2] == 3) { - List otherstr = []; - obj['sn'] = a[3]; - obj['deviceId'] = ab2str(a.sublist(4, 10)).toUpperCase(); - obj['b'] = a[10]; - obj['h'] = a[11]; - obj['t'] = a[12]; - obj['net'] = (a[13] & 1) == 1 ? '在线' : '离线'; - obj['flag'] = (a[13] & 2) == 2 ? '异常' : '正常'; +void advertisDataFormatter(var a, item) { + Map obj = {}; + try { + if (a[2] == 1) { + obj['sn'] = a[3]; + obj['deviceId'] = ab2str(a.sublist(4, 10)).toUpperCase(); + obj['b'] = a[10]; + obj['h'] = a[11]; + obj['t'] = a[12]; + item['adData'] = obj; + } else if (a[2] == 2) { + obj['sn'] = a[3]; + obj['deviceId'] = ab2str(a.sublist(4, 10)).toUpperCase(); + obj['b'] = a[10]; + obj['h'] = a[11]; + obj['t'] = a[12]; + obj['net'] = (a[13] & 1) == 1 ? '在线' : '离线'; + obj['flag'] = (a[13] & 2) == 2 ? '异常' : '正常'; + ByteData byteData = ByteData.sublistView( + Uint8List.fromList(a.sublist(14, 18).reversed.toList())); + obj['version'] = byteData.getUint32(0); + item['adData'] = obj; + } else if (a[2] == 3) { + List otherstr = []; + obj['sn'] = a[3]; + obj['deviceId'] = ab2str(a.sublist(4, 10)).toUpperCase(); + obj['b'] = a[10]; + obj['h'] = a[11]; + obj['t'] = a[12]; + obj['net'] = (a[13] & 1) == 1 ? '在线' : '离线'; + obj['flag'] = (a[13] & 2) == 2 ? '异常' : '正常'; - if ((a[13] & 4) == 4) { - otherstr.add('呼吸暂停'); - } - - if ((a[13] & 8) == 8 && (a[13] & 1) == 1) { - obj['isbed'] = '在床'; - } else { - obj['isbed'] = '离床'; - } - - if ((a[13] & 16) == 16) { - otherstr.add('授权过期'); - } - - if ((a[13] & 64) == 64) { - otherstr.add('设备休眠'); - } - - obj['other'] = otherstr.join('、'); - - ByteData byteData = ByteData.sublistView( - Uint8List.fromList(a.sublist(14, 18).reversed.toList())); - obj['version'] = byteData.getUint32(0); - - ByteData qsnData = - ByteData.sublistView(Uint8List.fromList(a.sublist(17, 19))); - obj['qsn'] = qsnData.getUint16(0) * 256 + obj['sn']; - - item['adData'] = obj; - } else if (a.length > 17) { - obj['sn'] = a[3]; - obj['deviceId'] = ab2str(a.sublist(4, 10)).toUpperCase(); - obj['b'] = a[10]; - obj['h'] = a[11]; - obj['t'] = a[12]; - obj['net'] = (a[13] & 1) == 1 ? '在线' : '离线'; - obj['flag'] = (a[13] & 2) == 2 ? '异常' : '正常'; - - ByteData byteData = ByteData.sublistView( - Uint8List.fromList(a.sublist(14, 18).reversed.toList())); - obj['version'] = byteData.getUint32(0); - - item['adData'] = obj; + if ((a[13] & 4) == 4) { + otherstr.add('呼吸暂停'); } - } catch (e) { - print(e); + + if ((a[13] & 8) == 8 && (a[13] & 1) == 1) { + obj['isbed'] = '在床'; + } else { + obj['isbed'] = '离床'; + } + + if ((a[13] & 16) == 16) { + otherstr.add('授权过期'); + } + + if ((a[13] & 64) == 64) { + otherstr.add('设备休眠'); + } + + obj['other'] = otherstr.join('、'); + + ByteData byteData = ByteData.sublistView( + Uint8List.fromList(a.sublist(14, 18).reversed.toList())); + obj['version'] = byteData.getUint32(0); + + ByteData qsnData = + ByteData.sublistView(Uint8List.fromList(a.sublist(17, 19))); + obj['qsn'] = qsnData.getUint16(0) * 256 + obj['sn']; + + item['adData'] = obj; + } else if (a.length > 17) { + obj['sn'] = a[3]; + obj['deviceId'] = ab2str(a.sublist(4, 10)).toUpperCase(); + obj['b'] = a[10]; + obj['h'] = a[11]; + obj['t'] = a[12]; + obj['net'] = (a[13] & 1) == 1 ? '在线' : '离线'; + obj['flag'] = (a[13] & 2) == 2 ? '异常' : '正常'; + + ByteData byteData = ByteData.sublistView( + Uint8List.fromList(a.sublist(14, 18).reversed.toList())); + obj['version'] = byteData.getUint32(0); + + item['adData'] = obj; } - } - - bool isQuanShiDevice(name) { - return "$name".contains("S4-ZM-M94-4") || - "$name".contains("S4-ZM-N94-4") || - "$name".contains("MHT-SWES-D"); - } - - bool isMHTSWES(name) { - return "$name".contains("MHT-") || - "$name".contains("MHT-SWES-M") || - "$name".contains("MHT-SWES-S"); + } catch (e) { + print(e); } } + +bool isQuanShiDevice(name) { + return "$name".contains("S4-ZM-M94-4") || + "$name".contains("S4-ZM-N94-4") || + "$name".contains("MHT-SWES-D"); +} + +bool isMHTSWES(name) { + return "$name".contains("MHT-") || + "$name".contains("MHT-SWES-M") || + "$name".contains("MHT-SWES-S"); +}