From 555e853a360eba7430ded97c257d24f7df9d49dd Mon Sep 17 00:00:00 2001 From: wyf <494641114@qq.com> Date: Tue, 22 Jul 2025 11:53:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=93=9D=E7=89=99=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/main_page_b_bottom_change.dart | 3 +++ lib/pages/mh_page/test/WebviewTestModel.dart | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/pages/main_bottom/component/main_page_b_bottom_change.dart b/lib/pages/main_bottom/component/main_page_b_bottom_change.dart index 207390f..44e6737 100644 --- a/lib/pages/main_bottom/component/main_page_b_bottom_change.dart +++ b/lib/pages/main_bottom/component/main_page_b_bottom_change.dart @@ -226,6 +226,9 @@ class _HomePageState extends State //如果当前没有连接该设备,则返回 return; } + if (webviewTestController.selectDevice['blueToothStatus']!=2) { + return; + } edm.EasyDartModule.websocket.sendData(jsonEncode(WebSocketMessage( to: data['from'], // to: ef.kvRoot.websocketId, diff --git a/lib/pages/mh_page/test/WebviewTestModel.dart b/lib/pages/mh_page/test/WebviewTestModel.dart index 87158b8..5f8b540 100644 --- a/lib/pages/mh_page/test/WebviewTestModel.dart +++ b/lib/pages/mh_page/test/WebviewTestModel.dart @@ -86,6 +86,7 @@ class WebviewTestController extends GetControllerEx { bridge.sdk.updateBlueToothStatus((args) async { ef.log('updateBlueToothStatus: $args'); bluetooth = args[0]; + selectDevice['blueToothStatus'] = bluetooth; return true; }); //sdk定义接口 @@ -145,7 +146,7 @@ class WebviewTestController extends GetControllerEx { ef.log('更新睡眠习惯: $args[0]'); try { MHTBlueToothController blueToothController = Get.find(); - blueToothController.saveHabitData(args[0]); + await blueToothController.saveHabitData(args[0]); } catch (e) { ef.log("[更新睡眠习惯失败]:$e"); } @@ -172,6 +173,16 @@ class WebviewTestController extends GetControllerEx { } return true; }); + // bridge.sdk.bluetoothConnect((args) async { + // ef.log('[蓝牙连接失败]: $args[0]'); + // try { + // selectDevice['blueToothStatus'] = 2; + // return true; + // } catch (e) { + // ef.log("[蓝牙连接失败]:$e"); + // } + // return true; + // }); }); } catch (e, s) { ef.log('$e,$s');