diff --git a/lib/data/services/ble_manager.dart b/lib/data/services/ble_manager.dart index 1c921fa07..73fc14b9e 100644 --- a/lib/data/services/ble_manager.dart +++ b/lib/data/services/ble_manager.dart @@ -472,13 +472,37 @@ class BleManager extends GetxService { firmwareProductColor: '', ); } - - // 并行获取所有设备信息,不使用延迟 - final results = await Future.wait([ - _bleService.getBatteryInfo(), - _bleService.getDeviceVersion(), - _bleService.getProductId(), - ]); + final commands = [ + _bleService.getBatteryInfo, + _bleService.getDeviceVersion, + _bleService.getProductId, + ]; + + final delays = [ + Duration.zero, // 第一个命令立即执行 + const Duration(milliseconds: 100), // 第二个命令延迟100ms + const Duration(milliseconds: 200), // 第三个命令延迟200ms + ]; + + final futures = commands + .asMap() + .map((index, command) { + final delay = delays[index]; + return MapEntry( + index, + Future.delayed(delay, command), + ); + }) + .values + .toList(); + + final results = await Future.wait(futures); + // // 并行获取所有设备信息,不使用延迟 + // final results = await Future.wait([ + // _bleService.getBatteryInfo(), + // _bleService.getDeviceVersion(), + // _bleService.getProductId(), + // ]); Logger.info( '设备信息获取结果: 电池=${results[0]}, 版本=${results[1]}, 产品ID=${results[2]}'); diff --git a/local_plugins/ota/android/src/main/kotlin/com/example/ota/OtaPlugin.kt b/local_plugins/ota/android/src/main/kotlin/com/example/ota/OtaPlugin.kt index 8f68906de..c030cb725 100644 --- a/local_plugins/ota/android/src/main/kotlin/com/example/ota/OtaPlugin.kt +++ b/local_plugins/ota/android/src/main/kotlin/com/example/ota/OtaPlugin.kt @@ -337,10 +337,10 @@ class OtaPlugin : BleService.Callback, FlutterPlugin, MethodCallHandler { BleService.isEnterOta = false isDisconnect = false if(otaManager!= null) { - - otaManager?.bluetoothHelper?.stopScan() - - otaManager?.bluetoothHelper?.disconnectDevice(otaDevice) + BleService.removeCallback(this) + otaManager?.release() + otaManager= null + bluetoothHelper=null } result.success("") } else {