diff --git a/star_lock/lib/blue/blue_manage.dart b/star_lock/lib/blue/blue_manage.dart index 36c245ed..dc75543b 100644 --- a/star_lock/lib/blue/blue_manage.dart +++ b/star_lock/lib/blue/blue_manage.dart @@ -16,13 +16,13 @@ class BlueManage { final List scanDevices = []; // 用来写入的服务id - Uuid serviceIdConnect = Uuid.parse("fff0"); + final Uuid _serviceIdConnect = Uuid.parse("fff0"); // 用来写入的服务id - Uuid serviceIdWrite = Uuid.parse('0000FFF0-0000-1000-8000-00805F9B34FB'); + final Uuid _serviceIdWrite = Uuid.parse('0000FFF0-0000-1000-8000-00805F9B34FB'); // 用来订阅的特征id - Uuid characteristicIdSubscription = Uuid.parse("fff1"); + final Uuid _characteristicIdSubscription = Uuid.parse("fff1"); // 用来写入的特征id - Uuid characteristicIdWrite = Uuid.parse("fff2"); + final Uuid _characteristicIdWrite = Uuid.parse("fff2"); // 监听发送事件 StreamSubscription? _sendStreamSubscription; @@ -36,8 +36,7 @@ class BlueManage { // 当前连接设备的mac地址 String connectDeviceMacAddress = ""; // 监听蓝牙连接状态 - DeviceConnectionState? deviceConnectionState = - DeviceConnectionState.disconnected; + DeviceConnectionState? deviceConnectionState = DeviceConnectionState.disconnected; static BlueManage? _manager; BlueManage._init(); @@ -92,7 +91,7 @@ class BlueManage { } /// 调用连接 - Future judgeReconnect(String deviceName, ConnectStateCallBack stateCallBack) async { + Future bludSendData(String deviceName, ConnectStateCallBack stateCallBack) async { if(deviceConnectionState != DeviceConnectionState.connected){ _connect(deviceName, (state){ stateCallBack(deviceConnectionState!); @@ -117,7 +116,7 @@ class BlueManage { Timer.periodic(const Duration(milliseconds: 1000), (timer) { ///定时任务 // print("timer index0:$index"); - if(index >= 5){ + if(index >= 4){ // 当超过5秒的时候取消定时任务 弹窗显示连接失败 completer.complete(); timer.cancel(); @@ -127,8 +126,7 @@ class BlueManage { connectStateCallBack(DeviceConnectionState.disconnected); }else{ // 每秒判断数组列表里面是否有这个设备 - final knownDeviceIndex = - scanDevices.indexWhere((d) => d.name == deviceName); + final knownDeviceIndex = scanDevices.indexWhere((d) => d.name == deviceName); if (knownDeviceIndex >= 0) { // 存在的时候销毁定时器,赋值 completer.complete(); @@ -138,7 +136,7 @@ class BlueManage { } else { // 不存在的时候返回-1 然后循环5秒 index++; - print("index:$index 没有找到设备"); + print("index:$index"); } } }); @@ -158,7 +156,7 @@ class BlueManage { if (connectionStateUpdate.connectionState == DeviceConnectionState.connected) { // 如果状态是连接的开始发现服务 try { - _subScribeToCharacteristic(QualifiedCharacteristic(characteristicId: characteristicIdSubscription, serviceId: serviceIdConnect, deviceId: connectDeviceMacAddress)); + _subScribeToCharacteristic(QualifiedCharacteristic(characteristicId: _characteristicIdSubscription, serviceId: _serviceIdConnect, deviceId: connectDeviceMacAddress)); print('Discovering services finished'); deviceConnectionState = connectionStateUpdate.connectionState; @@ -225,7 +223,7 @@ class BlueManage { // 写入 Future writeCharacteristicWithResponse(List value) async { - QualifiedCharacteristic characteristic = QualifiedCharacteristic(characteristicId: characteristicIdWrite, serviceId: serviceIdWrite, deviceId: connectDeviceMacAddress); + QualifiedCharacteristic characteristic = QualifiedCharacteristic(characteristicId: _characteristicIdWrite, serviceId: _serviceIdWrite, deviceId: connectDeviceMacAddress); int mtuLength = await _flutterReactiveBle!.requestMtu(deviceId: characteristic.deviceId, mtu: 250); print("mtuLength:$mtuLength"); try { diff --git a/star_lock/lib/main.dart b/star_lock/lib/main.dart index 14669831..b223b6b8 100644 --- a/star_lock/lib/main.dart +++ b/star_lock/lib/main.dart @@ -50,7 +50,7 @@ class MyApp extends StatefulWidget { } // 注册 RouteObserver 作为 navigation observer. -final RouteObserver routeObserver = RouteObserver(); +// final RouteObserver routeObserver = RouteObserver(); class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { final _aliyunPush = AliyunPush(); @@ -68,7 +68,7 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { GetMaterialApp _initMaterialApp() => GetMaterialApp( title: 'Star Lock', - navigatorObservers: [routeObserver, AppRouteObserver().routeObserver], + navigatorObservers: [AppRouteObserver().routeObserver], translations: TranslationMessage(), supportedLocales: appDept.deptSupportedLocales, localizationsDelegates: const [ @@ -233,3 +233,4 @@ Future getMicrophonePermission() async { } return false; } + diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart index 8bf4eb2d..b3551c6f 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart @@ -163,7 +163,7 @@ class AuthorizedAdminLogic extends BaseGetXController { // 转移权限 Future transferPermissionsAction() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState state) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async { if (state == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -192,7 +192,7 @@ class AuthorizedAdminLogic extends BaseGetXController { // 添加用户 Future addUserConnectBlue(String receiveId) async { // 进来之后首先连接 - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connecteState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connecteState) async { if (connecteState == DeviceConnectionState.connected) { // 私钥 var privateKey = await Storage.getStringList(saveBluePrivateKey); diff --git a/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart b/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart index b5bc966e..469b2ad9 100644 --- a/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart +++ b/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart @@ -214,7 +214,7 @@ class AddICCardLogic extends BaseGetXController{ // 添加卡片 Future senderAddICCard() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { if (deviceConnectionState == DeviceConnectionState.connected){ var publicKey = await Storage.getStringList(saveBluePublicKey); List publicKeyDataList = changeStringListToIntList(publicKey!); @@ -241,7 +241,7 @@ class AddICCardLogic extends BaseGetXController{ token: getTokenList, ); } else if (deviceConnectionState == DeviceConnectionState.disconnected){ - Toast.show(msg: "连接设备失败,请确保在设备附近,设备未被连接,设备已打开"); + showBlueConnetctToast(); Get.close(2); } }); @@ -249,7 +249,7 @@ class AddICCardLogic extends BaseGetXController{ // 添加胁迫卡片 Future senderAddStressICCard() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { if (deviceConnectionState == DeviceConnectionState.connected){ var publicKey = await Storage.getStringList(saveBluePublicKey); List publicKeyDataList = changeStringListToIntList(publicKey!); diff --git a/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart b/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart index 0bea547c..9d493da4 100644 --- a/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart @@ -88,7 +88,7 @@ class CardDetailLogic extends BaseGetXController{ // 删除卡片 Future senderAddICCard() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { if (deviceConnectionState == DeviceConnectionState.connected){ var publicKey = await Storage.getStringList(saveBluePublicKey); List publicKeyDataList = changeStringListToIntList(publicKey!); diff --git a/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart b/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart index 69f4daf0..857dcb11 100644 --- a/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart +++ b/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart @@ -205,7 +205,7 @@ class CardListLogic extends BaseGetXController { // 查询卡片状态 Future senderCheckingCardStatus() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState state) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async { if (state == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -233,7 +233,7 @@ class CardListLogic extends BaseGetXController { // 查询用户、指纹、密码、卡片数量(用于判断是否同步) Future senderCheckingUserInfoCount() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState state) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async { if (state == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -260,7 +260,7 @@ class CardListLogic extends BaseGetXController { // 删除卡片 Future senderAddICCard() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { if (deviceConnectionState == DeviceConnectionState.connected){ var publicKey = await Storage.getStringList(saveBluePublicKey); List publicKeyDataList = changeStringListToIntList(publicKey!); diff --git a/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart b/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart index 557e2c35..54ebb4e4 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart @@ -252,7 +252,7 @@ class AddFingerprintLogic extends BaseGetXController { // 添加指纹开始 Future senderAddFingerprint() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { // print("66666666:$deviceConnectionState"); if (deviceConnectionState == DeviceConnectionState.connected){ var publicKey = await Storage.getStringList(saveBluePublicKey); @@ -280,7 +280,7 @@ class AddFingerprintLogic extends BaseGetXController { token: getTokenList, ); }else if (deviceConnectionState == DeviceConnectionState.disconnected){ - Toast.show(msg: "连接设备失败,请确保在设备附近,设备未被连接,设备已打开"); + showBlueConnetctToast(); Get.close(2); } }); @@ -288,7 +288,7 @@ class AddFingerprintLogic extends BaseGetXController { // 添加胁迫指纹 Future senderAddStressFingerprint() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { if (deviceConnectionState == DeviceConnectionState.connected){ var publicKey = await Storage.getStringList(saveBluePublicKey); List publicKeyDataList = changeStringListToIntList(publicKey!); diff --git a/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart b/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart index 039fe523..85a3a7e2 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart @@ -89,7 +89,7 @@ class FingerprintDetailLogic extends BaseGetXController{ // 删除指纹 Future senderAddFingerprint() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { if (deviceConnectionState == DeviceConnectionState.connected){ var publicKey = await Storage.getStringList(saveBluePublicKey); List publicKeyDataList = changeStringListToIntList(publicKey!); diff --git a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart index ce4126b9..71b540a2 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart @@ -238,7 +238,7 @@ class FingerprintListLogic extends BaseGetXController{ } // 获取指纹状态 Future senderQueryingFingerprintStatus() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName,(DeviceConnectionState state) async { + BlueManage().bludSendData(BlueManage().connectDeviceName,(DeviceConnectionState state) async { if (state == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -266,7 +266,7 @@ class FingerprintListLogic extends BaseGetXController{ // 查询用户、指纹、密码、卡片数量(用于判断是否同步) Future senderCheckingUserInfoCount() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState state) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async { if (state == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -293,7 +293,7 @@ class FingerprintListLogic extends BaseGetXController{ // 删除指纹 Future senderAddFingerprint() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { if (deviceConnectionState == DeviceConnectionState.connected){ var publicKey = await Storage.getStringList(saveBluePublicKey); List publicKeyDataList = changeStringListToIntList(publicKey!); diff --git a/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_logic.dart index bdc4c68b..0caf70dc 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_logic.dart @@ -128,7 +128,7 @@ class AutomaticBlockingLogic extends BaseGetXController{ // 读取支持功能-带参数 Future _readSupportFunctionsWithParameters() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -155,7 +155,7 @@ class AutomaticBlockingLogic extends BaseGetXController{ // 设置支持功能(带参数) Future sendAutoLock() async { showEasyLoading(); - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { dismissEasyLoading(); var privateKey = await Storage.getStringList(saveBluePrivateKey); diff --git a/star_lock/lib/main/lockDetail/lcokSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_logic.dart index 83c1cd22..b1ffa20e 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_logic.dart @@ -13,7 +13,7 @@ class AdminOpenLockPasswordLogic extends BaseGetXController{ // 读取支持功能-带参数 Future _readAdminPassword() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); diff --git a/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_logic.dart index dc72029c..0edd2624 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_logic.dart @@ -7,7 +7,7 @@ class BasicInformationLogic extends BaseGetXController{ // 读取支持功能-带参数 // Future _readAdminPassword() async { - // BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + // BlueManage().bludSendData(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { // if (connectionState == DeviceConnectionState.connected) { // var privateKey = await Storage.getStringList(saveBluePrivateKey); // List getPrivateKeyList = changeStringListToIntList(privateKey!); diff --git a/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_logic.dart index 5f24f753..b3e06ce9 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_logic.dart @@ -112,7 +112,7 @@ class BurglarAlarmLogic extends BaseGetXController{ // 读取支持功能-带参数 Future _readSupportFunctionsNoParameters() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -139,7 +139,7 @@ class BurglarAlarmLogic extends BaseGetXController{ // 设置支持功能(带参数) Future sendBurglarAlarm() async { showEasyLoading(); - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { dismissEasyLoading(); var privateKey = await Storage.getStringList(saveBluePrivateKey); diff --git a/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_logic.dart index 2fda5d7e..bb99c511 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_logic.dart @@ -144,7 +144,7 @@ class ConfiguringWifiLogic extends BaseGetXController{ // 点击配置wifi Future senderConfiguringWifiAction() async { showEasyLoading(); - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected){ dismissEasyLoading(); var privateKey = await Storage.getStringList(saveBluePrivateKey); diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart index 42d89d22..6ec52434 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart @@ -257,7 +257,9 @@ class LockSetLogic extends BaseGetXController { // 删除用户 Future deletUserAction() async { showEasyLoading(); - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + showBlueConnetctToastTimer(); + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + cancelBlueConnetctToastTimer(); if (connectionState == DeviceConnectionState.connected) { dismissEasyLoading(); var privateKey = await Storage.getStringList(saveBluePrivateKey); @@ -291,7 +293,9 @@ class LockSetLogic extends BaseGetXController { // 恢复出厂设置 Future factoryDataResetAction() async { showEasyLoading(); - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + showBlueConnetctToastTimer(); + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + cancelBlueConnetctToastTimer(); if (connectionState == DeviceConnectionState.connected) { dismissEasyLoading(); var privateKey = await Storage.getStringList(saveBluePrivateKey); @@ -320,7 +324,7 @@ class LockSetLogic extends BaseGetXController { // 读取支持功能-带参数 // Future _readSupportFunctionsNoParameters(int type) async { - // BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + // BlueManage().bludSendData(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { // if (connectionState == DeviceConnectionState.connected) { // var privateKey = await Storage.getStringList(saveBluePrivateKey); // List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -347,7 +351,9 @@ class LockSetLogic extends BaseGetXController { // 设置支持功能(带参数) Future sendBurglarAlarm(int type) async { showEasyLoading(); - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + showBlueConnetctToastTimer(); + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + cancelBlueConnetctToastTimer(); if (connectionState == DeviceConnectionState.connected) { dismissEasyLoading(); var privateKey = await Storage.getStringList(saveBluePrivateKey); @@ -614,7 +620,6 @@ class LockSetLogic extends BaseGetXController { void onReady() { // TODO: implement onReady super.onReady(); - print("onReady()"); getLockSettingInfoData(); @@ -626,12 +631,12 @@ class LockSetLogic extends BaseGetXController { void onInit() { // TODO: implement onInit super.onInit(); - print("onInit()"); } @override void onClose() { // TODO: implement onClose + _replySubscription.cancel(); _passCurrentLockInformationEvent!.cancel(); _scanListDiscoveredDeviceSubscription.cancel(); diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart index 8319e740..e41269bf 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart @@ -5,6 +5,7 @@ import 'package:get/get.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../main.dart'; import '../../../../tools/appRouteObserver.dart'; import '../../../../tools/commonItem.dart'; @@ -15,6 +16,7 @@ import '../../../../tools/toast.dart'; import '../../../../translations/trans_lib.dart'; import 'lockSet_logic.dart'; +// final RouteObserver routeObserver = RouteObserver(); class LockSetPage extends StatefulWidget { const LockSetPage({Key? key}) : super(key: key); @@ -782,7 +784,6 @@ class _LockSetPageState extends State with RouteAware { // }, // ); // } - @override void didChangeDependencies() { // TODO: implement didChangeDependencies @@ -800,27 +801,33 @@ class _LockSetPageState extends State with RouteAware { super.dispose(); } - /// 界面从上一个界面进入 当前界面即将出现 + /// 从上级界面进入 当前界面即将出现 @override void didPush() { + super.didPush(); print("lockSet===didPush"); } - /// 界面返回上一个界面 当前界面即将消失 + /// 返回上一个界面 当前界面即将消失 @override void didPop() { + super.didPop(); print("lockSet===didPop"); + logic.cancelBlueConnetctToastTimer(); } - /// 当前界面从下一级返回 当前界面即将出现 + /// 从下级返回 当前界面即将出现 @override void didPopNext() { + super.didPopNext(); print("lockSet===didPopNext"); } - /// 当前界面进入下一个界面 当前界面即将消失 + /// 进入下级界面 当前界面即将消失 @override void didPushNext() { + super.didPushNext(); print("lockSet===didPushNext"); + logic.cancelBlueConnetctToastTimer(); } } diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_logic.dart index c9e929ed..f511ce29 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_logic.dart @@ -120,7 +120,7 @@ class LockSoundSetLogic extends BaseGetXController { // 读取支持功能-带参数 Future _readSupportFunctionsWithParameters() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -147,7 +147,7 @@ class LockSoundSetLogic extends BaseGetXController { // 设置支持功能(带参数) Future sendLockSound() async { showEasyLoading(); - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { dismissEasyLoading(); var privateKey = await Storage.getStringList(saveBluePrivateKey); diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_logic.dart index ebf3e6d5..826fde17 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_logic.dart @@ -131,7 +131,7 @@ class LockTimeLogic extends BaseGetXController{ // 获取锁状态 // Future _getLockStatus() async { // // 进来之后首先连接 - // BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async { + // BlueManage().bludSendData(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async { // if (state == DeviceConnectionState.connected) { // var privateKey = await Storage.getStringList(saveBluePrivateKey); // List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -147,7 +147,7 @@ class LockTimeLogic extends BaseGetXController{ // 校验时间 Future sendTiming() async { showEasyLoading(); - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { dismissEasyLoading(); var privateKey = await Storage.getStringList(saveBluePrivateKey); diff --git a/star_lock/lib/main/lockDetail/lcokSet/motorPower/motorPower_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/motorPower/motorPower_logic.dart index 6e5a44f0..627a1f51 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/motorPower/motorPower_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/motorPower/motorPower_logic.dart @@ -111,7 +111,7 @@ class MotorPowerLogic extends BaseGetXController { // 读取支持功能-带参数 Future _readSupportFunctionsNoParameters() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -137,7 +137,7 @@ class MotorPowerLogic extends BaseGetXController { // 设置支持功能(带参数) Future sendOpenDoorDirection() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); diff --git a/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_logic.dart index ab8dd28b..a0f5ce02 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_logic.dart @@ -139,7 +139,7 @@ class NormallyOpenModeLogic extends BaseGetXController{ // 读取支持功能-带参数 Future _readSupportFunctionsWithParameters() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -166,7 +166,7 @@ class NormallyOpenModeLogic extends BaseGetXController{ // 设置支持功能(带参数) Future sendAutoLock() async { showEasyLoading(); - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { dismissEasyLoading(); var privateKey = await Storage.getStringList(saveBluePrivateKey); diff --git a/star_lock/lib/main/lockDetail/lcokSet/openDoorDirection/openDoorDirection_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/openDoorDirection/openDoorDirection_logic.dart index 252c8257..5b30442f 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/openDoorDirection/openDoorDirection_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/openDoorDirection/openDoorDirection_logic.dart @@ -113,7 +113,7 @@ class OpenDoorDirectionLogic extends BaseGetXController { // 读取支持功能-带参数 Future _readSupportFunctionsNoParameters() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -140,7 +140,7 @@ class OpenDoorDirectionLogic extends BaseGetXController { // 设置支持功能(带参数) Future sendOpenDoorDirection() async { showEasyLoading(); - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { dismissEasyLoading(); if (connectionState == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); diff --git a/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_logic.dart index b1be39d0..954ccf06 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_logic.dart @@ -112,7 +112,7 @@ class RemoteUnlockingLogic extends BaseGetXController{ // 读取支持功能-带参数 Future _readSupportFunctionsNoParameters() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -139,7 +139,7 @@ class RemoteUnlockingLogic extends BaseGetXController{ // 设置支持功能(带参数) 远程开锁 Future sendBurglarAlarm() async { showEasyLoading(); - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); diff --git a/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_logic.dart index c1a2809f..cfcdc560 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_logic.dart @@ -114,7 +114,7 @@ class ResetButtonLogic extends BaseGetXController{ // 读取支持功能-带参数 Future _readSupportFunctionsNoParameters() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -141,7 +141,7 @@ class ResetButtonLogic extends BaseGetXController{ // 设置支持功能(带参数) Future sendBurglarAlarm() async { showEasyLoading(); - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { dismissEasyLoading(); var privateKey = await Storage.getStringList(saveBluePrivateKey); diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 0d9c6136..e62cb715 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -78,7 +78,7 @@ class LockDetailLogic extends BaseGetXController { state.electricQuantity.value = power; getLockRecordLastUploadDataTime(); - state.lockState.value = 2; + state.openLockBtnState.value = 0; state.animationController.reset(); state.animationController.forward(); // state.animationController.isCompleted; @@ -345,8 +345,13 @@ class LockDetailLogic extends BaseGetXController { // 点击开门事件 Future openDoorAction() async { - BlueManage().judgeReconnect(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (DeviceConnectionState deviceConnectionState) async { + showBlueConnetctToastTimer(); + BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (DeviceConnectionState deviceConnectionState) async { + cancelBlueConnetctToastTimer(); if (deviceConnectionState == DeviceConnectionState.connected){ + state.connectState.value = 1; + state.openLockBtnState.value = 0; + var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -369,11 +374,12 @@ class LockDetailLogic extends BaseGetXController { privateKey: getPrivateKeyList, ); }else if (deviceConnectionState == DeviceConnectionState.disconnected){ - if(state.lockState.value != 2){ - // 2的状态是从已经连接上了 然后没有进行任何操作 锁板主动断开了 所以只需要改变开锁按钮状态不需要弹出toast - Toast.show(msg: "连接设备失败,请确保在设备附近,设备未被连接,设备已打开"); - } - state.lockState.value = 4; + // if(state.lockState.value != 2){ + // // 2的状态是从已经连接上了 然后没有进行任何操作 锁板主动断开了 所以只需要改变开锁按钮状态不需要弹出toast + showBlueConnetctToast(); + // } + state.connectState.value = 0; + state.openLockBtnState.value = 0; state.animationController.reset(); state.animationController.forward(); } @@ -382,7 +388,7 @@ class LockDetailLogic extends BaseGetXController { // 编辑用户事件 // Future editLockUserAction() async { - // BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async { + // BlueManage().bludSendData(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async { // if (state == DeviceConnectionState.connected){ // var publicKey = await Storage.getStringList(saveBluePublicKey); // List publicKeyDataList = changeStringListToIntList(publicKey!); @@ -442,7 +448,7 @@ class LockDetailLogic extends BaseGetXController { // 查询事件记录(时间查询) Future senderReferEventRecordTime(int time) async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async { if (state == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); @@ -472,7 +478,7 @@ class LockDetailLogic extends BaseGetXController { // 添加用户(普通用户接收电子钥匙) Future addUserConnectBlue() async { // 进来之后首先连接 - BlueManage().judgeReconnect(BlueManage().connectDeviceName, + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { if (deviceConnectionState == DeviceConnectionState.connected) { // 私钥 @@ -508,15 +514,15 @@ class LockDetailLogic extends BaseGetXController { }); } - //开始连接 - startConnect() { - if(state.lockState.value == 4){ - // 当状态为4的时候,代表是已经连接过一次了,但是连接失败了,所以要重新连接 - state.lockState.value = 3; - }else{ + // 点击开锁 + startOpenLock() { + // if(state.lockState.value == 4){ + // // 当状态为4的时候,代表是已经连接过一次了,但是连接失败了,所以要重新连接 + // state.lockState.value = 3; + // }else{ // 其他代表是第一次连接 - state.lockState.value = 1; - } + state.openLockBtnState.value = 1; + // } state.animationController.forward(); if (state.lockUserNo == 0) { @@ -533,6 +539,10 @@ class LockDetailLogic extends BaseGetXController { } } + longPressCloseDoor(){ + + } + // 获取手机联网token,根据锁设置里面获取的开锁时是否联网来判断是否调用这个接口 void getLockNetToken() async { LockNetTokenEntity entity = await ApiRepository.to @@ -581,11 +591,11 @@ class LockDetailLogic extends BaseGetXController { // connectBlueAndAnimationController(){ // state.lockState.value = 1; // state.animationController.forward(); - // BlueManage().judgeReconnect(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (DeviceConnectionState deviceConnectionState) async { + // BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (DeviceConnectionState deviceConnectionState) async { // if (deviceConnectionState == DeviceConnectionState.connected){ // state.lockState.value = 2; // }else if (deviceConnectionState == DeviceConnectionState.disconnected){ - // Toast.show(msg: "连接设备失败,请确保在设备附近,设备未被连接,设备已打开"); + // showBlueConnetctToast(); // // state.lockState.value = 4; // state.animationController.reset(); @@ -597,7 +607,7 @@ class LockDetailLogic extends BaseGetXController { /// 锁设置里面开启关闭考勤刷新锁详情 StreamSubscription? _lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent; - void initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction() { + void _initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction() { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus _lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent = eventBus .on() @@ -621,8 +631,7 @@ class LockDetailLogic extends BaseGetXController { print("onReady()"); _initReplySubscription(); - initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction(); - + _initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction(); } @override diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart index a06cedd3..0f55bdb7 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; @@ -8,8 +7,8 @@ import '../../../appRouters.dart'; import '../../../app_settings/app_colors.dart'; import '../../../blue/blue_manage.dart'; import '../../../blue/io_tool/io_tool.dart'; +import '../../../tools/appRouteObserver.dart'; import '../../../tools/storage.dart'; -import '../../../tools/toast.dart'; import '../../../translations/trans_lib.dart'; import '../../lockMian/entity/lockListInfo_entity.dart'; import 'lockDetail_logic.dart'; @@ -44,25 +43,19 @@ class _LockDetailPageState extends State with TickerProviderStat state.isOpenLockNeedOnline.value = state.keyInfos.value.lockSetting!.appUnlockOnline!; state.electricQuantity.value = state.keyInfos.value.electricQuantity!; - BlueManage().connectDeviceName = - state.keyInfos.value.bluetooth!.bluetoothDeviceName!; - // BlueManage().connectDeviceMacAddress = - // state.keyInfos.value.bluetooth!.bluetoothDeviceId!; + BlueManage().connectDeviceName = state.keyInfos.value.bluetooth!.bluetoothDeviceName!; - List publicKeyData = - state.keyInfos.value.bluetooth!.publicKey!.cast(); + List publicKeyData = state.keyInfos.value.bluetooth!.publicKey!.cast(); var saveStrList = changeIntListToStringList(publicKeyData); Storage.setStringList(saveBluePublicKey, saveStrList); // 私钥 - List privateKeyData = - state.keyInfos.value.bluetooth!.privateKey!.cast(); + List privateKeyData = state.keyInfos.value.bluetooth!.privateKey!.cast(); var savePrivateKeyList = changeIntListToStringList(privateKeyData); Storage.setStringList(saveBluePrivateKey, savePrivateKeyList); // signKey - List signKeyData = - state.keyInfos.value.bluetooth!.signKey!.cast(); + List signKeyData = state.keyInfos.value.bluetooth!.signKey!.cast(); var saveSignKeyList = changeIntListToStringList(signKeyData); Storage.setStringList(saveBlueSignKey, saveSignKeyList); @@ -124,14 +117,14 @@ class _LockDetailPageState extends State with TickerProviderStat children: [ Center( child: GestureDetector( - child: Obx(() => Stack( + child: Obx(() => Stack( children: [ Image.asset( - (state.lockState.value == 4 || state.lockState.value == 3) ? 'images/main/icon_main_openLockBtn_grey.png' : 'images/main/icon_main_openLockBtn_center.png', + state.connectState.value == 0 ? 'images/main/icon_main_openLockBtn_grey.png' : 'images/main/icon_main_openLockBtn_center.png', width: 330.w, height: 330.w, ), - (state.lockState.value == 1 || state.lockState.value == 3) + state.openLockBtnState.value == 1 ? buildRotationTransition() : Positioned( child: Image.asset( @@ -141,9 +134,14 @@ class _LockDetailPageState extends State with TickerProviderStat )), ], )), - onTap: () { - logic.startConnect(); - }, + onTap: () { + Get.log("点击开锁"); + logic.startOpenLock(); + }, + onLongPressStart: (details) { + Get.log("长按开锁"); + // logic.startConnect(); + }, )), ], ), @@ -503,33 +501,41 @@ class _LockDetailPageState extends State with TickerProviderStat void dispose() { // TODO: implement dispose /// 取消路由订阅 - // AppRouteObserver().routeObserver.unsubscribe(this); + AppRouteObserver().routeObserver.unsubscribe(this); state.animationController.dispose(); super.dispose(); BlueManage().disconnect(BlueManage().connectDeviceMacAddress); } - /// + /// 从上级界面进入 当前界面即将出现 @override void didPush() { - print("LockDetailPage didPush"); + super.didPush(); + print("LockDetailPage===didPush"); } - /// Called when the current route has been popped off. + /// 返回上一个界面 当前界面即将消失 @override void didPop() { - print("LockDetailPage didPop"); + super.didPop(); + print("LockDetailPage===didPop"); + logic.cancelBlueConnetctToastTimer(); } - /// Called when the current route has been popped off. + /// 从下级返回 当前界面即将出现 @override void didPopNext() { - print("LockDetailPage didPopNext"); + super.didPopNext(); + print("LockDetailPage===didPopNext"); } - /// Called when the current route has been popped off. + /// 进入下级界面 当前界面即将消失 @override void didPushNext() { - print("LockDetailPage didPushNext"); + super.didPushNext(); + print("LockDetailPage===didPushNext"); + logic.cancelBlueConnetctToastTimer(); } + } + diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart index cd2c08ff..21073d3a 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart @@ -24,7 +24,11 @@ class LockDetailState { var isOpenLockNeedOnline = 0.obs; // APP开锁时是否需联网 var electricQuantity = 0.obs; // 电量 + var currentDeviceUUid = "".obs;// 当前设备的uuid + //过渡动画控制器 late AnimationController animationController; - var lockState = 0.obs;// 0未连接普通状态 1连接开锁中(展示动画) 2已连接开锁成功 3检测可用性 4连接失败 5连接失败重连中 + // var lockState = 0.obs;// 0未连接普通状态 1连接开锁中(展示动画) 2已连接开锁成功 3检测可用性 4连接失败 5连接失败重连中 + var openLockBtnState = 0.obs;// 0普通状态(未转动) 1连接中(转动状态) + var connectState = 0.obs;// 0未连接 1连接 } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart b/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart index c3d88de5..8168523b 100644 --- a/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart +++ b/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart @@ -132,7 +132,7 @@ class LockOperatingRecordLogic extends BaseGetXController{ // 查询事件记录(页数查询) // Future senderReferEventRecordNumber() async { - // BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async { + // BlueManage().bludSendData(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async { // if (state == DeviceConnectionState.connected) { // var privateKey = await Storage.getStringList(saveBluePrivateKey); // List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -159,7 +159,7 @@ class LockOperatingRecordLogic extends BaseGetXController{ // 查询事件记录(时间查询) Future senderReferEventRecordTime(int time) async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState state) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async { if (state == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); diff --git a/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_logic.dart b/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_logic.dart index 02528936..a4b04980 100644 --- a/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_logic.dart +++ b/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_logic.dart @@ -149,11 +149,9 @@ class LockMonitoringLogic extends BaseGetXController { Future startProcessing() async { frameListener(List frame) async { - // Get.log('Get data.length:${frame.length} Received data:$frame'); for (int i = 0; i < frame.length; i++) { frame[i] = linearToULaw(frame[i]); } - // Get.log('change Get data.length:${frame.length} change Received data:$frame'); await Future.delayed(const Duration(milliseconds: 50)); sendRecordData({ "bytes": frame, diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart index 3b5ed20a..4fc142eb 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart @@ -223,7 +223,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { // 设置自定义密码 Future senderCustomPasswords() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState state) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async { if (state == DeviceConnectionState.connected) { var publicKey = await Storage.getStringList(saveBluePublicKey); List publicKeyDataList = changeStringListToIntList(publicKey!); diff --git a/star_lock/lib/mine/addLock/lockAddress/lockAddress/lockAddress_page.dart b/star_lock/lib/mine/addLock/lockAddress/lockAddress/lockAddress_page.dart index 039f8709..df51e738 100644 --- a/star_lock/lib/mine/addLock/lockAddress/lockAddress/lockAddress_page.dart +++ b/star_lock/lib/mine/addLock/lockAddress/lockAddress/lockAddress_page.dart @@ -67,7 +67,7 @@ class _LockAddressPageState extends State with RouteAware{ void didChangeDependencies() { super.didChangeDependencies(); // 订阅 routeObserver,之后就会尝试调用抽象类 RouteAware 的方法 - routeObserver.subscribe(this, ModalRoute.of(context) as PageRoute); +// routeObserver.subscribe(this, ModalRoute.of(context) as PageRoute); } @override diff --git a/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart b/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart index faa911f8..a7c488aa 100644 --- a/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart +++ b/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart @@ -28,7 +28,7 @@ class NearbyLockLogic extends BaseGetXController { // 点击连接设备 void connect(String deviceName){ showEasyLoading(); - BlueManage().judgeReconnect(deviceName, (DeviceConnectionState state) async { + BlueManage().bludSendData(deviceName, (DeviceConnectionState state) async { if (state == DeviceConnectionState.connected) { IoSenderManage.getPublicKey(lockId: deviceName); }else if (state == DeviceConnectionState.disconnected) { @@ -322,7 +322,7 @@ class NearbyLockLogic extends BaseGetXController { Future _getStarLockStatus() async { // print("connectDeviceMacAddress:${BlueManage().connectDeviceMacAddress} connectDeviceName:${BlueManage().connectDeviceName}"); // 进来之后首先连接 - BlueManage().judgeReconnect(BlueManage().connectDeviceName, + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async { if (state == DeviceConnectionState.connected) { dismissEasyLoading(); diff --git a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart index 59b09a90..1ac9d0d0 100644 --- a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart +++ b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart @@ -106,7 +106,7 @@ class SaveLockLogic extends BaseGetXController { // print("111111"); // 进来之后首先连接 showEasyLoading(); - BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState state) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async { // print("222222"); if (state == DeviceConnectionState.connected){ // print("333333"); diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index 00bb99ef..b6ea9a69 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -1,6 +1,6 @@ abstract class Api { - // static String baseAddress = "https://pre.lock.star-lock.cn:8093"; //预发布环境 - static String baseAddress = "http://192.168.56.101:8099"; //联调环境 + static String baseAddress = "https://pre.lock.star-lock.cn:8093"; //预发布环境 + // static String baseAddress = "http://192.168.56.101:8099"; //联调环境 // static String baseAddress = "http://192.168.1.15:8022"; //谢总本地 final String baseUrl = "$baseAddress/api"; diff --git a/star_lock/lib/tools/baseGetXController.dart b/star_lock/lib/tools/baseGetXController.dart index 870fcc25..736fb17e 100644 --- a/star_lock/lib/tools/baseGetXController.dart +++ b/star_lock/lib/tools/baseGetXController.dart @@ -1,6 +1,7 @@ import 'dart:async'; +import 'package:async/async.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; @@ -44,9 +45,9 @@ class BaseGetXController extends GetxController{ Get.log('onClose -----> $runtimeType'); } - operationFailedCallBack(e){ - showOperationFailed(); - } + // operationFailedCallBack(e){ + // showOperationFailed(); + // } Future delay({Duration? duration,Function? something}) => Future.delayed(duration ?? 500. milliseconds,something as FutureOr Function()?); @@ -54,8 +55,31 @@ class BaseGetXController extends GetxController{ void dismissEasyLoading() => EasyLoading.dismiss(); + Timer? _timer; + // CancelableOperation? _operation; + void showBlueConnetctToastTimer() { + if(_timer != null && _timer!.isActive){ + _timer!.cancel(); + } + _timer = Timer.periodic(15.seconds, (timer) { + showBlueConnetctToast(); + }); + // _operation = CancelableOperation.fromFuture( + // Future.delayed(const Duration(seconds: 15), () { + // print('Operation completed'); + // showBlueConnetctToast(); + // }), + // ); + } + + void cancelBlueConnetctToastTimer() { + Get.log('cancelBlueConnetctToastTimer'); + if(_timer != null && _timer!.isActive) _timer!.cancel(); + // _operation?.cancel(); + } + void showBlueConnetctToast() { - showToast("未扫描到要连接的设备,请确保在设备附近,设备未被连接,设备已打开"); + showToast("连接设备失败,请确保在设备附近,设备未被连接,设备已打开"); } void showToast(String status,{Function? something}) { diff --git a/star_lock/pubspec.yaml b/star_lock/pubspec.yaml index bba33406..19bb29a6 100644 --- a/star_lock/pubspec.yaml +++ b/star_lock/pubspec.yaml @@ -38,6 +38,7 @@ dependencies: # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 + async: ^2.8.2 # 常用工具类 flustars: ^2.0.1 # 提示