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

This commit is contained in:
Daisy 2023-12-14 11:22:21 +08:00
commit 77494e6630
10 changed files with 67 additions and 34 deletions

View File

@ -32,6 +32,7 @@ class BlueManage{
//
StreamSubscription<EventSendModel>? _sendStreamSubscription;
StreamSubscription? _scanSubscription;
StreamSubscription<dynamic>? _currentConnectionStream;
//
DeviceConnectionState? deviceConnectionState = DeviceConnectionState.disconnected;
@ -126,7 +127,7 @@ class BlueManage{
if(deviceConnectionState == DeviceConnectionState.connected){
return;
}
_flutterReactiveBle!.connectToDevice(id: connectDeviceMacAddress, connectionTimeout: const Duration(seconds: 100000)).listen((connectionStateUpdate) async {
_currentConnectionStream = _flutterReactiveBle!.connectToDevice(id: connectDeviceMacAddress, connectionTimeout: const Duration(seconds: 100000)).listen((connectionStateUpdate) async {
//
deviceConnectionState = connectionStateUpdate.connectionState;
print('ConnectionState for device $deviceMAC : ${connectionStateUpdate.connectionState}');
@ -206,16 +207,15 @@ class BlueManage{
//
Future<void> disconnect(String deviceMAC) async {
try {
_currentConnectionStream?.cancel();
print('disconnecting to device: $deviceMAC');
} on Exception catch (e, _) {
print("Error disconnecting from a device: $e");
} finally {
// EventBusManager().eventBusFir(ConnectionStateUpdate(
// deviceId: deviceMAC,
// connectionState: DeviceConnectionState.disconnected,
// failure: null,
// ));
deviceConnectionState = DeviceConnectionState.disconnected;
// _currentConnectionStream = null;
}
}
@ -394,5 +394,6 @@ class BlueManage{
disposed(){
_sendStreamSubscription?.cancel();
_currentConnectionStream?.cancel();
}
}

View File

@ -71,6 +71,7 @@ class AddCardTypeLogic extends BaseGetXController{
fingerprintType = 4;
}
var isCoerced = state.isStressFingerprint.value == false ? "1" : "2"; // 1: 2:
print("addOtherType startDate:$startDate endDate:$endDate");
Get.toNamed(Routers.addICCardPage, arguments: {
"lockId": state.lockId.value,
@ -79,7 +80,7 @@ class AddCardTypeLogic extends BaseGetXController{
"cardName": state.nameController.text,
"cardNumber": (Random().nextInt(100000000) + 10000000).floor().toString(),
"cardType": fingerprintType.toString(),
"isCoerced": state.isStressFingerprint.value ? "1" : "2",
"isCoerced": isCoerced,
"startDate": startDate,
"weekDay": state.weekdaysList.value,
"fromType": state.fromType.value,

View File

@ -74,8 +74,10 @@ class AddICCardLogic extends BaseGetXController{
userID:await Storage.getUid(),
fingerNo:1,
useCountLimit:0xff,
startTime:int.parse(state.startDate.value)~/1000,
endTime:int.parse(state.endDate.value)~/1000,
startTime:0x11223344,
endTime:0x11223344,
// startTime:int.parse(state.startDate.value)~/1000,
// endTime:int.parse(state.endDate.value)~/1000,
needAuthor:1,
publicKey:publicKeyDataList,
privateKey:getPrivateKeyList,
@ -258,8 +260,10 @@ class AddICCardLogic extends BaseGetXController{
icCardNo:1,
cardType:1,
useCountLimit:1,
startTime:int.parse(state.startDate.value)~/1000,
endTime:int.parse(state.endDate.value)~/1000,
startTime:0x11223344,
endTime:0x11223344,
// startTime:int.parse(state.startDate.value)~/1000,
// endTime:int.parse(state.endDate.value)~/1000,
needAuthor:1,
publicKey:publicKeyDataList,
privateKey:getPrivateKeyList,

View File

@ -181,13 +181,13 @@ class AddFingerprintLogic extends BaseGetXController {
//
print("${reply.commandType!.typeValue} 数据解析成功");
// print("添加指纹确认成功,调用添加指纹接口");
// if(state.isCoerced.value == "1"){
if(state.isCoerced.value == "1"){
//
addFingerprintsData(reply.data[6].toString());
// }else{
// //
// senderAddStressFingerprint();
// }
}else{
//
senderAddStressFingerprint();
}
break;
case 0x06:
//

View File

@ -338,8 +338,12 @@ class FingerprintListLogic extends BaseGetXController{
//
void deletAllFingerprintsData() async{
var fingerprintId = "";
if(state.isDeletAll == false){
// fingerprintId =
}
var entity = await ApiRepository.to.deletFingerprintsData(
fingerprintId: "",
fingerprintId: fingerprintId,
lockId: state.lockId.value.toString(),
type: "1",
deleteType:"1"

View File

@ -176,6 +176,7 @@ class _FingerprintListPageState extends State<FingerprintListPage> {
return GestureDetector(
onTap: () {
// :
state.deletFingerprintId = idStr;
showIosTipViewDialog(context, idStr);
},
child: Container(
@ -206,6 +207,7 @@ class _FingerprintListPageState extends State<FingerprintListPage> {
Get.back();
String? idStr = await Storage.getUid();
state.isDeletFingerprintData = true;
state.isDeletAll = false;
logic.senderAddFingerprint(keyId, idStr ?? "", 0);
},
cancelClick: () {
@ -287,6 +289,7 @@ class _FingerprintListPageState extends State<FingerprintListPage> {
onPressed: () {
Navigator.pop(context);
state.isDeletFingerprintData = true;
state.isDeletAll = true;
logic.senderAddFingerprint("1", "DeleteAll!@#", 255);
},
),

View File

@ -10,6 +10,7 @@ class FingerprintListState{
//
var isDeletFingerprintData = false;
var isDeletAll = false;
var deletFingerprintId = "0";
final fingerprintItemListData = <FingerprintItemData>[].obs;
final TextEditingController searchController = TextEditingController();

View File

@ -2,6 +2,7 @@
import 'dart:async';
import 'dart:io';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:star_lock/blue/io_protocol/io_editUser.dart';
@ -404,6 +405,9 @@ class LockDetailLogic extends BaseGetXController{
Future<void> connectBlue(String bluetoothDeviceId, String bluetoothDeviceName) async {
//
BlueManage().connect(bluetoothDeviceId, bluetoothDeviceName, connectStateCallBack: (DeviceConnectionState state) async {
if(EasyLoading.isShow){
EasyLoading.dismiss();
}
if (state == DeviceConnectionState.connected){
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
@ -545,6 +549,14 @@ class LockDetailLogic extends BaseGetXController{
_initReplySubscription();
initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction();
EasyLoading.show(status: "正在连接设备,请稍等。", maskType: EasyLoadingMaskType.black, dismissOnTap: true);
Future.delayed(const Duration(seconds: 12), () {
if(EasyLoading.isShow){
EasyLoading.dismiss();
Toast.show(msg: "连接设备失败,请确保在设备附近,设备未被连接,设备已打开");
}
});
if(Platform.isIOS){
print("有蓝牙权限开始扫描");
startScanAction();
@ -574,16 +586,6 @@ class LockDetailLogic extends BaseGetXController{
// factoryDataResetAction();
}
@override
void onClose() {
// TODO: implement onClose
print("锁详情界面销毁了");
_replySubscription.cancel();
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent!.cancel();
}
///
Future<bool> getMicrophonePermission() async {
// You can request multiple permissions at once.
@ -602,4 +604,12 @@ class LockDetailLogic extends BaseGetXController{
return false;
}
@override
void onClose() {
// TODO: implement onClose
print("锁详情界面销毁了");
_replySubscription.cancel();
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent!.cancel();
}
}

View File

@ -25,8 +25,7 @@ class LockDetailPage extends StatefulWidget {
State<LockDetailPage> createState() => _LockDetailPageState();
}
class _LockDetailPageState extends State<LockDetailPage>
with TickerProviderStateMixin {
class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStateMixin, RouteAware {
// with RouteAware
final logic = Get.put(LockDetailLogic());
final state = Get.find<LockDetailLogic>().state;
@ -471,22 +470,33 @@ class _LockDetailPageState extends State<LockDetailPage>
// TODO: implement dispose
///
// AppRouteObserver().routeObserver.unsubscribe(this);
state.animationController.dispose();
super.dispose();
BlueManage().stopScan();
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
}
///
@override
void didPush() {}
void didPush() {
print("LockDetailPage didPush");
}
/// Called when the current route has been popped off.
@override
void didPop() {}
void didPop() {
print("LockDetailPage didPop");
}
/// Called when the current route has been popped off.
@override
void didPopNext() {}
void didPopNext() {
print("LockDetailPage didPopNext");
}
/// Called when the current route has been popped off.
@override
void didPushNext() {}
void didPushNext() {
print("LockDetailPage didPushNext");
}
}

View File

@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';