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() {
_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,8 +180,8 @@ class BlueManage {
FlutterBluePlus.startScan(timeout: Duration(seconds: timeout));
Completer<dynamic> completer = Completer<dynamic>();
var subscription = FlutterBluePlus.scanResults.listen((results) {
Get.log("startScanSingle扫描到的设备:$results");
bool isExit = results.any((element) => element.device.platformName == deviceName);
print("startScanSingle扫描到的设备:$results");
bool isExit = results.any((element) => (element.device.platformName == deviceName) || (element.advertisementData.advName == deviceName));
if (isExit) {
for (var scanResult in results) {
if (((scanResult.advertisementData.serviceUuids.isNotEmpty
@ -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) || (d.advertisementData.advName == scanResult.advertisementData.advName));
// -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) || (d.advertisementData.advName == scanResult.advertisementData.advName));
// -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("开始扫描 蓝牙不可用,不能进行蓝牙操作");
}
});
}
@ -333,10 +333,10 @@ class BlueManage {
connectDeviceName = deviceName;
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) {
startScanSingle(deviceName, 10, (List<ScanResult> scanDevices) {
Get.log("扫描到的设备:$scanDevices");
print("扫描到的设备:$scanDevices");
devicesList = scanDevices;
_connectDevice(devicesList, deviceName, connectStateCallBack, isAddEquipment: isAddEquipment);
});
@ -349,27 +349,27 @@ class BlueManage {
List<ScanResult> 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) || (d.advertisementData.advName == deviceName));
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;
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 = <int>[];
@ -554,18 +554,18 @@ class BlueManage {
try {
List<int> 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;
}

View File

@ -164,7 +164,7 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
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: "",

View File

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

View File

@ -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];

View File

@ -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;
}
}

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.27+2024041101打包提审
# 1.0.27+2024041102打包预发布环境给田总测试
# 1.0.28+2024041702:打包给欧阳回归测试
# 1.0.28+2024041703:打包给欧阳回归测试
version: 1.0.28+2024041702
version: 1.0.28+2024041703
environment:
sdk: '>=2.12.0 <3.0.0'