fix:修复开锁的问题,以及操作记录重复上传的问题。
This commit is contained in:
parent
bc31d7d651
commit
b067e8a22e
@ -14,6 +14,7 @@ class AppLog {
|
|||||||
_onlyError = onlyError ?? false;
|
_onlyError = onlyError ?? false;
|
||||||
}
|
}
|
||||||
static log(String msg,{bool? error}){
|
static log(String msg,{bool? error}){
|
||||||
|
msg = '${DateTime.now().toIso8601String()} : $msg';
|
||||||
DebugConsole.info(msg);
|
DebugConsole.info(msg);
|
||||||
if(!kDebugMode)return;
|
if(!kDebugMode)return;
|
||||||
error = error ?? false;
|
error = error ?? false;
|
||||||
|
|||||||
@ -623,7 +623,7 @@ class BlueManage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
AppLog.log('APP写入失败: $e');
|
AppLog.log('APP写入失败: $e $s');
|
||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -654,6 +654,30 @@ class BlueManage {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 写入
|
||||||
|
Future<void> writeNull() async {
|
||||||
|
List<BluetoothService> services =
|
||||||
|
await bluetoothConnectDevice!.discoverServices();
|
||||||
|
for (BluetoothService service in services) {
|
||||||
|
if (service.uuid == _serviceIdConnect) {
|
||||||
|
for (BluetoothCharacteristic characteristic
|
||||||
|
in service.characteristics) {
|
||||||
|
|
||||||
|
if (characteristic.characteristicUuid == _characteristicIdWrite) {
|
||||||
|
try {
|
||||||
|
List<int> valueList = [1];
|
||||||
|
AppLog.log('APP写入 writeNull ');
|
||||||
|
await characteristic.write(valueList);
|
||||||
|
} on Exception catch (e, s) {
|
||||||
|
AppLog.log('APP写入失败 writeNull : $e $s');
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 读取
|
// 读取
|
||||||
// Future<List<int>> _readCharacteristic(QualifiedCharacteristic characteristic) async {
|
// Future<List<int>> _readCharacteristic(QualifiedCharacteristic characteristic) async {
|
||||||
// try {
|
// try {
|
||||||
@ -696,6 +720,8 @@ class BlueManage {
|
|||||||
// if(bluetoothConnectDevice != null && bluetoothConnectDevice!.connectionState == BluetoothConnectionState.connected){
|
// if(bluetoothConnectDevice != null && bluetoothConnectDevice!.connectionState == BluetoothConnectionState.connected){
|
||||||
connectDeviceMacAddress = "";
|
connectDeviceMacAddress = "";
|
||||||
if (bluetoothConnectionState == BluetoothConnectionState.connected) {
|
if (bluetoothConnectionState == BluetoothConnectionState.connected) {
|
||||||
|
// await writeNull();
|
||||||
|
// await Future.delayed(const Duration(milliseconds: 1000));
|
||||||
//加快蓝牙断连
|
//加快蓝牙断连
|
||||||
await bluetoothConnectDevice!.disconnect(timeout: 2);
|
await bluetoothConnectDevice!.disconnect(timeout: 2);
|
||||||
AppLog.log("断开连接成功");
|
AppLog.log("断开连接成功");
|
||||||
|
|||||||
@ -35,7 +35,8 @@ abstract class SenderProtocol extends IOData {
|
|||||||
|
|
||||||
void printLog(List<int> data) {
|
void printLog(List<int> data) {
|
||||||
AppLog.log(
|
AppLog.log(
|
||||||
"App -> 锁,指令类型:${commandType!.typeName} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}");
|
"App -> 锁,指令类型:${commandType!.typeName} ${commandType!.typeValue == 0x3030
|
||||||
|
? '子命令:${data[3]}' : ''} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}");
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO:拼装数据Ï
|
//TODO:拼装数据Ï
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
|
import 'package:star_lock/app_settings/app_settings.dart';
|
||||||
|
|
||||||
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart';
|
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart';
|
||||||
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_state.dart';
|
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_state.dart';
|
||||||
@ -58,7 +59,7 @@ class DoorLockLogLogic extends BaseGetXController {
|
|||||||
// AppLog.log("indexList:$indexList");
|
// AppLog.log("indexList:$indexList");
|
||||||
var indexMap = {};
|
var indexMap = {};
|
||||||
indexMap["type"] = indexList[0].toString();
|
indexMap["type"] = indexList[0].toString();
|
||||||
|
int operateDate = 0;
|
||||||
if (indexList[0] == 2) {
|
if (indexList[0] == 2) {
|
||||||
var passwordData = indexList.sublist(7, 17);
|
var passwordData = indexList.sublist(7, 17);
|
||||||
var password = utf8String(passwordData);
|
var password = utf8String(passwordData);
|
||||||
@ -75,6 +76,11 @@ class DoorLockLogLogic extends BaseGetXController {
|
|||||||
(0xFF & indexList[6]));
|
(0xFF & indexList[6]));
|
||||||
indexMap["date"] = "${time * 1000}";
|
indexMap["date"] = "${time * 1000}";
|
||||||
uploadList.add(indexMap);
|
uploadList.add(indexMap);
|
||||||
|
|
||||||
|
if (i == getList.length - 1) {
|
||||||
|
//设置最后的时间戳
|
||||||
|
state.operateDate = operateDate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lockRecordUploadData(uploadList);
|
lockRecordUploadData(uploadList);
|
||||||
|
|
||||||
|
|||||||
@ -188,7 +188,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
case 0x00:
|
case 0x00:
|
||||||
//成功
|
//成功
|
||||||
int dataLength = (reply.data[5] << 8) + reply.data[6];
|
int dataLength = (reply.data[5] << 8) + reply.data[6];
|
||||||
AppLog.log("dataLength:$dataLength");
|
// AppLog.log("dataLength:$dataLength");
|
||||||
if (dataLength > 0) {
|
if (dataLength > 0) {
|
||||||
reply.data.removeRange(0, 7);
|
reply.data.removeRange(0, 7);
|
||||||
// 把得到的数据按8位分割成数组 然后塞进一个新的数组里面
|
// 把得到的数据按8位分割成数组 然后塞进一个新的数组里面
|
||||||
@ -203,7 +203,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
// AppLog.log("indexList:$indexList");
|
// AppLog.log("indexList:$indexList");
|
||||||
var indexMap = {};
|
var indexMap = {};
|
||||||
indexMap["type"] = indexList[0].toString();
|
indexMap["type"] = indexList[0].toString();
|
||||||
|
int operateDate = 0;
|
||||||
if (indexList[0] == 2) {
|
if (indexList[0] == 2) {
|
||||||
var passwordData = reply.data.sublist(7, 17);
|
var passwordData = reply.data.sublist(7, 17);
|
||||||
var password = utf8String(passwordData);
|
var password = utf8String(passwordData);
|
||||||
@ -219,8 +219,14 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
(0xff & indexList[4]) << 16 |
|
(0xff & indexList[4]) << 16 |
|
||||||
(0xff & indexList[5]) << 8 |
|
(0xff & indexList[5]) << 8 |
|
||||||
(0xFF & indexList[6]));
|
(0xFF & indexList[6]));
|
||||||
indexMap["date"] = "${time * 1000}";
|
operateDate = time * 1000;
|
||||||
|
indexMap["date"] = "$operateDate";
|
||||||
uploadList.add(indexMap);
|
uploadList.add(indexMap);
|
||||||
|
|
||||||
|
if (i == getList.length - 1) {
|
||||||
|
//设置最后的时间戳
|
||||||
|
state.operateDate = operateDate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lockRecordUploadData(uploadList);
|
lockRecordUploadData(uploadList);
|
||||||
|
|
||||||
@ -259,7 +265,8 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
var token = await Storage.getStringList(saveBlueToken);
|
var token = await Storage.getStringList(saveBlueToken);
|
||||||
List<int> getTokenList = changeStringListToIntList(token!);
|
List<int> getTokenList = changeStringListToIntList(token!);
|
||||||
|
|
||||||
BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!,
|
BlueManage()
|
||||||
|
.bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!,
|
||||||
(BluetoothConnectionState deviceConnectionState) async {
|
(BluetoothConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||||
IoSenderManage.senderOpenLock(
|
IoSenderManage.senderOpenLock(
|
||||||
@ -289,6 +296,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
Future<void> senderReferEventRecordTime() async {
|
Future<void> senderReferEventRecordTime() async {
|
||||||
showBlueConnetctToastTimer(
|
showBlueConnetctToastTimer(
|
||||||
isShowBlueConnetctToast: false,
|
isShowBlueConnetctToast: false,
|
||||||
|
outTimer: 10,
|
||||||
action: () {
|
action: () {
|
||||||
BlueManage().disconnect();
|
BlueManage().disconnect();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -403,8 +403,9 @@ class _LockDetailPageState extends State<LockDetailPage>
|
|||||||
children: [
|
children: [
|
||||||
Visibility(
|
Visibility(
|
||||||
visible:
|
visible:
|
||||||
((state.keyInfos.value.keyType == XSConstantMacro.keyTypeTime || state.keyInfos.value.keyType == XSConstantMacro.keyTypeLoop)
|
((state.keyInfos.value.keyType == XSConstantMacro.keyTypeTime ||
|
||||||
&& // 限时、循环
|
state.keyInfos.value.keyType ==
|
||||||
|
XSConstantMacro.keyTypeLoop) && // 限时、循环
|
||||||
(DateTool().compareTimeGetDaysFromNow(
|
(DateTool().compareTimeGetDaysFromNow(
|
||||||
state.keyInfos.value.endDate!) <=
|
state.keyInfos.value.endDate!) <=
|
||||||
15 &&
|
15 &&
|
||||||
@ -1023,8 +1024,9 @@ class _LockDetailPageState extends State<LockDetailPage>
|
|||||||
|
|
||||||
if (state.keyInfos.value.lockFeature!.isSupportIris == 1) {
|
if (state.keyInfos.value.lockFeature!.isSupportIris == 1) {
|
||||||
showWidgetArr.add(
|
showWidgetArr.add(
|
||||||
bottomItem('images/main/icon_iris.png', '虹膜'.tr,
|
bottomItem(
|
||||||
state.bottomBtnisEable.value, () {
|
'images/main/icon_iris.png', '虹膜'.tr, state.bottomBtnisEable.value,
|
||||||
|
() {
|
||||||
Get.toNamed(Routers.irisListPage, arguments: {
|
Get.toNamed(Routers.irisListPage, arguments: {
|
||||||
"lockId": state.keyInfos.value.lockId,
|
"lockId": state.keyInfos.value.lockId,
|
||||||
});
|
});
|
||||||
@ -1034,8 +1036,9 @@ class _LockDetailPageState extends State<LockDetailPage>
|
|||||||
|
|
||||||
if (state.keyInfos.value.lockFeature!.palmVein == 1) {
|
if (state.keyInfos.value.lockFeature!.palmVein == 1) {
|
||||||
showWidgetArr.add(
|
showWidgetArr.add(
|
||||||
bottomItem('images/main/icon_palm.png', '手掌'.tr,
|
bottomItem(
|
||||||
state.bottomBtnisEable.value, () {
|
'images/main/icon_palm.png', '手掌'.tr, state.bottomBtnisEable.value,
|
||||||
|
() {
|
||||||
Get.toNamed(Routers.palmListPage, arguments: {
|
Get.toNamed(Routers.palmListPage, arguments: {
|
||||||
"lockId": state.keyInfos.value.lockId,
|
"lockId": state.keyInfos.value.lockId,
|
||||||
});
|
});
|
||||||
@ -1121,7 +1124,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
|||||||
return showWidgetArr;
|
return showWidgetArr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget bottomItem(String iconUrl, String name, bool bottomBtnisEable, Function() onClick) {
|
Widget bottomItem(
|
||||||
|
String iconUrl, String name, bool bottomBtnisEable, Function() onClick) {
|
||||||
Widget child = F.sw(
|
Widget child = F.sw(
|
||||||
defaultCall: () => Container(
|
defaultCall: () => Container(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
@ -1147,7 +1151,9 @@ class _LockDetailPageState extends State<LockDetailPage>
|
|||||||
child: Text(name,
|
child: Text(name,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 20.sp,
|
fontSize: 20.sp,
|
||||||
color: bottomBtnisEable ? AppColors.blackColor : AppColors.lockDetailBottomBtnUneable),
|
color: bottomBtnisEable
|
||||||
|
? AppColors.blackColor
|
||||||
|
: AppColors.lockDetailBottomBtnUneable),
|
||||||
textAlign: TextAlign.center))
|
textAlign: TextAlign.center))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -1189,8 +1195,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
|||||||
onTap: bottomBtnisEable
|
onTap: bottomBtnisEable
|
||||||
? onClick
|
? onClick
|
||||||
: () {
|
: () {
|
||||||
logic.showToast("请在锁旁边完成第一次开锁".tr);
|
logic.showToast("请在锁旁边完成第一次开锁".tr);
|
||||||
},
|
},
|
||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1406,7 +1412,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
|||||||
void didPushNext() {
|
void didPushNext() {
|
||||||
super.didPushNext();
|
super.didPushNext();
|
||||||
state.ifCurrentScreen.value = false;
|
state.ifCurrentScreen.value = false;
|
||||||
logic.cancelBlueConnetctToastTimer();
|
logic.closeLuckStatus();
|
||||||
state.openLockBtnState.value = 0;
|
BlueManage().disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,12 +66,14 @@ class BaseGetXController extends GetxController {
|
|||||||
|
|
||||||
// CancelableOperation? _operation;
|
// CancelableOperation? _operation;
|
||||||
void showBlueConnetctToastTimer(
|
void showBlueConnetctToastTimer(
|
||||||
{bool isShowBlueConnetctToast = true, Function? action}) {
|
{bool isShowBlueConnetctToast = true,
|
||||||
|
int outTimer = 15,
|
||||||
|
Function? action}) {
|
||||||
if (_timer != null && _timer!.isActive) {
|
if (_timer != null && _timer!.isActive) {
|
||||||
_timer!.cancel();
|
_timer!.cancel();
|
||||||
_timer = null;
|
_timer = null;
|
||||||
}
|
}
|
||||||
_timer = Timer.periodic(15.seconds, (timer) {
|
_timer = Timer.periodic(outTimer.seconds, (timer) {
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
action();
|
action();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user