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