蓝牙控制类修改方法 修复首次添加完锁之后,部分机型开锁提示锁已被重置问题

This commit is contained in:
魏少阳 2024-08-01 11:10:46 +08:00
parent 696a2884d2
commit 0d2dd5f585

View File

@ -355,9 +355,14 @@ class BlueManage {
return isExistDevice; return isExistDevice;
} }
Future<void> _connectDevice(List<ScanResult> devicesList, String deviceName, Future<void> _connectDevice(
List<ScanResult> devicesList,
String deviceName,
ConnectStateCallBack connectStateCallBack, ConnectStateCallBack connectStateCallBack,
{bool isAddEquipment = false}) async { {
bool isAddEquipment = false,//
bool isReconnect = true,//
}) async {
// //
// AppLog.log("devicesList:$devicesList"); // AppLog.log("devicesList:$devicesList");
final int knownDeviceIndex = devicesList.indexWhere((ScanResult d) => final int knownDeviceIndex = devicesList.indexWhere((ScanResult d) =>
@ -385,16 +390,18 @@ class BlueManage {
AppLog.log('调用了停止扫描的方法'); AppLog.log('调用了停止扫描的方法');
await stopScan(); await stopScan();
if ((scanResult.advertisementData.serviceUuids[0].toString()[31] == '0') && if ((scanResult.advertisementData.serviceUuids[0].toString()[31] == '0') && isAddEquipment == false) {
isAddEquipment == false) { //
connectStateCallBack(BluetoothConnectionState.disconnected); if(isReconnect == true){
EasyLoading.showToast('该锁已被重置'.tr, duration: 2000.milliseconds); AppLog.log('该锁已被重置, 重新发送扫描命令');
scanDevices.clear(); startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) {
_connectDevice(scanDevices, deviceName, connectStateCallBack, isAddEquipment: isAddEquipment, isReconnect: false);
startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) { });
_connectDevice(scanDevices, deviceName, connectStateCallBack, }else{
isAddEquipment: isAddEquipment); connectStateCallBack(BluetoothConnectionState.disconnected);
}); EasyLoading.showToast('该锁已被重置'.tr, duration: 2000.milliseconds);
scanDevices.clear();
}
return; return;
} }
// //