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