Merge branch 'master' of gitee.com:starlock-cn/app-starlock

This commit is contained in:
Daisy 2024-04-18 15:46:41 +08:00
commit 7b1bda144f
6 changed files with 51 additions and 49 deletions

View File

@ -89,7 +89,7 @@ class BlueManage {
void _initGetMtuSubscription() { void _initGetMtuSubscription() {
_mtuSubscription ??= bluetoothConnectDevice!.mtu.listen((value) { _mtuSubscription ??= bluetoothConnectDevice!.mtu.listen((value) {
_mtuSize = value - 3; _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 { _connectionStateSubscription = bluetoothConnectDevice!.connectionState.listen((state) async {
bluetoothConnectionState = state; bluetoothConnectionState = state;
Get.log("蓝牙连接状态:$state"); print("蓝牙连接状态:$state");
}); });
} }
@ -160,11 +160,11 @@ class BlueManage {
try { try {
} catch (e) { } catch (e) {
Get.log("Error Turning On:"); print("Error Turning On:");
} }
} }
} else { } else {
Get.log("写入数据 蓝牙不可用,不能进行蓝牙操作"); print("写入数据 蓝牙不可用,不能进行蓝牙操作");
} }
}); });
} }
@ -180,8 +180,8 @@ class BlueManage {
FlutterBluePlus.startScan(timeout: Duration(seconds: timeout)); FlutterBluePlus.startScan(timeout: Duration(seconds: timeout));
Completer<dynamic> completer = Completer<dynamic>(); Completer<dynamic> completer = Completer<dynamic>();
var subscription = FlutterBluePlus.scanResults.listen((results) { var subscription = FlutterBluePlus.scanResults.listen((results) {
Get.log("startScanSingle扫描到的设备:$results"); print("startScanSingle扫描到的设备:$results");
bool isExit = results.any((element) => element.device.platformName == deviceName); bool isExit = results.any((element) => (element.device.platformName == deviceName) || (element.advertisementData.advName == deviceName));
if (isExit) { if (isExit) {
for (var scanResult in results) { for (var scanResult in results) {
if (((scanResult.advertisementData.serviceUuids.isNotEmpty if (((scanResult.advertisementData.serviceUuids.isNotEmpty
@ -192,7 +192,7 @@ class BlueManage {
(scanResult.rssi >= -100)) { (scanResult.rssi >= -100)) {
// id相同的元素 // id相同的元素
final knownDeviceIndex = scanDevices final knownDeviceIndex = scanDevices
.indexWhere((d) => d.advertisementData.advName == scanResult.advertisementData.advName); .indexWhere((d) => (d.device.platformName == scanResult.device.platformName) || (d.advertisementData.advName == scanResult.advertisementData.advName));
// -1 // -1
if (knownDeviceIndex >= 0) { if (knownDeviceIndex >= 0) {
scanDevices[knownDeviceIndex] = scanResult; scanDevices[knownDeviceIndex] = scanResult;
@ -204,7 +204,7 @@ class BlueManage {
completer.complete(); completer.complete();
} }
}, onError: (e) { }, onError: (e) {
Get.log( print(
"Scan Error:$e", "Scan Error:$e",
); );
}); });
@ -213,7 +213,7 @@ class BlueManage {
scanDevicesCallBack(scanDevices); scanDevicesCallBack(scanDevices);
subscription.cancel(); subscription.cancel();
} catch (e) { } catch (e) {
Get.log("扫描失败"); print("扫描失败");
} }
} else { } else {
try { try {
@ -221,11 +221,11 @@ class BlueManage {
await FlutterBluePlus.turnOn(); await FlutterBluePlus.turnOn();
} }
} catch (e) { } catch (e) {
Get.log("Error Turning On:"); print("Error Turning On:");
} }
} }
} else { } else {
Get.log("开始扫描 蓝牙不可用,不能进行蓝牙操作"); print("开始扫描 蓝牙不可用,不能进行蓝牙操作");
} }
}); });
} }
@ -256,7 +256,7 @@ class BlueManage {
(scanResult.rssi >= -100)) { (scanResult.rssi >= -100)) {
// id相同的元素 // id相同的元素
final knownDeviceIndex = scanDevices final knownDeviceIndex = scanDevices
.indexWhere((d) => d.advertisementData.advName == scanResult.advertisementData.advName); .indexWhere((d) => (d.device.platformName == scanResult.device.platformName) || (d.advertisementData.advName == scanResult.advertisementData.advName));
// -1 // -1
if (knownDeviceIndex >= 0) { if (knownDeviceIndex >= 0) {
scanDevices[knownDeviceIndex] = scanResult; scanDevices[knownDeviceIndex] = scanResult;
@ -269,14 +269,14 @@ class BlueManage {
// EventBusManager().eventBusFir(scanDevices); // EventBusManager().eventBusFir(scanDevices);
// FlutterBluePlus.stopScan(); // FlutterBluePlus.stopScan();
}, onError: (e) { }, onError: (e) {
Get.log( print(
"Scan Error:$e", "Scan Error:$e",
); );
}); });
FlutterBluePlus.cancelWhenScanComplete(subscription); FlutterBluePlus.cancelWhenScanComplete(subscription);
} catch (e) { } catch (e) {
Get.log("扫描失败"); print("扫描失败");
} }
} else { } else {
try { try {
@ -284,7 +284,7 @@ class BlueManage {
await FlutterBluePlus.turnOn(); await FlutterBluePlus.turnOn();
} }
} catch (e) { } catch (e) {
Get.log("Error Turning On:"); print("Error Turning On:");
} }
} }
; ;
@ -318,11 +318,11 @@ class BlueManage {
stateCallBack(BluetoothConnectionState.disconnected); stateCallBack(BluetoothConnectionState.disconnected);
openBlue(); openBlue();
} catch (e) { } catch (e) {
Get.log("Error Turning On:"); print("Error Turning On:");
} }
} }
} else { } else {
Get.log("开始扫描 蓝牙不可用,不能进行蓝牙操作"); print("开始扫描 蓝牙不可用,不能进行蓝牙操作");
} }
}); });
} }
@ -333,10 +333,10 @@ class BlueManage {
connectDeviceName = deviceName; connectDeviceName = deviceName;
List<ScanResult> devicesList = scanDevices; List<ScanResult> devicesList = scanDevices;
// //
bool isExistDevice = scanDevices.any((element) => element.device.platformName == connectDeviceName); bool isExistDevice = scanDevices.any((element) => element.device.platformName == connectDeviceName || element.advertisementData.advName == connectDeviceName);
if (isAddEquipment == false && isExistDevice == false) { if (isAddEquipment == false && isExistDevice == false) {
startScanSingle(deviceName, 10, (List<ScanResult> scanDevices) { startScanSingle(deviceName, 10, (List<ScanResult> scanDevices) {
Get.log("扫描到的设备:$scanDevices"); print("扫描到的设备:$scanDevices");
devicesList = scanDevices; devicesList = scanDevices;
_connectDevice(devicesList, deviceName, connectStateCallBack, isAddEquipment: isAddEquipment); _connectDevice(devicesList, deviceName, connectStateCallBack, isAddEquipment: isAddEquipment);
}); });
@ -349,27 +349,27 @@ class BlueManage {
List<ScanResult> devicesList, String deviceName, ConnectStateCallBack connectStateCallBack, List<ScanResult> devicesList, String deviceName, ConnectStateCallBack connectStateCallBack,
{bool isAddEquipment = false}) async { {bool isAddEquipment = false}) async {
// //
Get.log("devicesList:$devicesList"); print("devicesList:$devicesList");
final knownDeviceIndex = devicesList.indexWhere((d) => d.advertisementData.advName == deviceName); final knownDeviceIndex = devicesList.indexWhere((d) => (d.device.platformName == deviceName) || (d.advertisementData.advName == deviceName));
if (knownDeviceIndex >= 0) { if (knownDeviceIndex >= 0) {
// //
connectDeviceMacAddress = devicesList[knownDeviceIndex].advertisementData.advName; connectDeviceMacAddress = devicesList[knownDeviceIndex].advertisementData.advName.isNotEmpty ? devicesList[knownDeviceIndex].advertisementData.advName : devicesList[knownDeviceIndex].device.platformName;
bluetoothConnectDevice = devicesList[knownDeviceIndex].device; bluetoothConnectDevice = devicesList[knownDeviceIndex].device;
Get.log('bluetoothConnectDevice: $bluetoothConnectDevice'); print('bluetoothConnectDevice: $bluetoothConnectDevice');
scanResult = devicesList[knownDeviceIndex]; scanResult = devicesList[knownDeviceIndex];
_initGetMtuSubscription(); _initGetMtuSubscription();
_initListenConnectionState(); _initListenConnectionState();
} }
Get.log("1 connectDeviceId:$connectDeviceMacAddress connectDeviceName:$connectDeviceName"); print("1 connectDeviceId:$connectDeviceMacAddress connectDeviceName:$connectDeviceName");
// stopScan(); // stopScan();
if (connectDeviceMacAddress.isEmpty) { if (connectDeviceMacAddress.isEmpty) {
// connectStateCallBack(BluetoothConnectionState.disconnected!); // connectStateCallBack(BluetoothConnectionState.disconnected!);
return; return;
} }
Get.log("调用了停止扫描的方法"); print("调用了停止扫描的方法");
await stopScan(); await stopScan();
if ((scanResult!.advertisementData.serviceUuids[0].toString()[31] == "0") && isAddEquipment == false) { if ((scanResult!.advertisementData.serviceUuids[0].toString()[31] == "0") && isAddEquipment == false) {
@ -386,16 +386,16 @@ class BlueManage {
await bluetoothConnectDevice!.connect(timeout: 5.seconds); await bluetoothConnectDevice!.connect(timeout: 5.seconds);
break; // If the connection is successful, break the loop break; // If the connection is successful, break the loop
} catch (e) { } catch (e) {
Get.log('Failed to connect: $e'); print('Failed to connect: $e');
attempt++; // Increase the attempt count attempt++; // Increase the attempt count
if (attempt < maxAttempts) { if (attempt < maxAttempts) {
Get.log('Retrying connection...'); print('Retrying connection...');
} }
} }
} }
if (attempt >= maxAttempts) { if (attempt >= maxAttempts) {
Get.log('Failed to connect after $maxAttempts attempts.'); print('Failed to connect after $maxAttempts attempts.');
connectStateCallBack(BluetoothConnectionState.disconnected); connectStateCallBack(BluetoothConnectionState.disconnected);
} }
@ -404,7 +404,7 @@ class BlueManage {
try { try {
bluetoothConnectDevice!.discoverServices().then((services) { bluetoothConnectDevice!.discoverServices().then((services) {
for (BluetoothService service in services) { for (BluetoothService service in services) {
Get.log("11111service.remoteId:${service.remoteId}" print("11111service.remoteId:${service.remoteId}"
" service.uuid:${service.uuid}" " service.uuid:${service.uuid}"
" service.characteristics:${service.characteristics}" " service.characteristics:${service.characteristics}"
" service.includedServices:${service.includedServices}"); " service.includedServices:${service.includedServices}");
@ -416,7 +416,7 @@ class BlueManage {
// " characteristic.characteristicUuid:${characteristic.characteristicUuid}"); // " characteristic.characteristicUuid:${characteristic.characteristicUuid}");
if (characteristic.characteristicUuid == _characteristicIdSubscription) { if (characteristic.characteristicUuid == _characteristicIdSubscription) {
_subScribeToCharacteristic(characteristic); _subScribeToCharacteristic(characteristic);
Get.log('Discovering services finished'); print('Discovering services finished');
bluetoothConnectionState = BluetoothConnectionState.connected; bluetoothConnectionState = BluetoothConnectionState.connected;
connectStateCallBack(bluetoothConnectionState!); connectStateCallBack(bluetoothConnectionState!);
} }
@ -426,9 +426,9 @@ class BlueManage {
}); });
} on Exception catch (e) { } on Exception catch (e) {
bluetoothConnectionState = BluetoothConnectionState.disconnected; bluetoothConnectionState = BluetoothConnectionState.disconnected;
Get.log("5555 回调状态:$bluetoothConnectionState"); print("5555 回调状态:$bluetoothConnectionState");
connectStateCallBack(bluetoothConnectionState!); connectStateCallBack(bluetoothConnectionState!);
Get.log('Error occurred when discovering services: $e'); print('Error occurred when discovering services: $e');
rethrow; rethrow;
} }
} }
@ -444,26 +444,26 @@ class BlueManage {
_subScribeToCharacteristic(BluetoothCharacteristic characteristic) async { _subScribeToCharacteristic(BluetoothCharacteristic characteristic) async {
final subscription = characteristic.onValueReceived.listen((data) { final subscription = characteristic.onValueReceived.listen((data) {
// Get.log("启动对特性的通知。当特性的值发生变化时,设备会发送一个通知"); // Get.log("启动对特性的通知。当特性的值发生变化时,设备会发送一个通知");
Get.log("订阅获取的数据:$data"); print("订阅获取的数据:$data");
if (data == lastTimeData || data.isEmpty) { if (data == lastTimeData || data.isEmpty) {
return; return;
} else { } else {
lastTimeData = data; lastTimeData = data;
} }
// code to handle incoming 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)) { if ((data[0] == 0xEF) && (data[1] == 0x01) && (data[2] == 0xEE) && (data[3] == 0x02)) {
// //
// //
dataLen = data[8] * 256 + data[9]; // 16 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) { if (dataLen! + 12 > data.length) {
// //
allData.addAll(data); allData.addAll(data);
} else { } else {
// //
allData.addAll(data); allData.addAll(data);
Get.log("dataLen2222:$dataLen getDataLength:${data.length}"); print("dataLen2222:$dataLen getDataLength:${data.length}");
CommandReciverManager.appDataReceive(allData); CommandReciverManager.appDataReceive(allData);
// //
allData = <int>[]; allData = <int>[];
@ -554,18 +554,18 @@ class BlueManage {
try { try {
List<int> valueList = value; List<int> valueList = value;
List subData = splitList(valueList, _mtuSize!); List subData = splitList(valueList, _mtuSize!);
Get.log('writeCharacteristicWithResponse _mtuSize:$_mtuSize 得到的分割数据:$subData'); print('writeCharacteristicWithResponse _mtuSize:$_mtuSize 得到的分割数据:$subData');
for (int i = 0; i < subData.length; i++) { for (int i = 0; i < subData.length; i++) {
await characteristic.write(subData[i]).then((value) async { await characteristic.write(subData[i]).then((value) async {
await Future.delayed(const Duration(milliseconds: 1)).then(( await Future.delayed(const Duration(milliseconds: 1)).then((
value) async { value) async {
Get.log('分包发送成功了'); print('分包发送成功了');
}); });
}); });
} }
} on Exception catch (e, s) { } on Exception catch (e, s) {
Get.log('Error occurred when writing: $e'); print('Error occurred when writing: $e');
// Get.log(s); // Get.log(s);
rethrow; rethrow;
} }
@ -630,7 +630,7 @@ class BlueManage {
try { try {
await FlutterBluePlus.stopScan(); await FlutterBluePlus.stopScan();
} catch (e) { } catch (e) {
Get.log("停止扫描失败"); print("停止扫描失败");
} }
} }
@ -641,11 +641,11 @@ class BlueManage {
connectDeviceMacAddress = ""; connectDeviceMacAddress = "";
if (bluetoothConnectionState == BluetoothConnectionState.connected) { if (bluetoothConnectionState == BluetoothConnectionState.connected) {
await bluetoothConnectDevice!.disconnect(); await bluetoothConnectDevice!.disconnect();
Get.log("断开连接成功"); print("断开连接成功");
} }
// } // }
} on Exception catch (e, _) { } on Exception catch (e, _) {
Get.log("Error disconnecting from a device: $e"); print("Error disconnecting from a device: $e");
} finally { } finally {
bluetoothConnectionState = BluetoothConnectionState.disconnected; bluetoothConnectionState = BluetoothConnectionState.disconnected;
} }

View File

@ -164,7 +164,7 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
child: _onlyManageYouCreatesUserSwitch())), child: _onlyManageYouCreatesUserSwitch())),
), ),
Visibility(// (state.keyInfo.value.lockSetting!.remoteUnlock == 1 ? true : false 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( child: CommonItem(
leftTitel: "远程开锁".tr, leftTitel: "远程开锁".tr,
rightTitle: "", rightTitle: "",

View File

@ -39,7 +39,8 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget {
LockListInfoGroupEntity? lockListInfoGroupEntity = await Storage.getLockMainListData(); LockListInfoGroupEntity? lockListInfoGroupEntity = await Storage.getLockMainListData();
// Get.log("lockListInfoGroupEntity:${lockListInfoGroupEntity!.groupList!.length}"); // Get.log("lockListInfoGroupEntity:${lockListInfoGroupEntity!.groupList!.length}");
if (lockListInfoGroupEntity != null) { if (lockListInfoGroupEntity != null) {
logic.loadMainDataLogic(lockListInfoGroupEntity).then((value) { var localLockListInfoGroupEntity = lockListInfoGroupEntity;
logic.loadMainDataLogic(localLockListInfoGroupEntity).then((value) {
if (mounted) { if (mounted) {
setState(() {}); setState(() {});
} }

View File

@ -140,9 +140,10 @@ class NearbyLockLogic extends BaseGetXController {
// //
var vendor = reply.data.sublist(3, 23); var vendor = reply.data.sublist(3, 23);
Get.log("vendor:$vendor reply.data:${reply.data}");
var vendorStr = utf8String(vendor); 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]; var product = reply.data[23];

View File

@ -172,7 +172,7 @@ class DateTool {
DateTime now = DateTime.now(); // DateTime now = DateTime.now(); //
Duration difference = dateTime.difference(now); // Duration difference = dateTime.difference(now); //
int days = difference.inDays; // 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; return days;
} }
} }

View File

@ -31,9 +31,9 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# 1.0.26+20240408打包预发布环境给欧阳测试 # 1.0.26+20240408打包预发布环境给欧阳测试
# 1.0.27+2024041101打包提审 # 1.0.27+2024041101打包提审
# 1.0.27+2024041102打包预发布环境给田总测试 # 1.0.27+2024041102打包预发布环境给田总测试
# 1.0.28+2024041702:打包给欧阳回归测试 # 1.0.28+2024041703:打包给欧阳回归测试
version: 1.0.28+2024041702 version: 1.0.28+2024041703
environment: environment:
sdk: '>=2.12.0 <3.0.0' sdk: '>=2.12.0 <3.0.0'