fix:搜索蓝牙设备区分,sky改为76
This commit is contained in:
parent
a106fe6bbf
commit
10d4fa78fa
@ -262,7 +262,7 @@ class BlueManage {
|
|||||||
for (final ScanResult scanResult in results) {
|
for (final ScanResult scanResult in results) {
|
||||||
if (scanResult.advertisementData.serviceUuids.isNotEmpty) {
|
if (scanResult.advertisementData.serviceUuids.isNotEmpty) {
|
||||||
// AppLog.log(
|
// AppLog.log(
|
||||||
// '扫描到的设备:${scanResult.advertisementData.serviceUuids[0].toString()}');
|
// '扫描到的设备:${scanResult.advertisementData.serviceUuids[0].toString()}====${scanResult.advertisementData.advName}');
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -315,20 +315,30 @@ class BlueManage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 判断是否包含指定的uuid
|
/// 判断是否包含指定的uuid
|
||||||
bool _isMatch(List<String> serviceUuids,
|
bool _isMatch(List<String> serviceUuids, {DeviceType deviceType = DeviceType.blue}) {
|
||||||
{DeviceType deviceType = DeviceType.blue}) {
|
final List<String> prefixes = getDeviceType(deviceType).map((e) => e.toLowerCase()).toList();
|
||||||
// 获取设备类型数组
|
for (String uuid in serviceUuids) {
|
||||||
List<String> deviceTypeList = getDeviceType(deviceType);
|
final String cleanUuid = uuid.replaceAll('-', '').toLowerCase();
|
||||||
|
if (cleanUuid.length == 8) {
|
||||||
// 检查 serviceUuids 是否包含 deviceTypeList 中的任意一个值
|
// 8位,判断前两位
|
||||||
if (serviceUuids != null && serviceUuids.isNotEmpty) {
|
for (final prefix in prefixes) {
|
||||||
return serviceUuids.any((uuid) {
|
if (cleanUuid.startsWith(prefix)) {
|
||||||
return deviceTypeList
|
return true;
|
||||||
.any((type) => uuid.toLowerCase().contains(type.toLowerCase()));
|
}
|
||||||
});
|
}
|
||||||
|
} else if (cleanUuid.length == 32) {
|
||||||
|
// 128位,判断前8位的第3、第4位
|
||||||
|
final String first8 = cleanUuid.substring(0, 8);
|
||||||
|
if (first8.length >= 4) {
|
||||||
|
final String thirdAndFourth = first8.substring(2, 4); // 索引2和3
|
||||||
|
for (final prefix in prefixes) {
|
||||||
|
if (thirdAndFourth == prefix) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果 serviceUuids 为空,则返回 false
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ List<String> getDeviceType(DeviceType deviceType) {
|
|||||||
List<String> t = ['758824'];
|
List<String> t = ['758824'];
|
||||||
switch (deviceType) {
|
switch (deviceType) {
|
||||||
case DeviceType.blue:
|
case DeviceType.blue:
|
||||||
t = ['758824', '75'];
|
t = ['758824', '75', '768824', '76'];
|
||||||
break;
|
break;
|
||||||
case DeviceType.gateway:
|
case DeviceType.gateway:
|
||||||
t = ['758825'];
|
t = ['758825'];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user