Browse Source

修复对蓝牙开关状态的监测

weicu
lxm 2 years ago
parent
commit
b73fccd802
  1. 4
      lib/data/services/classic_bluetooth_service.dart
  2. 1
      lib/modules/home/controllers/home_controller.dart
  3. 1
      lib/modules/home/views/home_view.dart

4
lib/data/services/classic_bluetooth_service.dart

@ -316,7 +316,7 @@ class ClassicBluetoothService extends GetxService {
if (event is Map) {
final type = event['type'] as String?;
if (type == 'stateChanged') {
if (type == 'bluetoothStateChanged') {
final state = event['state'] as String?;
if (state != null) {
_handleBluetoothStateChange(state);
@ -353,7 +353,7 @@ class ClassicBluetoothService extends GetxService {
/// 处理蓝牙状态变化
void _handleBluetoothStateChange(String state) {
Logger.info('蓝牙状态变化: $state');
Logger.info('----蓝牙状态变化: $state');
// 如果蓝牙关闭,清除设备信息
if (state == 'off') {

1
lib/modules/home/controllers/home_controller.dart

@ -111,6 +111,7 @@ class HomeController extends GetxController {
// 设置蓝牙监听器
void _setupBluetoothListeners() {
// 监听设备连接
_bluetoothService.onDeviceConnected((device) {
Logger.info('监听到蓝牙设备连接: ${device.name}');

1
lib/modules/home/views/home_view.dart

@ -69,6 +69,7 @@ class _AnimatedPulsingState extends State<AnimatedPulsing>
}
}
//首页视图
class HomeView extends GetView<HomeController> {
const HomeView({Key? key}) : super(key: key);

Loading…
Cancel
Save