Browse Source

ble已经链接,则不回连

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

Loading…
Cancel
Save