feat:优化蓝牙工具,android 低配手机新增保底逻辑
This commit is contained in:
parent
855ce1fb18
commit
0ec92eaad0
@ -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;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user