From b73fccd802a6dcbc2e58f37bc0ea43e3c15be1be Mon Sep 17 00:00:00 2001 From: lxm <1274844347@qq.com> Date: Thu, 20 Mar 2025 18:27:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AF=B9=E8=93=9D=E7=89=99?= =?UTF-8?q?=E5=BC=80=E5=85=B3=E7=8A=B6=E6=80=81=E7=9A=84=E7=9B=91=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/data/services/classic_bluetooth_service.dart | 4 ++-- lib/modules/home/controllers/home_controller.dart | 1 + lib/modules/home/views/home_view.dart | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/data/services/classic_bluetooth_service.dart b/lib/data/services/classic_bluetooth_service.dart index bc4c3a25e..3ed682e6b 100644 --- a/lib/data/services/classic_bluetooth_service.dart +++ b/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') { diff --git a/lib/modules/home/controllers/home_controller.dart b/lib/modules/home/controllers/home_controller.dart index 8b6bc7716..4cd0fdfa8 100644 --- a/lib/modules/home/controllers/home_controller.dart +++ b/lib/modules/home/controllers/home_controller.dart @@ -111,6 +111,7 @@ class HomeController extends GetxController { // 设置蓝牙监听器 void _setupBluetoothListeners() { + // 监听设备连接 _bluetoothService.onDeviceConnected((device) { Logger.info('监听到蓝牙设备连接: ${device.name}'); diff --git a/lib/modules/home/views/home_view.dart b/lib/modules/home/views/home_view.dart index da2a1aa3c..c3b646fae 100644 --- a/lib/modules/home/views/home_view.dart +++ b/lib/modules/home/views/home_view.dart @@ -69,6 +69,7 @@ class _AnimatedPulsingState extends State } } +//首页视图 class HomeView extends GetView { const HomeView({Key? key}) : super(key: key);