fix:修复无法搜索到网关的问题
This commit is contained in:
parent
4045adf0b2
commit
139d16387c
@ -348,21 +348,43 @@ class BlueManage {
|
|||||||
} else {
|
} else {
|
||||||
// 128位,判断前8位的第3、第4位
|
// 128位,判断前8位的第3、第4位
|
||||||
if (cleanUuid.length >= 32) {
|
if (cleanUuid.length >= 32) {
|
||||||
final String thirdAndFourth = cleanUuid.substring(2, 4); // 索引2和3
|
if (deviceType == DeviceType.blue) {
|
||||||
for (final prefix in prefixes) {
|
final String thirdAndFourth = cleanUuid.substring(2, 4); // 索引2和3
|
||||||
if (thirdAndFourth == prefix) {
|
for (final prefix in prefixes) {
|
||||||
if (isSingle) {
|
if (thirdAndFourth == prefix) {
|
||||||
return true; // isSingle为true,前缀匹配即返回true
|
if (isSingle) {
|
||||||
} else {
|
return true; // isSingle为true,前缀匹配即返回true
|
||||||
// 判断配对状态(带横杠UUID的第31、32位,从1开始计数)
|
} else {
|
||||||
if (cleanUuid.length >= 32) {
|
// 判断配对状态(带横杠UUID的第31、32位,从1开始计数)
|
||||||
String pairStatus =
|
if (cleanUuid.length >= 32) {
|
||||||
cleanUuid.substring(30, 32); // 第31、32位(从1开始计数)
|
String pairStatus =
|
||||||
// 00=未配对,01=已配对
|
cleanUuid.substring(30, 32); // 第31、32位(从1开始计数)
|
||||||
if (pairStatus == '00') {
|
// 00=未配对,01=已配对
|
||||||
return true; // 未配对才返回true
|
if (pairStatus == '00') {
|
||||||
|
return true; // 未配对才返回true
|
||||||
|
}
|
||||||
|
// 已配对(01)不返回true,继续判断下一个uuid
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (deviceType == DeviceType.gateway) {
|
||||||
|
final String thirdAndFourth = cleanUuid.substring(2, 8); // 索引2和3
|
||||||
|
for (final prefix in prefixes) {
|
||||||
|
if (thirdAndFourth == prefix) {
|
||||||
|
if (isSingle) {
|
||||||
|
return true; // isSingle为true,前缀匹配即返回true
|
||||||
|
} else {
|
||||||
|
// 判断配对状态(带横杠UUID的第31、32位,从1开始计数)
|
||||||
|
if (cleanUuid.length >= 32) {
|
||||||
|
String pairStatus =
|
||||||
|
cleanUuid.substring(30, 32); // 第31、32位(从1开始计数)
|
||||||
|
// 00=未配对,01=已配对
|
||||||
|
if (pairStatus == '00') {
|
||||||
|
return true; // 未配对才返回true
|
||||||
|
}
|
||||||
|
// 已配对(01)不返回true,继续判断下一个uuid
|
||||||
}
|
}
|
||||||
// 已配对(01)不返回true,继续判断下一个uuid
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -99,7 +99,7 @@ class SelectGatewayListLogic extends BaseGetXController {
|
|||||||
void startScanBlueList() {
|
void startScanBlueList() {
|
||||||
state.devices.clear();
|
state.devices.clear();
|
||||||
BlueManage().startScan(2000, DeviceType.gateway, (List<ScanResult> list) {
|
BlueManage().startScan(2000, DeviceType.gateway, (List<ScanResult> list) {
|
||||||
AppLog.log('ScanResultList:$list');
|
// AppLog.log('ScanResultList:$list');
|
||||||
for (int i = 0; i < list.length; i++) {
|
for (int i = 0; i < list.length; i++) {
|
||||||
final ScanResult device = list[i];
|
final ScanResult device = list[i];
|
||||||
// if ((device.advertisementData.serviceUuids.isNotEmpty
|
// if ((device.advertisementData.serviceUuids.isNotEmpty
|
||||||
@ -211,7 +211,8 @@ class SelectGatewayListLogic extends BaseGetXController {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
|
||||||
_replySubscription.cancel();
|
_replySubscription.cancel();
|
||||||
|
super.dispose();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user