fix:搜索蓝牙设备区分,sky改为76

This commit is contained in:
liyi 2025-05-08 15:11:08 +08:00
parent a106fe6bbf
commit 10d4fa78fa
2 changed files with 25 additions and 15 deletions

View File

@ -262,7 +262,7 @@ class BlueManage {
for (final ScanResult scanResult in results) {
if (scanResult.advertisementData.serviceUuids.isNotEmpty) {
// AppLog.log(
// '扫描到的设备:${scanResult.advertisementData.serviceUuids[0].toString()}');
// '扫描到的设备:${scanResult.advertisementData.serviceUuids[0].toString()}====${scanResult.advertisementData.advName}');
} else {
continue;
}
@ -315,20 +315,30 @@ class BlueManage {
}
/// uuid
bool _isMatch(List<String> serviceUuids,
{DeviceType deviceType = DeviceType.blue}) {
//
List<String> deviceTypeList = getDeviceType(deviceType);
// serviceUuids deviceTypeList
if (serviceUuids != null && serviceUuids.isNotEmpty) {
return serviceUuids.any((uuid) {
return deviceTypeList
.any((type) => uuid.toLowerCase().contains(type.toLowerCase()));
});
bool _isMatch(List<String> serviceUuids, {DeviceType deviceType = DeviceType.blue}) {
final List<String> prefixes = getDeviceType(deviceType).map((e) => e.toLowerCase()).toList();
for (String uuid in serviceUuids) {
final String cleanUuid = uuid.replaceAll('-', '').toLowerCase();
if (cleanUuid.length == 8) {
// 8
for (final prefix in prefixes) {
if (cleanUuid.startsWith(prefix)) {
return true;
}
}
} else if (cleanUuid.length == 32) {
// 128834
final String first8 = cleanUuid.substring(0, 8);
if (first8.length >= 4) {
final String thirdAndFourth = first8.substring(2, 4); // 23
for (final prefix in prefixes) {
if (thirdAndFourth == prefix) {
return true;
}
}
}
}
}
// serviceUuids false
return false;
}

View File

@ -9,7 +9,7 @@ List<String> getDeviceType(DeviceType deviceType) {
List<String> t = ['758824'];
switch (deviceType) {
case DeviceType.blue:
t = ['758824', '75'];
t = ['758824', '75', '768824', '76'];
break;
case DeviceType.gateway:
t = ['758825'];