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');