fix:SKY环境下注释该锁已被重置的弹窗

This commit is contained in:
liyi 2025-04-28 09:20:11 +08:00
parent ea96419e05
commit d75754e14e

View File

@ -5,6 +5,7 @@ import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_settings.dart';
import 'package:star_lock/flavors.dart';
import 'package:star_lock/tools/bugly/bugly_tool.dart';
import 'package:star_lock/tools/commonDataManage.dart';
@ -551,7 +552,10 @@ class BlueManage {
});
} else {
connectStateCallBack(BluetoothConnectionState.disconnected);
EasyLoading.showToast('该锁已被重置'.tr, duration: 2000.milliseconds);
if (!F.isSKY) {
EasyLoading.showToast('该锁已被重置'.tr, duration: 2000.milliseconds);
}
scanDevices.clear();
BuglyTool.uploadException(
@ -582,7 +586,9 @@ class BlueManage {
});
} else {
connectStateCallBack(BluetoothConnectionState.disconnected);
EasyLoading.showToast('该锁已被重置'.tr, duration: 2000.milliseconds);
if (!F.isSKY) {
EasyLoading.showToast('该锁已被重置'.tr, duration: 2000.milliseconds);
}
scanDevices.clear();
BuglyTool.uploadException(
@ -789,34 +795,39 @@ class BlueManage {
int retryCount = 0;
const int maxRetries = 3;
const int retryDelayMs = 500;
final List<int> valueList = value;
final List subData = splitList(valueList, _mtuSize!);
for (int i = 0; i < subData.length; i++) {
//
bool packetSent = false;
retryCount = 0;
while (!packetSent && retryCount < maxRetries) {
try {
if (characteristic.properties.writeWithoutResponse) {
await characteristic.write(subData[i], withoutResponse: true);
await characteristic.write(subData[i],
withoutResponse: true);
} else if (characteristic.properties.write) {
await characteristic.write(subData[i]);
} else {
//
throw Exception('This characteristic does not support writing.');
throw Exception(
'This characteristic does not support writing.');
}
//
packetSent = true;
} catch (e) {
if (e.toString().contains('UNKNOWN_GATT_ERROR (133)') && retryCount < maxRetries - 1) {
if (e.toString().contains('UNKNOWN_GATT_ERROR (133)') &&
retryCount < maxRetries - 1) {
// GATT错误133
retryCount++;
AppLog.log('蓝牙写入失败(GATT 133),数据包 ${i+1}/${subData.length} 正在重试 $retryCount/$maxRetries...');
await Future.delayed(Duration(milliseconds: retryDelayMs));
AppLog.log(
'蓝牙写入失败(GATT 133),数据包 ${i + 1}/${subData.length} 正在重试 $retryCount/$maxRetries...');
await Future.delayed(
Duration(milliseconds: retryDelayMs));
continue;
} else {
//
@ -825,12 +836,13 @@ class BlueManage {
}
}
}
if (!packetSent) {
throw Exception('蓝牙写入失败,数据包 ${i+1}/${subData.length} 已达到最大重试次数');
throw Exception(
'蓝牙写入失败,数据包 ${i + 1}/${subData.length} 已达到最大重试次数');
}
}
return; //
} on Exception catch (e, s) {
AppLog.log('APP写入失败: $e $s');
@ -840,7 +852,7 @@ class BlueManage {
}
}
}
//
throw Exception('未找到适合写入的蓝牙特性');
}