Merge branch 'release' into International-language+20240725
This commit is contained in:
commit
9f473d9909
@ -355,9 +355,14 @@ class BlueManage {
|
||||
return isExistDevice;
|
||||
}
|
||||
|
||||
Future<void> _connectDevice(List<ScanResult> devicesList, String deviceName,
|
||||
Future<void> _connectDevice(
|
||||
List<ScanResult> devicesList,
|
||||
String deviceName,
|
||||
ConnectStateCallBack connectStateCallBack,
|
||||
{bool isAddEquipment = false}) async {
|
||||
{
|
||||
bool isAddEquipment = false,// 是否是添加设备之前
|
||||
bool isReconnect = true,// 是否是重连
|
||||
}) async {
|
||||
// 判断数组列表里面是否有这个设备
|
||||
// AppLog.log("devicesList:$devicesList");
|
||||
final int knownDeviceIndex = devicesList.indexWhere((ScanResult d) =>
|
||||
@ -385,16 +390,18 @@ class BlueManage {
|
||||
AppLog.log('调用了停止扫描的方法');
|
||||
await stopScan();
|
||||
|
||||
if ((scanResult.advertisementData.serviceUuids[0].toString()[31] == '0') &&
|
||||
isAddEquipment == false) {
|
||||
connectStateCallBack(BluetoothConnectionState.disconnected);
|
||||
EasyLoading.showToast('该锁已被重置'.tr, duration: 2000.milliseconds);
|
||||
scanDevices.clear();
|
||||
|
||||
startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) {
|
||||
_connectDevice(scanDevices, deviceName, connectStateCallBack,
|
||||
isAddEquipment: isAddEquipment);
|
||||
});
|
||||
if ((scanResult.advertisementData.serviceUuids[0].toString()[31] == '0') && isAddEquipment == false) {
|
||||
// 添加这个判断是因为有些苹果设备或者安卓等性能比较好的设备时,添加完锁之后,锁板未改变为已添加状态之前,就进行了蓝牙连接,导致添加完锁就失败,这里进行了判断,如果第一次连接失败,就清除缓存重新扫描连接
|
||||
if(isReconnect == true){
|
||||
AppLog.log('该锁已被重置, 重新发送扫描命令');
|
||||
startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) {
|
||||
_connectDevice(scanDevices, deviceName, connectStateCallBack, isAddEquipment: isAddEquipment, isReconnect: false);
|
||||
});
|
||||
}else{
|
||||
connectStateCallBack(BluetoothConnectionState.disconnected);
|
||||
EasyLoading.showToast('该锁已被重置'.tr, duration: 2000.milliseconds);
|
||||
scanDevices.clear();
|
||||
}
|
||||
return;
|
||||
}
|
||||
//尝试连接设备
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user