diff --git a/star_lock/lib/blue/blue_manage.dart b/star_lock/lib/blue/blue_manage.dart index 70e1ed83..869d005b 100644 --- a/star_lock/lib/blue/blue_manage.dart +++ b/star_lock/lib/blue/blue_manage.dart @@ -89,7 +89,7 @@ class BlueManage { void _initGetMtuSubscription() { _mtuSubscription ??= bluetoothConnectDevice!.mtu.listen((value) { _mtuSize = value - 3; - Get.log('_mtuSizeValue:$value mtuSize:$_mtuSize'); + print('_mtuSizeValue:$value mtuSize:$_mtuSize'); }); } @@ -144,7 +144,7 @@ class BlueManage { _connectionStateSubscription = bluetoothConnectDevice!.connectionState.listen((state) async { bluetoothConnectionState = state; - Get.log("蓝牙连接状态:$state"); + print("蓝牙连接状态:$state"); }); } @@ -160,11 +160,11 @@ class BlueManage { try { } catch (e) { - Get.log("Error Turning On:"); + print("Error Turning On:"); } } } else { - Get.log("写入数据 蓝牙不可用,不能进行蓝牙操作"); + print("写入数据 蓝牙不可用,不能进行蓝牙操作"); } }); } @@ -180,7 +180,7 @@ class BlueManage { FlutterBluePlus.startScan(timeout: Duration(seconds: timeout)); Completer completer = Completer(); var subscription = FlutterBluePlus.scanResults.listen((results) { - Get.log("startScanSingle扫描到的设备:$results"); + print("startScanSingle扫描到的设备:$results"); bool isExit = results.any((element) => element.device.platformName == deviceName); if (isExit) { for (var scanResult in results) { @@ -192,7 +192,7 @@ class BlueManage { (scanResult.rssi >= -100)) { // 查询id相同的元素 final knownDeviceIndex = scanDevices - .indexWhere((d) => d.advertisementData.advName == scanResult.advertisementData.advName); + .indexWhere((d) => d.device.platformName == scanResult.device.platformName); // 不存在的时候返回-1 if (knownDeviceIndex >= 0) { scanDevices[knownDeviceIndex] = scanResult; @@ -204,7 +204,7 @@ class BlueManage { completer.complete(); } }, onError: (e) { - Get.log( + print( "Scan Error:$e", ); }); @@ -213,7 +213,7 @@ class BlueManage { scanDevicesCallBack(scanDevices); subscription.cancel(); } catch (e) { - Get.log("扫描失败"); + print("扫描失败"); } } else { try { @@ -221,11 +221,11 @@ class BlueManage { await FlutterBluePlus.turnOn(); } } catch (e) { - Get.log("Error Turning On:"); + print("Error Turning On:"); } } } else { - Get.log("开始扫描 蓝牙不可用,不能进行蓝牙操作"); + print("开始扫描 蓝牙不可用,不能进行蓝牙操作"); } }); } @@ -256,7 +256,7 @@ class BlueManage { (scanResult.rssi >= -100)) { // 查询id相同的元素 final knownDeviceIndex = scanDevices - .indexWhere((d) => d.advertisementData.advName == scanResult.advertisementData.advName); + .indexWhere((d) => d.device.platformName == scanResult.device.platformName); // 不存在的时候返回-1 if (knownDeviceIndex >= 0) { scanDevices[knownDeviceIndex] = scanResult; @@ -269,14 +269,14 @@ class BlueManage { // EventBusManager().eventBusFir(scanDevices); // FlutterBluePlus.stopScan(); }, onError: (e) { - Get.log( + print( "Scan Error:$e", ); }); FlutterBluePlus.cancelWhenScanComplete(subscription); } catch (e) { - Get.log("扫描失败"); + print("扫描失败"); } } else { try { @@ -284,7 +284,7 @@ class BlueManage { await FlutterBluePlus.turnOn(); } } catch (e) { - Get.log("Error Turning On:"); + print("Error Turning On:"); } } ; @@ -318,11 +318,11 @@ class BlueManage { stateCallBack(BluetoothConnectionState.disconnected); openBlue(); } catch (e) { - Get.log("Error Turning On:"); + print("Error Turning On:"); } } } else { - Get.log("开始扫描 蓝牙不可用,不能进行蓝牙操作"); + print("开始扫描 蓝牙不可用,不能进行蓝牙操作"); } }); } @@ -336,7 +336,7 @@ class BlueManage { bool isExistDevice = scanDevices.any((element) => element.device.platformName == connectDeviceName); if (isAddEquipment == false && isExistDevice == false) { startScanSingle(deviceName, 10, (List scanDevices) { - Get.log("扫描到的设备:$scanDevices"); + print("扫描到的设备:$scanDevices"); devicesList = scanDevices; _connectDevice(devicesList, deviceName, connectStateCallBack, isAddEquipment: isAddEquipment); }); @@ -349,27 +349,27 @@ class BlueManage { List devicesList, String deviceName, ConnectStateCallBack connectStateCallBack, {bool isAddEquipment = false}) async { // 判断数组列表里面是否有这个设备 - Get.log("devicesList:$devicesList"); - final knownDeviceIndex = devicesList.indexWhere((d) => d.advertisementData.advName == deviceName); + print("devicesList:$devicesList"); + final knownDeviceIndex = devicesList.indexWhere((d) => d.device.platformName == deviceName); if (knownDeviceIndex >= 0) { // 存在的时候赋值 - connectDeviceMacAddress = devicesList[knownDeviceIndex].advertisementData.advName; + connectDeviceMacAddress = devicesList[knownDeviceIndex].device.platformName; bluetoothConnectDevice = devicesList[knownDeviceIndex].device; - Get.log('bluetoothConnectDevice: $bluetoothConnectDevice'); + print('bluetoothConnectDevice: $bluetoothConnectDevice'); scanResult = devicesList[knownDeviceIndex]; _initGetMtuSubscription(); _initListenConnectionState(); } - Get.log("1 connectDeviceId:$connectDeviceMacAddress connectDeviceName:$connectDeviceName"); + print("1 connectDeviceId:$connectDeviceMacAddress connectDeviceName:$connectDeviceName"); // stopScan(); if (connectDeviceMacAddress.isEmpty) { // connectStateCallBack(BluetoothConnectionState.disconnected!); return; } - Get.log("调用了停止扫描的方法"); + print("调用了停止扫描的方法"); await stopScan(); if ((scanResult!.advertisementData.serviceUuids[0].toString()[31] == "0") && isAddEquipment == false) { @@ -386,16 +386,16 @@ class BlueManage { await bluetoothConnectDevice!.connect(timeout: 5.seconds); break; // If the connection is successful, break the loop } catch (e) { - Get.log('Failed to connect: $e'); + print('Failed to connect: $e'); attempt++; // Increase the attempt count if (attempt < maxAttempts) { - Get.log('Retrying connection...'); + print('Retrying connection...'); } } } if (attempt >= maxAttempts) { - Get.log('Failed to connect after $maxAttempts attempts.'); + print('Failed to connect after $maxAttempts attempts.'); connectStateCallBack(BluetoothConnectionState.disconnected); } @@ -404,7 +404,7 @@ class BlueManage { try { bluetoothConnectDevice!.discoverServices().then((services) { for (BluetoothService service in services) { - Get.log("11111service.remoteId:${service.remoteId}" + print("11111service.remoteId:${service.remoteId}" " service.uuid:${service.uuid}" " service.characteristics:${service.characteristics}" " service.includedServices:${service.includedServices}"); @@ -416,7 +416,7 @@ class BlueManage { // " characteristic.characteristicUuid:${characteristic.characteristicUuid}"); if (characteristic.characteristicUuid == _characteristicIdSubscription) { _subScribeToCharacteristic(characteristic); - Get.log('Discovering services finished'); + print('Discovering services finished'); bluetoothConnectionState = BluetoothConnectionState.connected; connectStateCallBack(bluetoothConnectionState!); } @@ -426,9 +426,9 @@ class BlueManage { }); } on Exception catch (e) { bluetoothConnectionState = BluetoothConnectionState.disconnected; - Get.log("5555 回调状态:$bluetoothConnectionState"); + print("5555 回调状态:$bluetoothConnectionState"); connectStateCallBack(bluetoothConnectionState!); - Get.log('Error occurred when discovering services: $e'); + print('Error occurred when discovering services: $e'); rethrow; } } @@ -444,26 +444,26 @@ class BlueManage { _subScribeToCharacteristic(BluetoothCharacteristic characteristic) async { final subscription = characteristic.onValueReceived.listen((data) { // Get.log("启动对特性的通知。当特性的值发生变化时,设备会发送一个通知"); - Get.log("订阅获取的数据:$data"); + print("订阅获取的数据:$data"); if (data == lastTimeData || data.isEmpty) { return; } else { lastTimeData = data; } // code to handle incoming data - // Get.log("subscribeToCharacteristic: deviceId = ${characteristic.deviceId} characteristicId =${characteristic.characteristicId}---上报来的数据data = $data"); + // print("subscribeToCharacteristic: deviceId = ${characteristic.deviceId} characteristicId =${characteristic.characteristicId}---上报来的数据data = $data"); if ((data[0] == 0xEF) && (data[1] == 0x01) && (data[2] == 0xEE) && (data[3] == 0x02)) { // 当包有头时 // 判断是否需要分包 dataLen = data[8] * 256 + data[9]; // 高16位用来指示后面数据块内容的长度 - Get.log("dataLen1111:$dataLen getDataLength:${data.length} data:$data"); + print("dataLen1111:$dataLen getDataLength:${data.length} data:$data"); if (dataLen! + 12 > data.length) { // 当前包的长度小于实际的包时 分包添加 不解析 allData.addAll(data); } else { // 当前包的长度小于实际的包时 不分包 解析 allData.addAll(data); - Get.log("dataLen2222:$dataLen getDataLength:${data.length}"); + print("dataLen2222:$dataLen getDataLength:${data.length}"); CommandReciverManager.appDataReceive(allData); // 发送完解析初始化数组 allData = []; @@ -554,18 +554,18 @@ class BlueManage { try { List valueList = value; List subData = splitList(valueList, _mtuSize!); - Get.log('writeCharacteristicWithResponse _mtuSize:$_mtuSize 得到的分割数据:$subData'); + print('writeCharacteristicWithResponse _mtuSize:$_mtuSize 得到的分割数据:$subData'); for (int i = 0; i < subData.length; i++) { await characteristic.write(subData[i]).then((value) async { await Future.delayed(const Duration(milliseconds: 1)).then(( value) async { - Get.log('分包发送成功了'); + print('分包发送成功了'); }); }); } } on Exception catch (e, s) { - Get.log('Error occurred when writing: $e'); + print('Error occurred when writing: $e'); // Get.log(s); rethrow; } @@ -630,7 +630,7 @@ class BlueManage { try { await FlutterBluePlus.stopScan(); } catch (e) { - Get.log("停止扫描失败"); + print("停止扫描失败"); } } @@ -641,11 +641,11 @@ class BlueManage { connectDeviceMacAddress = ""; if (bluetoothConnectionState == BluetoothConnectionState.connected) { await bluetoothConnectDevice!.disconnect(); - Get.log("断开连接成功"); + print("断开连接成功"); } // } } on Exception catch (e, _) { - Get.log("Error disconnecting from a device: $e"); + print("Error disconnecting from a device: $e"); } finally { bluetoothConnectionState = BluetoothConnectionState.disconnected; } diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart index 7916e5e9..a5432bbe 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart @@ -164,7 +164,7 @@ class _ElectronicKeyDetailPageState extends State { child: _onlyManageYouCreatesUserSwitch())), ), Visibility(// (state.keyInfo.value.lockSetting!.remoteUnlock == 1 ? true : false - visible: state.keyInfo.value.lockSetting!.remoteUnlock == 1 ? true:false, + visible: state.keyInfo.value.lockSetting!.remoteUnlock == 1 && state.itemData.value.keyRight != 1 ? true:false, child: CommonItem( leftTitel: "远程开锁".tr, rightTitle: "", diff --git a/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart b/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart index 675fdb6e..f76d56d6 100644 --- a/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart +++ b/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart @@ -140,9 +140,10 @@ class NearbyLockLogic extends BaseGetXController { // 厂商名称 var vendor = reply.data.sublist(3, 23); - Get.log("vendor:$vendor reply.data:${reply.data}"); var vendorStr = utf8String(vendor); - state.lockInfo["vendor"] = vendorStr; + // state.lockInfo["vendor"] = vendorStr; + state.lockInfo["vendor"] = "XL"; + Get.log("vendor:$vendor vendorStr:$vendorStr reply.data:${reply.data}"); // 锁设备类型 var product = reply.data[23]; diff --git a/star_lock/lib/tools/dateTool.dart b/star_lock/lib/tools/dateTool.dart index 8091ce0e..2a385a32 100644 --- a/star_lock/lib/tools/dateTool.dart +++ b/star_lock/lib/tools/dateTool.dart @@ -172,7 +172,7 @@ class DateTool { DateTime now = DateTime.now(); // 获取当前时间 Duration difference = dateTime.difference(now); // 计算两个日期之间的差异 int days = difference.inDays; // 获取差异的天数 - print('dateTime:$dateTime now:$now The difference is $days days.'); + // print('dateTime:$dateTime now:$now The difference is $days days.'); return days; } } \ No newline at end of file