Merge branch 'master' of gitee.com:starlock-cn/app-starlock
This commit is contained in:
commit
77494e6630
@ -32,6 +32,7 @@ class BlueManage{
|
|||||||
// 监听发送事件
|
// 监听发送事件
|
||||||
StreamSubscription<EventSendModel>? _sendStreamSubscription;
|
StreamSubscription<EventSendModel>? _sendStreamSubscription;
|
||||||
StreamSubscription? _scanSubscription;
|
StreamSubscription? _scanSubscription;
|
||||||
|
StreamSubscription<dynamic>? _currentConnectionStream;
|
||||||
|
|
||||||
// 监听蓝牙连接状态
|
// 监听蓝牙连接状态
|
||||||
DeviceConnectionState? deviceConnectionState = DeviceConnectionState.disconnected;
|
DeviceConnectionState? deviceConnectionState = DeviceConnectionState.disconnected;
|
||||||
@ -126,7 +127,7 @@ class BlueManage{
|
|||||||
if(deviceConnectionState == DeviceConnectionState.connected){
|
if(deviceConnectionState == DeviceConnectionState.connected){
|
||||||
return;
|
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;
|
deviceConnectionState = connectionStateUpdate.connectionState;
|
||||||
print('ConnectionState for device $deviceMAC : ${connectionStateUpdate.connectionState}');
|
print('ConnectionState for device $deviceMAC : ${connectionStateUpdate.connectionState}');
|
||||||
@ -206,16 +207,15 @@ class BlueManage{
|
|||||||
|
|
||||||
// 断开连接
|
// 断开连接
|
||||||
Future<void> disconnect(String deviceMAC) async {
|
Future<void> disconnect(String deviceMAC) async {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
_currentConnectionStream?.cancel();
|
||||||
print('disconnecting to device: $deviceMAC');
|
print('disconnecting to device: $deviceMAC');
|
||||||
} on Exception catch (e, _) {
|
} on Exception catch (e, _) {
|
||||||
print("Error disconnecting from a device: $e");
|
print("Error disconnecting from a device: $e");
|
||||||
} finally {
|
} finally {
|
||||||
// EventBusManager().eventBusFir(ConnectionStateUpdate(
|
deviceConnectionState = DeviceConnectionState.disconnected;
|
||||||
// deviceId: deviceMAC,
|
// _currentConnectionStream = null;
|
||||||
// connectionState: DeviceConnectionState.disconnected,
|
|
||||||
// failure: null,
|
|
||||||
// ));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -394,5 +394,6 @@ class BlueManage{
|
|||||||
|
|
||||||
disposed(){
|
disposed(){
|
||||||
_sendStreamSubscription?.cancel();
|
_sendStreamSubscription?.cancel();
|
||||||
|
_currentConnectionStream?.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -71,6 +71,7 @@ class AddCardTypeLogic extends BaseGetXController{
|
|||||||
fingerprintType = 4;
|
fingerprintType = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isCoerced = state.isStressFingerprint.value == false ? "1" : "2"; // 1:非胁迫卡 2:胁迫卡
|
||||||
print("addOtherType startDate:$startDate endDate:$endDate");
|
print("addOtherType startDate:$startDate endDate:$endDate");
|
||||||
Get.toNamed(Routers.addICCardPage, arguments: {
|
Get.toNamed(Routers.addICCardPage, arguments: {
|
||||||
"lockId": state.lockId.value,
|
"lockId": state.lockId.value,
|
||||||
@ -79,7 +80,7 @@ class AddCardTypeLogic extends BaseGetXController{
|
|||||||
"cardName": state.nameController.text,
|
"cardName": state.nameController.text,
|
||||||
"cardNumber": (Random().nextInt(100000000) + 10000000).floor().toString(),
|
"cardNumber": (Random().nextInt(100000000) + 10000000).floor().toString(),
|
||||||
"cardType": fingerprintType.toString(),
|
"cardType": fingerprintType.toString(),
|
||||||
"isCoerced": state.isStressFingerprint.value ? "1" : "2",
|
"isCoerced": isCoerced,
|
||||||
"startDate": startDate,
|
"startDate": startDate,
|
||||||
"weekDay": state.weekdaysList.value,
|
"weekDay": state.weekdaysList.value,
|
||||||
"fromType": state.fromType.value,
|
"fromType": state.fromType.value,
|
||||||
|
|||||||
@ -74,8 +74,10 @@ class AddICCardLogic extends BaseGetXController{
|
|||||||
userID:await Storage.getUid(),
|
userID:await Storage.getUid(),
|
||||||
fingerNo:1,
|
fingerNo:1,
|
||||||
useCountLimit:0xff,
|
useCountLimit:0xff,
|
||||||
startTime:int.parse(state.startDate.value)~/1000,
|
startTime:0x11223344,
|
||||||
endTime:int.parse(state.endDate.value)~/1000,
|
endTime:0x11223344,
|
||||||
|
// startTime:int.parse(state.startDate.value)~/1000,
|
||||||
|
// endTime:int.parse(state.endDate.value)~/1000,
|
||||||
needAuthor:1,
|
needAuthor:1,
|
||||||
publicKey:publicKeyDataList,
|
publicKey:publicKeyDataList,
|
||||||
privateKey:getPrivateKeyList,
|
privateKey:getPrivateKeyList,
|
||||||
@ -258,8 +260,10 @@ class AddICCardLogic extends BaseGetXController{
|
|||||||
icCardNo:1,
|
icCardNo:1,
|
||||||
cardType:1,
|
cardType:1,
|
||||||
useCountLimit:1,
|
useCountLimit:1,
|
||||||
startTime:int.parse(state.startDate.value)~/1000,
|
startTime:0x11223344,
|
||||||
endTime:int.parse(state.endDate.value)~/1000,
|
endTime:0x11223344,
|
||||||
|
// startTime:int.parse(state.startDate.value)~/1000,
|
||||||
|
// endTime:int.parse(state.endDate.value)~/1000,
|
||||||
needAuthor:1,
|
needAuthor:1,
|
||||||
publicKey:publicKeyDataList,
|
publicKey:publicKeyDataList,
|
||||||
privateKey:getPrivateKeyList,
|
privateKey:getPrivateKeyList,
|
||||||
|
|||||||
@ -181,13 +181,13 @@ class AddFingerprintLogic extends BaseGetXController {
|
|||||||
//成功
|
//成功
|
||||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||||
// print("添加指纹确认成功,调用添加指纹接口");
|
// print("添加指纹确认成功,调用添加指纹接口");
|
||||||
// if(state.isCoerced.value == "1"){
|
if(state.isCoerced.value == "1"){
|
||||||
// 非胁迫指纹
|
// 非胁迫指纹
|
||||||
addFingerprintsData(reply.data[6].toString());
|
addFingerprintsData(reply.data[6].toString());
|
||||||
// }else{
|
}else{
|
||||||
// // 如果是胁迫指纹在 添加完之后以后再调用添加胁迫指纹的
|
// 如果是胁迫指纹在 添加完之后以后再调用添加胁迫指纹的
|
||||||
// senderAddStressFingerprint();
|
senderAddStressFingerprint();
|
||||||
// }
|
}
|
||||||
break;
|
break;
|
||||||
case 0x06:
|
case 0x06:
|
||||||
//需要权限
|
//需要权限
|
||||||
|
|||||||
@ -338,8 +338,12 @@ class FingerprintListLogic extends BaseGetXController{
|
|||||||
|
|
||||||
// 重置所有的指纹
|
// 重置所有的指纹
|
||||||
void deletAllFingerprintsData() async{
|
void deletAllFingerprintsData() async{
|
||||||
|
var fingerprintId = "";
|
||||||
|
if(state.isDeletAll == false){
|
||||||
|
// fingerprintId =
|
||||||
|
}
|
||||||
var entity = await ApiRepository.to.deletFingerprintsData(
|
var entity = await ApiRepository.to.deletFingerprintsData(
|
||||||
fingerprintId: "",
|
fingerprintId: fingerprintId,
|
||||||
lockId: state.lockId.value.toString(),
|
lockId: state.lockId.value.toString(),
|
||||||
type: "1",
|
type: "1",
|
||||||
deleteType:"1"
|
deleteType:"1"
|
||||||
|
|||||||
@ -176,6 +176,7 @@ class _FingerprintListPageState extends State<FingerprintListPage> {
|
|||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// 省略: 弹出是否删除的确认对话框。
|
// 省略: 弹出是否删除的确认对话框。
|
||||||
|
state.deletFingerprintId = idStr;
|
||||||
showIosTipViewDialog(context, idStr);
|
showIosTipViewDialog(context, idStr);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
@ -206,6 +207,7 @@ class _FingerprintListPageState extends State<FingerprintListPage> {
|
|||||||
Get.back();
|
Get.back();
|
||||||
String? idStr = await Storage.getUid();
|
String? idStr = await Storage.getUid();
|
||||||
state.isDeletFingerprintData = true;
|
state.isDeletFingerprintData = true;
|
||||||
|
state.isDeletAll = false;
|
||||||
logic.senderAddFingerprint(keyId, idStr ?? "", 0);
|
logic.senderAddFingerprint(keyId, idStr ?? "", 0);
|
||||||
},
|
},
|
||||||
cancelClick: () {
|
cancelClick: () {
|
||||||
@ -287,6 +289,7 @@ class _FingerprintListPageState extends State<FingerprintListPage> {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
state.isDeletFingerprintData = true;
|
state.isDeletFingerprintData = true;
|
||||||
|
state.isDeletAll = true;
|
||||||
logic.senderAddFingerprint("1", "DeleteAll!@#", 255);
|
logic.senderAddFingerprint("1", "DeleteAll!@#", 255);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@ -10,6 +10,7 @@ class FingerprintListState{
|
|||||||
// 因为删除跟添加指纹用的同一个协议 所以这里用做判断
|
// 因为删除跟添加指纹用的同一个协议 所以这里用做判断
|
||||||
var isDeletFingerprintData = false;
|
var isDeletFingerprintData = false;
|
||||||
var isDeletAll = false;
|
var isDeletAll = false;
|
||||||
|
var deletFingerprintId = "0";
|
||||||
|
|
||||||
final fingerprintItemListData = <FingerprintItemData>[].obs;
|
final fingerprintItemListData = <FingerprintItemData>[].obs;
|
||||||
final TextEditingController searchController = TextEditingController();
|
final TextEditingController searchController = TextEditingController();
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_editUser.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 {
|
Future<void> connectBlue(String bluetoothDeviceId, String bluetoothDeviceName) async {
|
||||||
// 进来之后首先连接
|
// 进来之后首先连接
|
||||||
BlueManage().connect(bluetoothDeviceId, bluetoothDeviceName, connectStateCallBack: (DeviceConnectionState state) async {
|
BlueManage().connect(bluetoothDeviceId, bluetoothDeviceName, connectStateCallBack: (DeviceConnectionState state) async {
|
||||||
|
if(EasyLoading.isShow){
|
||||||
|
EasyLoading.dismiss();
|
||||||
|
}
|
||||||
if (state == DeviceConnectionState.connected){
|
if (state == DeviceConnectionState.connected){
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
@ -545,6 +549,14 @@ class LockDetailLogic extends BaseGetXController{
|
|||||||
_initReplySubscription();
|
_initReplySubscription();
|
||||||
initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction();
|
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){
|
if(Platform.isIOS){
|
||||||
print("有蓝牙权限开始扫描");
|
print("有蓝牙权限开始扫描");
|
||||||
startScanAction();
|
startScanAction();
|
||||||
@ -574,16 +586,6 @@ class LockDetailLogic extends BaseGetXController{
|
|||||||
// factoryDataResetAction();
|
// factoryDataResetAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
|
||||||
void onClose() {
|
|
||||||
// TODO: implement onClose
|
|
||||||
print("锁详情界面销毁了");
|
|
||||||
|
|
||||||
_replySubscription.cancel();
|
|
||||||
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent!.cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
///请求录音相机权限
|
///请求录音相机权限
|
||||||
Future<bool> getMicrophonePermission() async {
|
Future<bool> getMicrophonePermission() async {
|
||||||
// You can request multiple permissions at once.
|
// You can request multiple permissions at once.
|
||||||
@ -602,4 +604,12 @@ class LockDetailLogic extends BaseGetXController{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onClose() {
|
||||||
|
// TODO: implement onClose
|
||||||
|
print("锁详情界面销毁了");
|
||||||
|
|
||||||
|
_replySubscription.cancel();
|
||||||
|
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent!.cancel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -25,8 +25,7 @@ class LockDetailPage extends StatefulWidget {
|
|||||||
State<LockDetailPage> createState() => _LockDetailPageState();
|
State<LockDetailPage> createState() => _LockDetailPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _LockDetailPageState extends State<LockDetailPage>
|
class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStateMixin, RouteAware {
|
||||||
with TickerProviderStateMixin {
|
|
||||||
// with RouteAware
|
// with RouteAware
|
||||||
final logic = Get.put(LockDetailLogic());
|
final logic = Get.put(LockDetailLogic());
|
||||||
final state = Get.find<LockDetailLogic>().state;
|
final state = Get.find<LockDetailLogic>().state;
|
||||||
@ -471,22 +470,33 @@ class _LockDetailPageState extends State<LockDetailPage>
|
|||||||
// TODO: implement dispose
|
// TODO: implement dispose
|
||||||
/// 取消路由订阅
|
/// 取消路由订阅
|
||||||
// AppRouteObserver().routeObserver.unsubscribe(this);
|
// AppRouteObserver().routeObserver.unsubscribe(this);
|
||||||
|
state.animationController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
|
BlueManage().stopScan();
|
||||||
|
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@override
|
@override
|
||||||
void didPush() {}
|
void didPush() {
|
||||||
|
print("LockDetailPage didPush");
|
||||||
|
}
|
||||||
|
|
||||||
/// Called when the current route has been popped off.
|
/// Called when the current route has been popped off.
|
||||||
@override
|
@override
|
||||||
void didPop() {}
|
void didPop() {
|
||||||
|
print("LockDetailPage didPop");
|
||||||
|
}
|
||||||
|
|
||||||
/// Called when the current route has been popped off.
|
/// Called when the current route has been popped off.
|
||||||
@override
|
@override
|
||||||
void didPopNext() {}
|
void didPopNext() {
|
||||||
|
print("LockDetailPage didPopNext");
|
||||||
|
}
|
||||||
|
|
||||||
/// Called when the current route has been popped off.
|
/// Called when the current route has been popped off.
|
||||||
@override
|
@override
|
||||||
void didPushNext() {}
|
void didPushNext() {
|
||||||
|
print("LockDetailPage didPushNext");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user