feat:优化蓝牙工具,android 低配手机新增保底逻辑

This commit is contained in:
anfe 2024-05-28 14:58:01 +08:00
parent 855ce1fb18
commit 0ec92eaad0

View File

@ -71,6 +71,7 @@ class BlueManage {
// //
List<int> lastTimeData = <int>[]; List<int> lastTimeData = <int>[];
int? dataLen; int? dataLen;
Timer? scanSingleTimer;
static BlueManage? _manager; static BlueManage? _manager;
@ -322,10 +323,13 @@ class BlueManage {
!isExistDevice && !isExistDevice &&
isCurrentDevice && isCurrentDevice &&
mac != null) { mac != null) {
scanSingleTimer?.cancel();
//android //android
await doNotSearchBLE(mac, connectStateCallBack); await doNotSearchBLE(mac, connectStateCallBack);
await Future<dynamic>.delayed(3.seconds); scanSingleTimer = Timer(3.seconds, () {
startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) => null); scanSingleTimer?.cancel();
startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) => null);
});
} else if (isAddEquipment == false && isExistDevice == false) { } else if (isAddEquipment == false && isExistDevice == false) {
//使 //使
startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) { startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) {
@ -436,7 +440,7 @@ class BlueManage {
// //
Future<void> doNotSearchBLE( Future<void> doNotSearchBLE(
String masAdds, ConnectStateCallBack connectStateCallBack) async { String masAdds, ConnectStateCallBack connectStateCallBack) async {
// FlutterBluePlus.setLogLevel(LogLevel.debug); await FlutterBluePlus.stopScan();
final BluetoothDevice device = BluetoothDevice.fromId(masAdds); final BluetoothDevice device = BluetoothDevice.fromId(masAdds);
// //
const int maxAttempts = 3; const int maxAttempts = 3;