Browse Source

ble已经链接,则不回连

weicu
fdp 1 year ago
parent
commit
ec0279b05d
  1. 5
      lib/data/services/bluetooth_manager.dart

5
lib/data/services/bluetooth_manager.dart

@ -3,6 +3,7 @@ import 'package:get/get.dart';
import 'package:classic_bluetooth/classic_bluetooth.dart'; import 'package:classic_bluetooth/classic_bluetooth.dart';
import '../../core/utils/logger.dart'; import '../../core/utils/logger.dart';
import '../../routes/app_routes.dart'; import '../../routes/app_routes.dart';
import 'ble_manager.dart';
// 重新导出蓝牙设备类型,让外部可以通过BluetoothManager访问 // 重新导出蓝牙设备类型,让外部可以通过BluetoothManager访问
export 'package:classic_bluetooth/classic_bluetooth.dart' show BluetoothDevice; export 'package:classic_bluetooth/classic_bluetooth.dart' show BluetoothDevice;
@ -19,7 +20,7 @@ class BluetoothManager extends GetxService {
// 当前经典蓝牙设备 // 当前经典蓝牙设备
final Rx<BluetoothDevice?> currentDeviceRx = Rx<BluetoothDevice?>(null); final Rx<BluetoothDevice?> currentDeviceRx = Rx<BluetoothDevice?>(null);
BluetoothDevice? get currentDevice => currentDeviceRx.value; BluetoothDevice? get currentDevice => currentDeviceRx.value;
final BleManager _bleManager = Get.find<BleManager>();
// 订阅 // 订阅
StreamSubscription<BluetoothEvent>? _bluetoothSubscription; StreamSubscription<BluetoothEvent>? _bluetoothSubscription;
@ -75,7 +76,7 @@ class BluetoothManager extends GetxService {
currentDeviceRx.value = newDevice; currentDeviceRx.value = newDevice;
// 检查当前是否在OTA升级界面,如果是则不跳转 // 检查当前是否在OTA升级界面,如果是则不跳转
if (!_isInOtaUpgradePage()) { if (!_isInOtaUpgradePage() && !_bleManager.isConnected) {
Get.toNamed(Routes.pairing, arguments: newDevice); Get.toNamed(Routes.pairing, arguments: newDevice);
} else { } else {
Logger.info('当前在OTA升级界面,跳过配对页面跳转'); Logger.info('当前在OTA升级界面,跳过配对页面跳转');

Loading…
Cancel
Save