Merge branch 'release' of gitee.com:starlock-cn/app-starlock into release
This commit is contained in:
commit
e9681e01a3
@ -17,6 +17,12 @@ typedef ConnectStateCallBack = Function(
|
||||
typedef ScanDevicesCallBack = Function(List<ScanResult>);
|
||||
|
||||
class BlueManage {
|
||||
|
||||
factory BlueManage() => shareManager()!;
|
||||
|
||||
BlueManage._init() {
|
||||
_initBlue();
|
||||
}
|
||||
final List<ScanResult> scanDevices = <ScanResult>[];
|
||||
|
||||
// 用来写入的服务id
|
||||
@ -34,12 +40,6 @@ class BlueManage {
|
||||
// 监听发送事件
|
||||
StreamSubscription<EventSendModel>? _sendStreamSubscription;
|
||||
|
||||
// 监听蓝牙扫描的事件
|
||||
// StreamSubscription? _scanSubscription;
|
||||
// 监听蓝牙连接的事件
|
||||
// StreamSubscription<dynamic>? _currentConnectionStream;
|
||||
|
||||
// StreamSubscription<List<ScanResult>>? _scanResultsSubscription;
|
||||
StreamSubscription<BluetoothConnectionState>? _connectionStateSubscription;
|
||||
|
||||
StreamSubscription<int>? _mtuSubscription;
|
||||
@ -64,11 +64,14 @@ class BlueManage {
|
||||
BluetoothAdapterState? _adapterState = BluetoothAdapterState.unknown;
|
||||
StreamSubscription<BluetoothAdapterState>? _adapterStateStateSubscription;
|
||||
|
||||
static BlueManage? _manager;
|
||||
// 听上报来的数据,参数来自前面扫描到的结果
|
||||
List<int> allData = <int>[];
|
||||
|
||||
BlueManage._init() {
|
||||
_initBlue();
|
||||
}
|
||||
// 保存上一次的数据,用来判断是否收到重复的数据
|
||||
List<int> lastTimeData = <int>[];
|
||||
int? dataLen;
|
||||
|
||||
static BlueManage? _manager;
|
||||
|
||||
static BlueManage? shareManager() {
|
||||
_manager ??= BlueManage._init();
|
||||
@ -76,16 +79,12 @@ class BlueManage {
|
||||
return _manager;
|
||||
}
|
||||
|
||||
factory BlueManage() => shareManager()!;
|
||||
|
||||
BlueManage? get manager => shareManager();
|
||||
|
||||
void _initBlue() {
|
||||
FlutterBluePlus.setLogLevel(LogLevel.error, color: true);
|
||||
_initSendStreamSubscription();
|
||||
_initAdapterStateStateSubscription();
|
||||
// _initListenscanResults();
|
||||
// _initListenConnectionState();
|
||||
}
|
||||
|
||||
void _initGetMtuSubscription() {
|
||||
@ -102,45 +101,6 @@ class BlueManage {
|
||||
});
|
||||
}
|
||||
|
||||
// void _initListenscanResults() {
|
||||
// var subscription = FlutterBluePlus.scanResults.listen((results) {
|
||||
// scanDevices.clear();
|
||||
// for (var scanResult in results) {
|
||||
// // 判断名字为空的直接剔除
|
||||
// // if (scanResult.device.advName.isEmpty) {
|
||||
// // return;
|
||||
// // }
|
||||
// AppLog.log("scanResult.device.advName:${scanResult.device.advName}"
|
||||
// " scanResult.advertisementData.serviceUuids:${scanResult.advertisementData.serviceUuids}"
|
||||
// " rssi:${scanResult.rssi}");
|
||||
// if (((scanResult.advertisementData.serviceUuids.isNotEmpty ? scanResult.advertisementData.serviceUuids[0] : "").toString().contains("758824")) && (scanResult.rssi >= -100)) {
|
||||
// // 查询id相同的元素
|
||||
// final knownDeviceIndex = scanDevices.indexWhere((d) => d.advertisementData.advName == scanResult.advertisementData.advName);
|
||||
// // 不存在的时候返回-1
|
||||
// if (knownDeviceIndex >= 0) {
|
||||
// scanDevices[knownDeviceIndex] = scanResult;
|
||||
// } else {
|
||||
// scanDevices.add(scanResult);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// EventBusManager().eventBusFir(scanDevices);
|
||||
// // FlutterBluePlus.stopScan();
|
||||
// }, onError: (e) {
|
||||
// AppLog.log("Scan Error:$e", );
|
||||
// });
|
||||
//
|
||||
// FlutterBluePlus.cancelWhenScanComplete(subscription);
|
||||
|
||||
// FlutterBluePlus.isScanning.listen((state) {
|
||||
// if (state) {
|
||||
// prAppLog.logint('Scanning');
|
||||
// } else {
|
||||
// AppLog.log('Not scanning');
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
void _initListenConnectionState() {
|
||||
_connectionStateSubscription?.cancel();
|
||||
_connectionStateSubscription = null;
|
||||
@ -185,7 +145,7 @@ class BlueManage {
|
||||
if (_adapterState == BluetoothAdapterState.on) {
|
||||
try {
|
||||
//android 扫描比较慢,取样只要 8 分之一
|
||||
final int divisor = Platform.isAndroid ? 8 : 1;
|
||||
final int divisor = Platform.isAndroid ? 3 : 1;
|
||||
FlutterBluePlus.startScan(
|
||||
continuousDivisor: divisor,
|
||||
continuousUpdates: true,
|
||||
@ -316,7 +276,7 @@ class BlueManage {
|
||||
}
|
||||
|
||||
/// 调用发送数据 List senderData,
|
||||
Future<void> bludSendData(
|
||||
Future<void> blueSendData(
|
||||
String deviceName, ConnectStateCallBack stateCallBack,
|
||||
{bool isAddEquipment = false}) async {
|
||||
FlutterBluePlus.isSupported.then((bool isAvailable) async {
|
||||
@ -368,14 +328,13 @@ class BlueManage {
|
||||
}
|
||||
|
||||
//查找缓存里面是否有设备
|
||||
bool isExistScanDevices(String connectDeviceName){
|
||||
bool isExistScanDevices(String connectDeviceName) {
|
||||
final bool isExistDevice = scanDevices.any((ScanResult element) =>
|
||||
element.device.platformName == connectDeviceName ||
|
||||
element.device.platformName == connectDeviceName ||
|
||||
element.advertisementData.advName == connectDeviceName);
|
||||
return isExistDevice;
|
||||
}
|
||||
|
||||
|
||||
Future<void> _connectDevice(List<ScanResult> devicesList, String deviceName,
|
||||
ConnectStateCallBack connectStateCallBack,
|
||||
{bool isAddEquipment = false}) async {
|
||||
@ -400,13 +359,9 @@ class BlueManage {
|
||||
_initGetMtuSubscription();
|
||||
_initListenConnectionState();
|
||||
}
|
||||
// AppLog.log("1 connectDeviceId:$connectDeviceMacAddress connectDeviceName:$connectDeviceName");
|
||||
// stopScan();
|
||||
if (scanResult == null || connectDeviceMacAddress.isEmpty) {
|
||||
// connectStateCallBack(BluetoothConnectionState.disconnected!);
|
||||
return;
|
||||
}
|
||||
|
||||
// AppLog.log("调用了停止扫描的方法");
|
||||
await stopScan();
|
||||
|
||||
@ -438,28 +393,18 @@ class BlueManage {
|
||||
connectStateCallBack(BluetoothConnectionState.disconnected);
|
||||
}
|
||||
|
||||
// await bluetoothConnectDevice!.connect();
|
||||
if (bluetoothConnectionState == BluetoothConnectionState.connected) {
|
||||
try {
|
||||
bluetoothConnectDevice!
|
||||
.discoverServices()
|
||||
.then((List<BluetoothService> services) {
|
||||
for (final BluetoothService service in services) {
|
||||
// AppLog.log("11111service.remoteId:${service.remoteId}"
|
||||
// " service.uuid:${service.uuid}"
|
||||
// " service.characteristics:${service.characteristics}"
|
||||
// " service.includedServices:${service.includedServices}");
|
||||
if (service.uuid == _serviceIdConnect) {
|
||||
for (final BluetoothCharacteristic characteristic
|
||||
in service.characteristics) {
|
||||
// Get.log("22222characteristic.remoteId:${characteristic.remoteId}"
|
||||
// " characteristic.uuid:${characteristic.uuid}"
|
||||
// " characteristic.secondaryServiceUuid:${characteristic.secondaryServiceUuid}"
|
||||
// " characteristic.characteristicUuid:${characteristic.characteristicUuid}");
|
||||
if (characteristic.characteristicUuid ==
|
||||
_characteristicIdSubscription) {
|
||||
_subScribeToCharacteristic(characteristic);
|
||||
// AppLog.log('Discovering services finished');
|
||||
bluetoothConnectionState = BluetoothConnectionState.connected;
|
||||
connectStateCallBack(bluetoothConnectionState!);
|
||||
}
|
||||
@ -477,49 +422,41 @@ class BlueManage {
|
||||
}
|
||||
}
|
||||
|
||||
// 听上报来的数据,参数来自前面扫描到的结果
|
||||
List<int> allData = <int>[];
|
||||
|
||||
// 保存上一次的数据,用来判断是否收到重复的数据
|
||||
List<int> lastTimeData = <int>[];
|
||||
int? dataLen;
|
||||
|
||||
Future<void> _subScribeToCharacteristic(
|
||||
BluetoothCharacteristic characteristic) async {
|
||||
final StreamSubscription<List<int>> subscription =
|
||||
characteristic.onValueReceived.listen((List<int> data) {
|
||||
// AppLog.log("订阅获取的数据:$data");
|
||||
AppLog.log('订阅获取的数据: $data ');
|
||||
if (data == lastTimeData || data.isEmpty) {
|
||||
return;
|
||||
} else {
|
||||
lastTimeData = data;
|
||||
}
|
||||
// code to handle incoming data
|
||||
// AppLog.log("subscribeToCharacteristic: deviceId = ${characteristic.deviceId} characteristicId =${characteristic.characteristicId}---上报来的数据data = $data");
|
||||
if ((data[0] == 0xEF) &&
|
||||
(data[1] == 0x01) &&
|
||||
(data[2] == 0xEE) &&
|
||||
(data[3] == 0x02)) {
|
||||
final bool dataHeadCorrect = isDataHeadCorrect(data);
|
||||
final bool allDataHeadCorrect = isDataHeadCorrect(allData);
|
||||
if (dataHeadCorrect && allDataHeadCorrect) {
|
||||
//缓存数据和新数据都有包头,直接放弃缓存数据
|
||||
allData = <int>[];
|
||||
}
|
||||
if (dataHeadCorrect) {
|
||||
// 当包有头时
|
||||
// 判断是否需要分包
|
||||
dataLen = data[8] * 256 + data[9]; // 高16位用来指示后面数据块内容的长度
|
||||
// AppLog.log("dataLen1111:$dataLen getDataLength:${data.length} data:$data");
|
||||
if (dataLen! + 14 > data.length) {
|
||||
// 当前包的长度小于实际的包时 分包添加 不解析
|
||||
allData.addAll(data);
|
||||
} else {
|
||||
// 当前包的长度小于实际的包时 不分包 解析
|
||||
allData.addAll(data);
|
||||
// AppLog.log("dataLen2222:$dataLen getDataLength:${data.length}");
|
||||
CommandReciverManager.appDataReceive(allData);
|
||||
// 发送完解析初始化数组
|
||||
allData = <int>[];
|
||||
}
|
||||
} else {
|
||||
} else if (allDataHeadCorrect) {
|
||||
// 当包没有头时 是分包的包 直接添加
|
||||
allData.addAll(data);
|
||||
// var len = allData[8] * 256 + allData[9];
|
||||
// AppLog.log("dataLen3333:$dataLen allData.length:${allData.length} allData:$allData");
|
||||
if (((dataLen ?? 0) + 14) <= allData.length) {
|
||||
// 当长度小于等于当前包的数据时 直接解析数据
|
||||
CommandReciverManager.appDataReceive(allData);
|
||||
@ -532,24 +469,30 @@ class BlueManage {
|
||||
await characteristic.setNotifyValue(true);
|
||||
}
|
||||
|
||||
//判断数据头是否正确
|
||||
bool isDataHeadCorrect(List<int> data) {
|
||||
if (data.length < 4) {
|
||||
return false;
|
||||
}
|
||||
//239, 1, 238, 2, 是数据包头
|
||||
if ((data[0] == 0xEF) &&
|
||||
(data[1] == 0x01) &&
|
||||
(data[2] == 0xEE) &&
|
||||
(data[3] == 0x02)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 写入
|
||||
Future<void> writeCharacteristicWithResponse(List<int> value) async {
|
||||
final List<BluetoothService> services =
|
||||
await bluetoothConnectDevice!.discoverServices();
|
||||
for (final BluetoothService service in services) {
|
||||
// AppLog.log("33333 service.remoteId:${service.remoteId}"
|
||||
// " service.uuid:${service.uuid}\n\n"
|
||||
// " service.characteristics:${service.characteristics}\n\n"
|
||||
// " service.includedServices:${service.includedServices}");
|
||||
if (service.uuid == _serviceIdConnect) {
|
||||
for (final BluetoothCharacteristic characteristic
|
||||
in service.characteristics) {
|
||||
// AppLog.log("44444 characteristic.remoteId:${characteristic.remoteId}"
|
||||
// " characteristic.uuid:${characteristic.uuid}\n\n"
|
||||
// " characteristic.secondaryServiceUuid:${characteristic
|
||||
// .secondaryServiceUuid}\n\n"
|
||||
// " characteristic.characteristicUuid:${characteristic
|
||||
// .characteristicUuid}");
|
||||
if (characteristic.characteristicUuid == _characteristicIdWrite) {
|
||||
try {
|
||||
final List<int> valueList = value;
|
||||
@ -558,22 +501,10 @@ class BlueManage {
|
||||
for (int i = 0; i < subData.length; i++) {
|
||||
if (characteristic.properties.writeWithoutResponse) {
|
||||
// 使用WRITE_NO_RESPONSE属性写入值
|
||||
await characteristic
|
||||
.write(subData[i], withoutResponse: true)
|
||||
.then((value) async {
|
||||
// await Future.delayed(const Duration(milliseconds: 1)).then((
|
||||
// value) async {
|
||||
// AppLog.log('分包发送成功了');
|
||||
// });
|
||||
});
|
||||
await characteristic.write(subData[i], withoutResponse: true);
|
||||
} else if (characteristic.properties.write) {
|
||||
// 使用WRITE属性写入值
|
||||
await characteristic.write(subData[i]).then((value) async {
|
||||
// await Future.delayed(const Duration(milliseconds: 1)).then((
|
||||
// value) async {
|
||||
// AppLog.log('分包发送成功了');
|
||||
// });
|
||||
});
|
||||
await characteristic.write(subData[i]);
|
||||
} else {
|
||||
// 特性不支持写入
|
||||
throw Exception(
|
||||
@ -588,28 +519,6 @@ class BlueManage {
|
||||
}
|
||||
}
|
||||
}
|
||||
// List<BluetoothService> services = await bluetoothConnectDevice!.discoverServices();
|
||||
// BluetoothCharacteristic characteristic = services
|
||||
// .firstWhere((service) => service.uuid == _serviceIdWrite)
|
||||
// .characteristics
|
||||
// .firstWhere((char) => char.uuid == _characteristicIdWrite);
|
||||
// try {
|
||||
// List<int> valueList = value;
|
||||
// List subData = splitList(valueList, _mtuSize!);
|
||||
// AppLog.log('writeCharacteristicWithResponse 得到的分割数据:$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 {
|
||||
// AppLog.log('分包发送成功了');
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// } on Exception catch (e, s) {
|
||||
// AppLog.log('Error occurred when writing: $e');
|
||||
// AppLog.log(s);
|
||||
// rethrow;
|
||||
// }
|
||||
}
|
||||
|
||||
// 停止扫描蓝牙设备
|
||||
@ -624,16 +533,12 @@ class BlueManage {
|
||||
// 断开连接
|
||||
Future<void> disconnect() async {
|
||||
try {
|
||||
// if(bluetoothConnectDevice != null && bluetoothConnectDevice!.connectionState == BluetoothConnectionState.connected){
|
||||
connectDeviceMacAddress = '';
|
||||
if (bluetoothConnectionState == BluetoothConnectionState.connected) {
|
||||
// await writeNull();
|
||||
// await Future.delayed(const Duration(milliseconds: 1000));
|
||||
//加快蓝牙断连
|
||||
await bluetoothConnectDevice!.disconnect(timeout: 2);
|
||||
await bluetoothConnectDevice!.disconnect(timeout: 3);
|
||||
AppLog.log('断开连接成功');
|
||||
}
|
||||
// }
|
||||
} on Exception catch (e, _) {
|
||||
AppLog.log('断开连接失败: $e');
|
||||
} finally {
|
||||
@ -641,7 +546,7 @@ class BlueManage {
|
||||
}
|
||||
}
|
||||
|
||||
openBlue() async {
|
||||
Future<void> openBlue() async {
|
||||
if (Platform.isAndroid) {
|
||||
await FlutterBluePlus.turnOn();
|
||||
}
|
||||
@ -650,10 +555,9 @@ class BlueManage {
|
||||
}
|
||||
}
|
||||
|
||||
disposed() {
|
||||
void disposed() {
|
||||
_sendStreamSubscription?.cancel();
|
||||
_mtuSubscription!.cancel();
|
||||
// _scanResultsSubscription!.cancel();
|
||||
_adapterStateStateSubscription!.cancel();
|
||||
_connectionStateSubscription!.cancel();
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import '../app_settings/app_settings.dart';
|
||||
import 'io_type.dart';
|
||||
|
||||
abstract class Reply{
|
||||
Reply.parseData(this.commandType, List<int> dataDetail);
|
||||
|
||||
CommandType? commandType;
|
||||
|
||||
@ -13,122 +14,121 @@ abstract class Reply{
|
||||
int status = 0;
|
||||
List<int> data = [];
|
||||
static String logTag= '锁 -> App,指令订阅类型 :';
|
||||
Reply.parseData(this.commandType, List<int> dataDetail);
|
||||
|
||||
void errorWithStstus(int status){
|
||||
switch(status){
|
||||
case 0x00:
|
||||
// 成功
|
||||
AppLog.log("$logTag ${commandType?.typeName} 0x00 成功");
|
||||
AppLog.log('$logTag ${commandType?.typeName} 0x00 成功');
|
||||
break;
|
||||
case 0x01:
|
||||
// 包格式错误
|
||||
AppLog.log("$logTag ${commandType!.typeName} 0x01 包格式错误");
|
||||
showErrorMessage("包格式错误");
|
||||
AppLog.log('$logTag ${commandType!.typeName} 0x01 包格式错误');
|
||||
showErrorMessage('包格式错误');
|
||||
break;
|
||||
case 0x02:
|
||||
// 密码错误
|
||||
AppLog.log("$logTag ${commandType!.typeName} 0x02 密码错误");
|
||||
showErrorMessage("密码错误");
|
||||
AppLog.log('$logTag ${commandType!.typeName} 0x02 密码错误');
|
||||
showErrorMessage('密码错误');
|
||||
break;
|
||||
case 0x03:
|
||||
// 网络中断
|
||||
AppLog.log("$logTag ${commandType!.typeName} 0x03 网络中断");
|
||||
showErrorMessage("网络中断");
|
||||
AppLog.log('$logTag ${commandType!.typeName} 0x03 网络中断');
|
||||
showErrorMessage('网络中断');
|
||||
break;
|
||||
case 0x04:
|
||||
// 用户未登记
|
||||
AppLog.log("$logTag ${commandType!.typeName} 0x04 用户未登记");
|
||||
showErrorMessage("用户未登记");
|
||||
AppLog.log('$logTag ${commandType!.typeName} 0x04 用户未登记');
|
||||
showErrorMessage('用户未登记');
|
||||
break;
|
||||
case 0x05:
|
||||
// 参数错误
|
||||
AppLog.log("$logTag ${commandType!.typeName} 0x05 参数错误");
|
||||
showErrorMessage("参数错误");
|
||||
AppLog.log('$logTag ${commandType!.typeName} 0x05 参数错误');
|
||||
showErrorMessage('参数错误');
|
||||
break;
|
||||
case 0x06:
|
||||
// 需要鉴权
|
||||
AppLog.log("$logTag ${commandType!.typeName} 0x06 需要鉴权");
|
||||
AppLog.log('$logTag ${commandType!.typeName} 0x06 需要鉴权');
|
||||
// showErrorMessage("需要鉴权");
|
||||
break;
|
||||
case 0x07:
|
||||
// 无权限
|
||||
AppLog.log("$logTag ${commandType!.typeName} 0x07 无权限");
|
||||
AppLog.log('$logTag ${commandType!.typeName} 0x07 无权限');
|
||||
// showErrorMessage("无权限");
|
||||
break;
|
||||
case 0x08:
|
||||
// 应答超时
|
||||
AppLog.log("$logTag ${commandType!.typeName} 0x08 应答超时");
|
||||
showErrorMessage("应答超时");
|
||||
AppLog.log('$logTag ${commandType!.typeName} 0x08 应答超时');
|
||||
showErrorMessage('应答超时');
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
AppLog.log("$logTag ${commandType!.typeName} 0x09 权限校验错误");
|
||||
showErrorMessage("权限校验错误");
|
||||
AppLog.log('$logTag ${commandType!.typeName} 0x09 权限校验错误');
|
||||
showErrorMessage('权限校验错误');
|
||||
break;
|
||||
case 0x0a:
|
||||
// 钥匙不存在
|
||||
showErrorMessage("钥匙不存在");
|
||||
AppLog.log("$logTag ${commandType!.typeName} 0x0a 钥匙不存在");
|
||||
showErrorMessage('钥匙不存在');
|
||||
AppLog.log('$logTag ${commandType!.typeName} 0x0a 钥匙不存在');
|
||||
break;
|
||||
case 0x0b:
|
||||
// 钥匙过期
|
||||
showErrorMessage("钥匙过期");
|
||||
AppLog.log("$logTag ${commandType!.typeName} 0x0b 钥匙过期");
|
||||
showErrorMessage('钥匙过期');
|
||||
AppLog.log('$logTag ${commandType!.typeName} 0x0b 钥匙过期');
|
||||
break;
|
||||
case 0x0c:
|
||||
// 钥匙数量已到上限
|
||||
showErrorMessage("钥匙数量已到上限");
|
||||
AppLog.log("$logTag ${commandType!.typeName} 0x0c 钥匙数量已到上限");
|
||||
showErrorMessage('钥匙数量已到上限');
|
||||
AppLog.log('$logTag ${commandType!.typeName} 0x0c 钥匙数量已到上限');
|
||||
break;
|
||||
case 0x0d:
|
||||
// 钥匙无效
|
||||
showErrorMessage("钥匙无效");
|
||||
AppLog.log("$logTag ${commandType!.typeName} 0x0d 钥匙无效");
|
||||
showErrorMessage('钥匙无效');
|
||||
AppLog.log('$logTag ${commandType!.typeName} 0x0d 钥匙无效');
|
||||
break;
|
||||
case 0x0e:
|
||||
// 钥匙已存在
|
||||
showErrorMessage("钥匙已存在");
|
||||
AppLog.log("$logTag ${commandType!.typeName} 0x0e 钥匙已存在");
|
||||
showErrorMessage('钥匙已存在');
|
||||
AppLog.log('$logTag ${commandType!.typeName} 0x0e 钥匙已存在');
|
||||
break;
|
||||
case 0x0f:
|
||||
// 用户已存在
|
||||
AppLog.log("$logTag ${commandType!.typeName} 0x0f 用户已存在");
|
||||
showErrorMessage("用户已存在");
|
||||
AppLog.log('$logTag ${commandType!.typeName} 0x0f 用户已存在');
|
||||
showErrorMessage('用户已存在');
|
||||
break;
|
||||
case 0x10:
|
||||
// 密码失效
|
||||
AppLog.log("$logTag ${commandType!.typeName} 0x11 密码失效");
|
||||
showErrorMessage("密码失效");
|
||||
AppLog.log('$logTag ${commandType!.typeName} 0x11 密码失效');
|
||||
showErrorMessage('密码失效');
|
||||
break;
|
||||
case 0x11:
|
||||
// 无效指令
|
||||
AppLog.log("$logTag ${commandType!.typeName} 0x11 无效指令");
|
||||
showErrorMessage("无效指令");
|
||||
AppLog.log('$logTag ${commandType!.typeName} 0x11 无效指令');
|
||||
showErrorMessage('无效指令');
|
||||
break;
|
||||
case 0x12:
|
||||
// 门锁时间异常
|
||||
AppLog.log("$logTag ${commandType!.typeName} 0x12 门锁时间异常");
|
||||
showErrorMessage("门锁时间异常");
|
||||
AppLog.log('$logTag ${commandType!.typeName} 0x12 门锁时间异常');
|
||||
showErrorMessage('门锁时间异常');
|
||||
break;
|
||||
case 0x15:
|
||||
// APP(手机)未联网
|
||||
AppLog.log("$logTag ${commandType!.typeName} 0x15 APP(手机)未联网");
|
||||
showErrorMessage("APP(手机)未联网");
|
||||
AppLog.log('$logTag ${commandType!.typeName} 0x15 APP(手机)未联网');
|
||||
showErrorMessage('APP(手机)未联网');
|
||||
break;
|
||||
case 0x16:
|
||||
// 正在开锁中...
|
||||
AppLog.log("$logTag ${commandType!.typeName} $status 正在开锁中...");
|
||||
showErrorMessage("正在开锁中...");
|
||||
AppLog.log('$logTag ${commandType!.typeName} $status 正在开锁中...');
|
||||
showErrorMessage('正在开锁中...');
|
||||
break;
|
||||
case 0xff:
|
||||
// 异常,未知错误
|
||||
AppLog.log("$logTag ${commandType!.typeName} 0xff 异常,未知错误");
|
||||
showErrorMessage("异常,未知错误");
|
||||
AppLog.log('$logTag ${commandType!.typeName} 0xff 异常,未知错误');
|
||||
showErrorMessage('异常,未知错误');
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
AppLog.log("$logTag ${commandType!.typeName} $status 蓝牙返回其他错误问题");
|
||||
AppLog.log('$logTag ${commandType!.typeName} $status 蓝牙返回其他错误问题');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ abstract class SenderProtocol extends IOData {
|
||||
? '子命令:${data[3]}' : ''} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}");
|
||||
}
|
||||
|
||||
//TODO:拼装数据Ï
|
||||
//TODO:拼装数据
|
||||
List<int> packageData() {
|
||||
commandData = messageDetail();
|
||||
List<int> commandList = [];
|
||||
|
||||
@ -47,12 +47,12 @@ import 'io_tool/manager_event_bus.dart';
|
||||
import 'sm4Encipher/sm4.dart';
|
||||
|
||||
class CommandReciverManager {
|
||||
static void appDataReceive(List<int> data) async {
|
||||
static Future<void> appDataReceive(List<int> data) async {
|
||||
///解析数据
|
||||
if (data.isEmpty) {
|
||||
return;
|
||||
}
|
||||
int dataSize = data.length;
|
||||
final int dataSize = data.length;
|
||||
// 当小于包头加起来13个字节
|
||||
if (dataSize < 13) {
|
||||
return;
|
||||
@ -62,20 +62,20 @@ class CommandReciverManager {
|
||||
(data[1] == 0x01) &&
|
||||
(data[2] == 0xEE) &&
|
||||
(data[3] == 0x02)) {
|
||||
var tmpType = (data[7] & 0x0f); // 包标识
|
||||
// AppLog.log("temType:$tmpType");
|
||||
final int tmpType = data[7] & 0x0f; // 包标识
|
||||
// AppLog.log('temType:$tmpType');
|
||||
|
||||
var dataLen = data[8] * 256 + data[9]; // 高16位用来指示后面数据块内容的长度
|
||||
var oriLen = data[10] * 256 + data[11]; // 低16位用来指示数据加密前的原长度
|
||||
final int dataLen = data[8] * 256 + data[9]; // 高16位用来指示后面数据块内容的长度
|
||||
final int oriLen = data[10] * 256 + data[11]; // 低16位用来指示数据加密前的原长度
|
||||
// AppLog.log("dataLen:$dataLen oriLen:$oriLen");
|
||||
List<int> oriDataList = [];
|
||||
List<int> oriDataList = <int>[];
|
||||
switch (tmpType) {
|
||||
case 0: //不加密
|
||||
// for (var i = 0; i < oriLen ; i++) {
|
||||
// oriDataList.add(data[12 + i]);
|
||||
// }
|
||||
oriDataList = data.sublist(12, 12 + dataLen);
|
||||
AppLog.log("不加密 :$oriDataList");
|
||||
AppLog.log('不加密 :$oriDataList');
|
||||
break;
|
||||
case 1:
|
||||
//AES128
|
||||
@ -83,7 +83,7 @@ class CommandReciverManager {
|
||||
case 2:
|
||||
// SM4(事先约定密钥)
|
||||
// 获取的加密数组
|
||||
var getDataList = data.sublist(12, 12 + dataLen);
|
||||
final List<int> getDataList = data.sublist(12, 12 + dataLen);
|
||||
|
||||
// 解密
|
||||
// String key = SM4.createHexKey(key: IoManager().getCurrentDeviceLockId);
|
||||
@ -91,39 +91,39 @@ class CommandReciverManager {
|
||||
key: utf8.encode(BlueManage().connectDeviceName),
|
||||
mode: SM4CryptoMode.ECB);
|
||||
oriDataList = oriDataList.sublist(0, oriLen);
|
||||
AppLog.log("APP收到的解密后的数据:$oriDataList");
|
||||
AppLog.log('APP收到的解密后的数据:$oriDataList');
|
||||
break;
|
||||
case 3:
|
||||
//SM4(设备指定密钥)
|
||||
// 获取的加密数组
|
||||
var getDataList = data.sublist(12, 12 + dataLen);
|
||||
final List<int> getDataList = data.sublist(12, 12 + dataLen);
|
||||
|
||||
var res = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(res!);
|
||||
final List<String>? res = await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList = changeStringListToIntList(res!);
|
||||
|
||||
// 解密
|
||||
oriDataList = SM4.decrypt(getDataList,
|
||||
key: getPrivateKeyList, mode: SM4CryptoMode.ECB);
|
||||
oriDataList = oriDataList.sublist(0, oriLen);
|
||||
AppLog.log("APP收到的解密后的数据:$oriDataList");
|
||||
AppLog.log('APP收到的解密后的数据:$oriDataList data:$data');
|
||||
break;
|
||||
}
|
||||
parseData(oriDataList).then((Reply? value) async {
|
||||
EasyLoading.dismiss();
|
||||
await EventBusManager().eventBusFir(value);
|
||||
}).catchError((error) {
|
||||
AppLog.log("APP解析数据时发生错误: $error");
|
||||
AppLog.log('APP解析数据时发生错误: $error');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Reply?> parseData(List<int> data) async {
|
||||
if (data.isNotEmpty) {
|
||||
var cmd = data[0] * 256 + data[1];
|
||||
CommandType commandType = ExtensionCommandType.getCommandType(cmd);
|
||||
final int cmd = data[0] * 256 + data[1];
|
||||
final CommandType commandType = ExtensionCommandType.getCommandType(cmd);
|
||||
await IoManager().increaseCommandIndex();
|
||||
// data.removeRange(0, 2);
|
||||
var reply;
|
||||
Reply? reply;
|
||||
switch (commandType) {
|
||||
case CommandType.getLockPublicKey:
|
||||
{
|
||||
@ -204,7 +204,7 @@ class CommandReciverManager {
|
||||
case CommandType.generalExtendedCommond:
|
||||
{
|
||||
// 子命令类型
|
||||
int subType = data[3];
|
||||
final int subType = data[3];
|
||||
switch (subType) {
|
||||
case 2:
|
||||
{
|
||||
@ -437,5 +437,6 @@ class CommandReciverManager {
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,4 +70,13 @@ class XSConstantMacro {
|
||||
static int catEyeWorkModeStayCapture = 2; //逗留抓拍模式
|
||||
static int catEyeWorkModeRealTimeMonitoring = 3; //实时监控模式
|
||||
static int catEyeWorkModeCustom = 4; //自定义模式
|
||||
|
||||
//管理员类型
|
||||
static int userTypeSuperAdmin = 110301; //超级管理员
|
||||
static int userTypeAuthorizedAdmin = 110302; //授权管理员
|
||||
|
||||
|
||||
//电子钥匙类型
|
||||
static int keyRightAdmin = 1; //管理钥匙
|
||||
static int keyRightOrdinary = 2; //普通钥匙
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bugly_plugin/flutter_bugly_plugin.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/appRouters.dart';
|
||||
import 'package:star_lock/blue/blue_manage.dart';
|
||||
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
||||
import 'package:star_lock/mine/mine/starLockMine_state.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
@ -47,11 +48,10 @@ class StarLockLoginLogic extends BaseGetXController {
|
||||
Storage.saveLoginData(entity.data);
|
||||
Storage.setBool(saveIsVip, entity.data!.isVip == 0 ? false : true);
|
||||
eventBus.fire(MineInfoChangeRefreshUI());
|
||||
// Get.back();
|
||||
// Get.toNamed(Routers.starLockMain);
|
||||
XSJPushProvider().initJPushService();
|
||||
XSJPushProvider().initLocalNotification(false);
|
||||
Get.offNamedUntil(Routers.starLockMain, (Route route) => false);
|
||||
BlueManage().scanDevices.clear(); //清除设备缓存
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -73,7 +73,7 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
||||
|
||||
// 转移权限
|
||||
Future<void> transferPermissionsAction() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
|
||||
@ -147,7 +147,7 @@ class AddICCardLogic extends BaseGetXController{
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
Get.close(1);
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
cancelBlueConnetctToastTimer();
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
@ -193,7 +193,7 @@ class AddICCardLogic extends BaseGetXController{
|
||||
|
||||
// 取消添加指纹
|
||||
Future<void> senderCancelAddCardCommand() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -100,7 +100,7 @@ class CardDetailLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
@ -229,7 +229,7 @@ class CardListLogic extends BaseGetXController {
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
@ -105,7 +105,7 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -257,7 +257,7 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
@ -313,7 +313,7 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
|
||||
@ -107,7 +107,7 @@ class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -259,7 +259,7 @@ class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
@ -315,7 +315,7 @@ class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/checkingIn/checkingInSet/checkingInSet_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockSet/lockSet/checkingInInfoData_entity.dart';
|
||||
|
||||
import '../../../../network/api_repository.dart';
|
||||
import '../../../../tools/baseGetXController.dart';
|
||||
@ -9,96 +11,94 @@ import '../../../../tools/dateTool.dart';
|
||||
import '../../../../tools/eventBusEventManage.dart';
|
||||
import 'checkingInSet_state.dart';
|
||||
|
||||
class CheckingInSetLogic extends BaseGetXController{
|
||||
class CheckingInSetLogic extends BaseGetXController {
|
||||
CheckingInSetState state = CheckingInSetState();
|
||||
|
||||
// 开启考勤获取是否有公司
|
||||
void openCheckingInData() async{
|
||||
var entity = await ApiRepository.to.openCheckingInData(
|
||||
lockId:state.getKeyInfosData.value.lockId.toString(),
|
||||
Future<void> openCheckingInData() async {
|
||||
final CheckingInInfoDataEntity entity = await ApiRepository.to.openCheckingInData(
|
||||
lockId: state.getKeyInfosData.value.lockId.toString(),
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.companyId.value = entity.data!.companyId.toString();
|
||||
getCheckInSetInfoData();
|
||||
}
|
||||
}
|
||||
|
||||
// 获取获取考勤设置信息
|
||||
void getCheckInSetInfoData() async{
|
||||
var entity = await ApiRepository.to.getCheckInSetInfoData(
|
||||
Future<void> getCheckInSetInfoData() async {
|
||||
final CheckingInSetEntity entity = await ApiRepository.to.getCheckInSetInfoData(
|
||||
companyId: state.companyId.value,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.checkingInSetInfo.value = entity.data!;
|
||||
|
||||
state.beginTime.value = DateTool().dateToHNString(state.checkingInSetInfo.value.workStartTime.toString());
|
||||
state.endTime.value = DateTool().dateToHNString(state.checkingInSetInfo.value.workEndTime.toString());
|
||||
state.beginTimeTimestamp.value = state.checkingInSetInfo.value.workStartTime.toString();
|
||||
state.endTimeTimestamp.value = state.checkingInSetInfo.value.workEndTime.toString();
|
||||
state.beginTime.value = DateTool().dateToHNString(
|
||||
state.checkingInSetInfo.value.workStartTime.toString());
|
||||
state.endTime.value = DateTool()
|
||||
.dateToHNString(state.checkingInSetInfo.value.workEndTime.toString());
|
||||
state.beginTimeTimestamp.value =
|
||||
state.checkingInSetInfo.value.workStartTime.toString();
|
||||
state.endTimeTimestamp.value =
|
||||
state.checkingInSetInfo.value.workEndTime.toString();
|
||||
|
||||
state.weekDays.value = state.checkingInSetInfo.value.workDay!;
|
||||
state.weekDaysStr.value = state.weekDays.value.join(",");
|
||||
state.isCustom.value = (state.checkingInSetInfo.value.attendanceType! == 0) ? true : false;
|
||||
state.weekDaysStr.value = state.weekDays.join(',');
|
||||
state.isCustom.value = state.checkingInSetInfo.value.attendanceType! == 0;
|
||||
|
||||
state.staffNumber.value = state.checkingInSetInfo.value.staffNum!.toString();
|
||||
state.staffNumber.value =
|
||||
state.checkingInSetInfo.value.staffNum!.toString();
|
||||
state.companyName.value = state.checkingInSetInfo.value.companyName!;
|
||||
state.changeNameController.text = state.companyName.value;
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑考勤设置信息
|
||||
void editCheckInSetInfoData() async{
|
||||
var entity = await ApiRepository.to.editCheckInSetInfoData(
|
||||
Future<void> editCheckInSetInfoData() async {
|
||||
final LoginEntity entity = await ApiRepository.to.editCheckInSetInfoData(
|
||||
attendanceType: state.checkingInSetInfo.value.attendanceType.toString(),
|
||||
companyId: state.checkingInSetInfo.value.companyId.toString(),
|
||||
type: "1",
|
||||
type: '1',
|
||||
companyName: state.changeNameController.text,
|
||||
workEndTime: state.checkingInSetInfo.value.workEndTime.toString(),
|
||||
workStartTime: state.checkingInSetInfo.value.workStartTime.toString(),
|
||||
workDay:state.checkingInSetInfo.value.workDay!,
|
||||
workDay: state.checkingInSetInfo.value.workDay!,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.companyName.value = state.changeNameController.text;
|
||||
showToast("修改成功");
|
||||
showToast('修改成功');
|
||||
}
|
||||
}
|
||||
|
||||
// 删除公司
|
||||
void deletCompanyData() async{
|
||||
var entity = await ApiRepository.to.deletCompanyData(
|
||||
companyId:state.checkingInSetInfo.value.companyId!,
|
||||
Future<void> deletCompanyData() async {
|
||||
final CheckingInInfoDataEntity entity = await ApiRepository.to.deletCompanyData(
|
||||
companyId: state.checkingInSetInfo.value.companyId!,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(0, "0"));
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(0, '0'));
|
||||
Get.close(2);
|
||||
}
|
||||
}
|
||||
|
||||
late StreamSubscription _teamEvent;
|
||||
|
||||
void _initLoadDataAction() {
|
||||
_teamEvent = eventBus.on<RefreshCheckInSetDataEvent>().listen((event) {
|
||||
_teamEvent = eventBus.on<RefreshCheckInSetDataEvent>().listen((RefreshCheckInSetDataEvent event) {
|
||||
getCheckInSetInfoData();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
|
||||
_initLoadDataAction();
|
||||
openCheckingInData();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
_teamEvent.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,13 +73,7 @@ class _CheckingInSetPageState extends State<CheckingInSetPage> {
|
||||
'checkingInSetInfo': state.checkingInSetInfo.value,
|
||||
});
|
||||
if(data != null) {
|
||||
setState(() {
|
||||
// state.beginTime.value = data["beginTime"];
|
||||
// state.endTime.value = data["endTime"];
|
||||
// state.beginTimeTimestamp.value = data["beginTimeTimestamp"];
|
||||
// state.endTimeTimestamp.value = data["endTimeTimestamp"];
|
||||
logic.getCheckInSetInfoData();
|
||||
});
|
||||
setState(logic.getCheckInSetInfoData);
|
||||
}
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
@ -98,7 +92,7 @@ class _CheckingInSetPageState extends State<CheckingInSetPage> {
|
||||
if(data != null) {
|
||||
state.isCustom.value = data['attendanceType'];
|
||||
state.weekDays.value = data['weekDays'];
|
||||
state.weekDaysStr.value = state.weekDays.value.join(',');
|
||||
state.weekDaysStr.value = state.weekDays.join(',');
|
||||
}
|
||||
})),
|
||||
CommonItem(
|
||||
@ -125,9 +119,7 @@ class _CheckingInSetPageState extends State<CheckingInSetPage> {
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 20.w),
|
||||
padding: EdgeInsets.only(top: 20.w, bottom: 20.w),
|
||||
onClick: () {
|
||||
ShowTipView().showIosTipWithContentDialog('是否删除?'.tr, () {
|
||||
logic.deletCompanyData();
|
||||
});
|
||||
ShowTipView().showIosTipWithContentDialog('是否删除?'.tr, logic.deletCompanyData);
|
||||
// showDeletCompanyAlertDialog(context);
|
||||
}),
|
||||
),
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
@ -72,7 +70,7 @@ class CheckingInAddStaffLogic extends BaseGetXController {
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.keyEntity.value = entity.data!;
|
||||
kyClickCallback(state.keyEntity.value);
|
||||
kyClickCallback(state.keyEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,6 +80,11 @@ class CheckingInAddStaffLogic extends BaseGetXController {
|
||||
if (state.appUnHaveAccount.value && state.staffAccount.contains('@')) {
|
||||
usernameType = '2';
|
||||
}
|
||||
// 当是app且没有钥匙时,直接把账号赋值给attendanceWayNumber
|
||||
if (state.appUnHaveAccount.value &&
|
||||
state.selectPrintingMethodType.value == '1') {
|
||||
state.attendanceWayNumber.value = state.staffAccountController.text;
|
||||
}
|
||||
|
||||
final LoginEntity entity = await ApiRepository.to.editStaffData(
|
||||
attendanceType: state.selectPrintingMethodType.value,
|
||||
@ -151,25 +154,15 @@ class CheckingInAddStaffLogic extends BaseGetXController {
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
_initLoadDataAction();
|
||||
|
||||
changeInput(state.staffNameController);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
|
||||
_getNumberEvent!.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@ -214,15 +214,18 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
child: Container(
|
||||
height: 40.h,
|
||||
padding: EdgeInsets.only(
|
||||
left: 25.w, right: 25.w, top: 2.h),
|
||||
left: 25.w,
|
||||
right: 25.w,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.mainColor,
|
||||
borderRadius: BorderRadius.circular(20.h),
|
||||
),
|
||||
child: Text(addStaffSelectKeyType(),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontSize: 22.sp)),
|
||||
child: Center(
|
||||
child: Text(addStaffSelectKeyType(),
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontSize: 22.sp)),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@ -145,9 +145,21 @@ class _CheckingInStaffListPageState extends State<CheckingInStaffListPage> {
|
||||
SizedBox(
|
||||
width: 20.w,
|
||||
),
|
||||
// CustomNetworkImage(url: staffListItem.headurl!, width: 40.w , height: 40.w),
|
||||
Image.asset(getTypeIcon(staffListItem.attendanceType!),
|
||||
width: 60.w, height: 60.w),
|
||||
if (staffListItem.headurl == null || staffListItem.headurl == '')
|
||||
Image.asset(
|
||||
getTypeIcon(staffListItem.attendanceType!),
|
||||
width: 60.w,
|
||||
height: 60.w,
|
||||
)
|
||||
else
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(100.w),
|
||||
child: Image.network(
|
||||
staffListItem.headurl!,
|
||||
width: 60.w,
|
||||
height: 60.w,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 20.w,
|
||||
),
|
||||
|
||||
@ -106,7 +106,7 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState connectionStateState) async {
|
||||
if (connectionStateState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
|
||||
@ -255,16 +255,18 @@ class ElectronicKeyDetailLogic extends BaseGetXController {
|
||||
|
||||
Future<void> openModalBottomSheet(BuildContext context) async {
|
||||
List<String> textList = <String>[];
|
||||
if (state.itemData.value.keyRight == 1) {
|
||||
final bool isAdminKey = state.itemData.value.keyRight == 1;
|
||||
final bool isLockOwner = CommonDataManage().currentKeyInfo.isLockOwner == 1;
|
||||
if (isAdminKey) {
|
||||
// 授权管理员
|
||||
textList = <String>[
|
||||
if (state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen)
|
||||
'取消冻结'.tr
|
||||
else
|
||||
'冻结'.tr,
|
||||
// '取消授权'.tr
|
||||
if (isLockOwner) '取消授权'.tr
|
||||
];
|
||||
} else if (CommonDataManage().currentKeyInfo.isLockOwner == 1) {
|
||||
} else if (isLockOwner) {
|
||||
// 锁拥有者
|
||||
if (state.keyType.value == 1 || state.keyType.value == 2) {
|
||||
textList = <String>[
|
||||
|
||||
@ -186,7 +186,7 @@ class AddFaceLogic extends BaseGetXController {
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
Get.close(1);
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
cancelBlueConnetctToastTimer();
|
||||
@ -231,7 +231,7 @@ class AddFaceLogic extends BaseGetXController {
|
||||
|
||||
// 取消添加指纹
|
||||
Future<void> senderCancelAddFaceCommand() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -97,7 +97,7 @@ class FaceDetailLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
|
||||
@ -256,7 +256,7 @@ class FaceListLogic extends BaseGetXController {
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
|
||||
|
||||
@ -185,7 +185,7 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
Get.close(1);
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -227,7 +227,7 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
|
||||
// 取消添加指纹
|
||||
Future<void> senderCancelAddFingerprintCommand() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -98,7 +98,7 @@ class FingerprintDetailLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
@ -189,7 +189,7 @@ class FingerprintListLogic extends BaseGetXController{
|
||||
}
|
||||
// 获取指纹状态
|
||||
Future<void> senderQueryingFingerprintStatus() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,(BluetoothConnectionState state) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,(BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -217,7 +217,7 @@ class FingerprintListLogic extends BaseGetXController{
|
||||
|
||||
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
||||
Future<void> senderCheckingUserInfoCount() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -248,7 +248,7 @@ class FingerprintListLogic extends BaseGetXController{
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
@ -90,7 +90,7 @@ class IrisDetailLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
|
||||
@ -189,7 +189,7 @@ class IrisListLogic extends BaseGetXController {
|
||||
|
||||
// 获取人脸状态
|
||||
Future<void> senderQueryingFaceStatus() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
@ -218,7 +218,7 @@ class IrisListLogic extends BaseGetXController {
|
||||
|
||||
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
||||
Future<void> senderCheckingUserInfoCount() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
@ -250,7 +250,7 @@ class IrisListLogic extends BaseGetXController {
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
|
||||
@ -37,17 +37,17 @@ class LockDetailLogic extends BaseGetXController {
|
||||
void initReplySubscription() {
|
||||
state.replySubscription =
|
||||
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
|
||||
// 开门
|
||||
if (reply is OpenDoorReply && state.ifCurrentScreen.value == true) {
|
||||
_replyOpenLock(reply);
|
||||
}
|
||||
// 开门
|
||||
if (reply is OpenDoorReply && state.ifCurrentScreen.value == true) {
|
||||
_replyOpenLock(reply);
|
||||
}
|
||||
|
||||
// 开完锁之后上传记录
|
||||
if (reply is SenderReferEventRecordTimeReply &&
|
||||
state.ifCurrentScreen.value == true) {
|
||||
_replyReferEventRecordTime(reply);
|
||||
}
|
||||
});
|
||||
// 开完锁之后上传记录
|
||||
if (reply is SenderReferEventRecordTimeReply &&
|
||||
state.ifCurrentScreen.value == true) {
|
||||
_replyReferEventRecordTime(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 开门数据解析
|
||||
@ -56,19 +56,18 @@ class LockDetailLogic extends BaseGetXController {
|
||||
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
// _showFullScreenOverlay(Get.context!);
|
||||
cancelBlueConnetctToastTimer();
|
||||
|
||||
//成功
|
||||
// _showFullScreenOverlay(Get.context!);
|
||||
state.iSClosedUnlockSuccessfulPopup.value = true;
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.closedUnlockSuccessfulTimer?.cancel();
|
||||
// 如果没有点击关闭弹窗,3秒后自动关闭
|
||||
state.closedUnlockSuccessfulTimer =
|
||||
Timer.periodic(3.seconds, (Timer timer) {
|
||||
state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||
timer.cancel();
|
||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||
});
|
||||
state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||
timer.cancel();
|
||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||
});
|
||||
|
||||
// 电量
|
||||
final int power = reply.data[7];
|
||||
@ -81,19 +80,20 @@ class LockDetailLogic extends BaseGetXController {
|
||||
}
|
||||
// 更新电量
|
||||
uploadElectricQuantityRequest();
|
||||
|
||||
//锁数据更新
|
||||
getLockRecordLastUploadDataTime();
|
||||
resetOpenDoorState();
|
||||
state.animationController!.stop();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
//无权限
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList =
|
||||
changeStringListToIntList(privateKey!);
|
||||
changeStringListToIntList(privateKey!);
|
||||
|
||||
final List<String>? signKey =
|
||||
await Storage.getStringList(saveBlueSignKey);
|
||||
await Storage.getStringList(saveBlueSignKey);
|
||||
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
final List<int> tokenData = reply.data.sublist(2, 6);
|
||||
@ -113,71 +113,58 @@ class LockDetailLogic extends BaseGetXController {
|
||||
);
|
||||
break;
|
||||
case 0x16:
|
||||
// 正在开锁中...
|
||||
// 正在开锁中...
|
||||
resetOpenDoorState();
|
||||
showToast('正在开锁中...'.tr, something: () {
|
||||
cancelBlueConnetctToastTimer();
|
||||
});
|
||||
break;
|
||||
case 0x0d:
|
||||
// 钥匙无效
|
||||
// 钥匙无效
|
||||
showToast('钥匙无效'.tr);
|
||||
// state.animationController!.stop();
|
||||
resetOpenDoorState();
|
||||
cancelBlueConnetctToastTimer();
|
||||
BlueManage().disconnect();
|
||||
openDoorError();
|
||||
break;
|
||||
case 0x0b:
|
||||
// 钥匙无效
|
||||
// 钥匙无效
|
||||
showToast('钥匙过期'.tr);
|
||||
resetOpenDoorState();
|
||||
|
||||
cancelBlueConnetctToastTimer();
|
||||
BlueManage().disconnect();
|
||||
openDoorError();
|
||||
break;
|
||||
case 0x0a:
|
||||
// 钥匙不存在
|
||||
// 钥匙不存在
|
||||
showToast('钥匙不存在');
|
||||
resetOpenDoorState();
|
||||
|
||||
cancelBlueConnetctToastTimer();
|
||||
BlueManage().disconnect();
|
||||
openDoorError();
|
||||
break;
|
||||
case 0x0c:
|
||||
// 钥匙数量已到上限
|
||||
// 钥匙数量已到上限
|
||||
showToast('钥匙数量已到上限');
|
||||
resetOpenDoorState();
|
||||
|
||||
cancelBlueConnetctToastTimer();
|
||||
BlueManage().disconnect();
|
||||
openDoorError();
|
||||
break;
|
||||
case 0x0e:
|
||||
// 钥匙已存在
|
||||
// 钥匙已存在
|
||||
showToast('钥匙已存在');
|
||||
resetOpenDoorState();
|
||||
|
||||
cancelBlueConnetctToastTimer();
|
||||
BlueManage().disconnect();
|
||||
openDoorError();
|
||||
break;
|
||||
case 0x0f:
|
||||
// 用户已存在
|
||||
// 用户已存在
|
||||
showToast('用户已存在');
|
||||
resetOpenDoorState();
|
||||
|
||||
cancelBlueConnetctToastTimer();
|
||||
BlueManage().disconnect();
|
||||
openDoorError();
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
//失败
|
||||
AppLog.log('开锁失败');
|
||||
// state.animationController!.stop();
|
||||
resetOpenDoorState();
|
||||
cancelBlueConnetctToastTimer();
|
||||
BlueManage().disconnect();
|
||||
openDoorError();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//开门指令失败
|
||||
void openDoorError() {
|
||||
resetOpenDoorState();
|
||||
state.animationController!.stop();
|
||||
cancelBlueConnetctToastTimer();
|
||||
BlueManage().disconnect();
|
||||
}
|
||||
|
||||
//清除开锁动画以及状态
|
||||
void closeLuckStatus() {
|
||||
state.openLockBtnState.value = 0;
|
||||
@ -190,67 +177,67 @@ class LockDetailLogic extends BaseGetXController {
|
||||
Future<void> _replyReferEventRecordTime(Reply reply) async {
|
||||
final int status = reply.data[2];
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
final int dataLength = (reply.data[5] << 8) + reply.data[6];
|
||||
// AppLog.log("dataLength:$dataLength");
|
||||
if (dataLength > 0) {
|
||||
reply.data.removeRange(0, 7);
|
||||
// 把得到的数据按17个字节分割成数组 然后塞进一个新的数组里面
|
||||
if (reply.data.length < 17) {
|
||||
return;
|
||||
}
|
||||
final List<List<int>> getList = splitList(reply.data, 17);
|
||||
// AppLog.log("getList:$getList");
|
||||
final List uploadList = [];
|
||||
for (int i = 0; i < getList.length; i++) {
|
||||
final List<int> indexList = getList[i];
|
||||
// AppLog.log("indexList:$indexList");
|
||||
final Map indexMap = {};
|
||||
indexMap['type'] = indexList[0].toString();
|
||||
int operateDate = 0;
|
||||
if (indexList[0] == 2) {
|
||||
final List<int> passwordData = reply.data.sublist(7, 17);
|
||||
final String password = utf8String(passwordData);
|
||||
indexMap['user'] = password.toString();
|
||||
} else {
|
||||
final int userNo = (indexList[1] * 256) + indexList[2];
|
||||
indexMap['user'] = userNo.toString();
|
||||
}
|
||||
case 0x00:
|
||||
//成功
|
||||
final int dataLength = (reply.data[5] << 8) + reply.data[6];
|
||||
// AppLog.log("dataLength:$dataLength");
|
||||
if (dataLength > 0) {
|
||||
reply.data.removeRange(0, 7);
|
||||
// 把得到的数据按17个字节分割成数组 然后塞进一个新的数组里面
|
||||
if (reply.data.length < 17) {
|
||||
return;
|
||||
}
|
||||
final List<List<int>> getList = splitList(reply.data, 17);
|
||||
// AppLog.log("getList:$getList");
|
||||
final List uploadList = [];
|
||||
for (int i = 0; i < getList.length; i++) {
|
||||
final List<int> indexList = getList[i];
|
||||
// AppLog.log("indexList:$indexList");
|
||||
final Map indexMap = {};
|
||||
indexMap['type'] = indexList[0].toString();
|
||||
int operateDate = 0;
|
||||
if (indexList[0] == 2) {
|
||||
final List<int> passwordData = reply.data.sublist(7, 17);
|
||||
final String password = utf8String(passwordData);
|
||||
indexMap['user'] = password.toString();
|
||||
} else {
|
||||
final int userNo = (indexList[1] * 256) + indexList[2];
|
||||
indexMap['user'] = userNo.toString();
|
||||
}
|
||||
|
||||
indexMap['success'] = '1';
|
||||
indexMap['success'] = '1';
|
||||
|
||||
final int time = ((0xff & indexList[(3)]) << 24 |
|
||||
(0xff & indexList[4]) << 16 |
|
||||
(0xff & indexList[5]) << 8 |
|
||||
(0xFF & indexList[6]));
|
||||
operateDate = time * 1000;
|
||||
indexMap['date'] = '$operateDate';
|
||||
uploadList.add(indexMap);
|
||||
final int time = ((0xff & indexList[(3)]) << 24 |
|
||||
(0xff & indexList[4]) << 16 |
|
||||
(0xff & indexList[5]) << 8 |
|
||||
(0xFF & indexList[6]));
|
||||
operateDate = time * 1000;
|
||||
indexMap['date'] = '$operateDate';
|
||||
uploadList.add(indexMap);
|
||||
|
||||
if (i == getList.length - 1) {
|
||||
//设置最后的时间戳
|
||||
state.operateDate = operateDate;
|
||||
}
|
||||
}
|
||||
lockRecordUploadData(uploadList);
|
||||
if (i == getList.length - 1) {
|
||||
//设置最后的时间戳
|
||||
state.operateDate = operateDate;
|
||||
}
|
||||
}
|
||||
lockRecordUploadData(uploadList);
|
||||
|
||||
if (dataLength == state.logCountPage) {
|
||||
senderReferEventRecordTime();
|
||||
} else {
|
||||
await BlueManage().disconnect();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
BlueManage().disconnect();
|
||||
cancelBlueConnetctToastTimer();
|
||||
break;
|
||||
default:
|
||||
BlueManage().disconnect();
|
||||
cancelBlueConnetctToastTimer();
|
||||
break;
|
||||
if (dataLength == state.logCountPage) {
|
||||
senderReferEventRecordTime();
|
||||
} else {
|
||||
await BlueManage().disconnect();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
BlueManage().disconnect();
|
||||
cancelBlueConnetctToastTimer();
|
||||
break;
|
||||
default:
|
||||
BlueManage().disconnect();
|
||||
cancelBlueConnetctToastTimer();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -258,11 +245,11 @@ class LockDetailLogic extends BaseGetXController {
|
||||
Future<void> openDoorAction() async {
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
resetOpenDoorState();
|
||||
// BlueManage().stopScan();
|
||||
closeLuckStatus();
|
||||
BlueManage().disconnect();
|
||||
});
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
@ -272,89 +259,84 @@ class LockDetailLogic extends BaseGetXController {
|
||||
final List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
BlueManage()
|
||||
.bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!,
|
||||
.blueSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
IoSenderManage.senderOpenLock(
|
||||
keyID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
openMode: state.openDoorModel,
|
||||
openTime: getUTCNetTime(),
|
||||
onlineToken: state.lockNetToken,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
} else if (deviceConnectionState ==
|
||||
BluetoothConnectionState.disconnected) {
|
||||
cancelBlueConnetctToastTimer();
|
||||
if (state.ifCurrentScreen.value == true) {
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
IoSenderManage.senderOpenLock(
|
||||
keyID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
openMode: state.openDoorModel,
|
||||
openTime: getUTCNetTime(),
|
||||
onlineToken: state.lockNetToken,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
} else if (deviceConnectionState ==
|
||||
BluetoothConnectionState.disconnected) {
|
||||
cancelBlueConnetctToastTimer();
|
||||
if (state.ifCurrentScreen.value == true) {
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
|
||||
resetOpenDoorState();
|
||||
}
|
||||
});
|
||||
resetOpenDoorState();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 查询事件记录(时间查询)
|
||||
Future<void> senderReferEventRecordTime() async {
|
||||
void senderReferEventRecordTime() {
|
||||
showBlueConnetctToastTimer(
|
||||
isShowBlueConnetctToast: false,
|
||||
outTimer: 10,
|
||||
action: () {
|
||||
closeLuckStatus();
|
||||
BlueManage().disconnect();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
final List<String>? privateKey =
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList =
|
||||
final List<int> getPrivateKeyList =
|
||||
changeStringListToIntList(privateKey!);
|
||||
|
||||
final List<String>? token = await Storage.getStringList(
|
||||
saveBlueToken);
|
||||
final List<int> getTokenList = changeStringListToIntList(token!);
|
||||
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||
final List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
final List<String>? publicKey =
|
||||
final List<String>? publicKey =
|
||||
await Storage.getStringList(saveBluePublicKey);
|
||||
final List<int> getPublicKeyList =
|
||||
final List<int> getPublicKeyList =
|
||||
changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.senderReferEventRecordTimeCommand(
|
||||
keyID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
logsCount: state.logCountPage,
|
||||
// time:DateTime.now().millisecondsSinceEpoch~/1000,
|
||||
time: state.operateDate,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
}
|
||||
});
|
||||
IoSenderManage.senderReferEventRecordTimeCommand(
|
||||
keyID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
logsCount: state.logCountPage,
|
||||
// time:DateTime.now().millisecondsSinceEpoch~/1000,
|
||||
time: state.operateDate,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 从服务器获取锁的时间 开锁时传入
|
||||
void getServerDatetime() async {
|
||||
final GetServerDatetimeEntity entity =
|
||||
await ApiRepository.to.getServerDatetimeData();
|
||||
await ApiRepository.to.getServerDatetimeData();
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.differentialTime = entity.data!.date! ~/ 1000 -
|
||||
DateTime
|
||||
.now()
|
||||
.millisecondsSinceEpoch ~/ 1000;
|
||||
DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||
// AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}");
|
||||
}
|
||||
}
|
||||
|
||||
int getUTCNetTime() {
|
||||
return DateTime
|
||||
.now()
|
||||
.millisecondsSinceEpoch ~/ 1000 +
|
||||
return DateTime.now().millisecondsSinceEpoch ~/ 1000 +
|
||||
state.differentialTime;
|
||||
}
|
||||
|
||||
@ -380,11 +362,11 @@ class LockDetailLogic extends BaseGetXController {
|
||||
Future<void> uploadElectricQuantityRequest() async {
|
||||
final KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
.uploadElectricQuantity(
|
||||
electricQuantity: state.electricQuantity.value.toString(),
|
||||
electricQuantityStandby:
|
||||
state.electricQuantityStandby.value.toString(),
|
||||
lockId: state.keyInfos.value.lockId.toString(),
|
||||
isUnShowLoading: true);
|
||||
electricQuantity: state.electricQuantity.value.toString(),
|
||||
electricQuantityStandby:
|
||||
state.electricQuantityStandby.value.toString(),
|
||||
lockId: state.keyInfos.value.lockId.toString(),
|
||||
isUnShowLoading: true);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
eventBus.fire(RefreshLockListInfoDataEvent(isUnShowLoading: true));
|
||||
@ -395,8 +377,8 @@ class LockDetailLogic extends BaseGetXController {
|
||||
// 查询锁记录最后时间
|
||||
void getLockRecordLastUploadDataTime() async {
|
||||
final LockOperatingRecordGetLastRecordTimeEntity entity =
|
||||
await ApiRepository.to.getLockRecordLastUploadDataTime(
|
||||
lockId: state.keyInfos.value.lockId.toString());
|
||||
await ApiRepository.to.getLockRecordLastUploadDataTime(
|
||||
lockId: state.keyInfos.value.lockId.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.operateDate = entity.data!.operateDate! ~/ 1000;
|
||||
senderReferEventRecordTime();
|
||||
@ -407,7 +389,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
Future<void> lockRecordUploadData(List list) async {
|
||||
final KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
.lockRecordUploadData(
|
||||
lockId: state.keyInfos.value.lockId.toString(), records: list);
|
||||
lockId: state.keyInfos.value.lockId.toString(), records: list);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
// mockNetworkDataRequest();
|
||||
AppLog.log(
|
||||
@ -423,7 +405,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
void deletKeyData() async {
|
||||
final ElectronicKeyListEntity entity = await ApiRepository.to
|
||||
.deleteElectronicKey(
|
||||
keyId: state.keyInfos.value.keyId.toString(), includeUnderlings: 0);
|
||||
keyId: state.keyInfos.value.keyId.toString(), includeUnderlings: 0);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
BlueManage().connectDeviceMacAddress = '';
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
@ -440,51 +422,50 @@ class LockDetailLogic extends BaseGetXController {
|
||||
eventBus
|
||||
.on<LockSetChangeSetRefreshLockDetailWithType>()
|
||||
.listen((LockSetChangeSetRefreshLockDetailWithType event) {
|
||||
if (event.type == 0) {
|
||||
// 0考勤
|
||||
state.isAttendance.value = int.parse(event.setResult);
|
||||
state.keyInfos.value.lockSetting!.attendance =
|
||||
int.parse(event.setResult);
|
||||
} else if (event.type == 1) {
|
||||
// 1 开锁时是否需联网
|
||||
state.isOpenLockNeedOnline.value = int.parse(event.setResult);
|
||||
state.keyInfos.value.lockSetting!.appUnlockOnline =
|
||||
int.parse(event.setResult);
|
||||
state.lockNetToken = ''; // 改变开锁时是否联网状态的时候清空token
|
||||
} else if (event.type == 2) {
|
||||
// 2 常开模式
|
||||
state.isOpenPassageMode.value = int.parse(event.setResult);
|
||||
state.keyInfos.value.passageMode = int.parse(event.setResult);
|
||||
} else if (event.type == 3) {
|
||||
// 3 修改了锁名字
|
||||
state.lockAlias.value = event.setResult;
|
||||
state.keyInfos.value.lockAlias = event.setResult;
|
||||
Storage.setString(saveLockAlias, state.lockAlias.value);
|
||||
} else if (event.type == 4) {
|
||||
// 4 更新了电量
|
||||
state.electricQuantity.value = int.parse(event.setResult);
|
||||
state.keyInfos.value.electricQuantity = int.parse(event.setResult);
|
||||
} else if (event.type == 5) {
|
||||
// 5 远程开锁
|
||||
state.keyInfos.value.lockSetting!.remoteUnlock =
|
||||
int.parse(event.setResult);
|
||||
}
|
||||
CommonDataManage().currentKeyInfo = state.keyInfos.value;
|
||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||
});
|
||||
if (event.type == 0) {
|
||||
// 0考勤
|
||||
state.isAttendance.value = int.parse(event.setResult);
|
||||
state.keyInfos.value.lockSetting!.attendance =
|
||||
int.parse(event.setResult);
|
||||
} else if (event.type == 1) {
|
||||
// 1 开锁时是否需联网
|
||||
state.isOpenLockNeedOnline.value = int.parse(event.setResult);
|
||||
state.keyInfos.value.lockSetting!.appUnlockOnline =
|
||||
int.parse(event.setResult);
|
||||
state.lockNetToken = ''; // 改变开锁时是否联网状态的时候清空token
|
||||
} else if (event.type == 2) {
|
||||
// 2 常开模式
|
||||
state.isOpenPassageMode.value = int.parse(event.setResult);
|
||||
state.keyInfos.value.passageMode = int.parse(event.setResult);
|
||||
} else if (event.type == 3) {
|
||||
// 3 修改了锁名字
|
||||
state.lockAlias.value = event.setResult;
|
||||
state.keyInfos.value.lockAlias = event.setResult;
|
||||
Storage.setString(saveLockAlias, state.lockAlias.value);
|
||||
} else if (event.type == 4) {
|
||||
// 4 更新了电量
|
||||
state.electricQuantity.value = int.parse(event.setResult);
|
||||
state.keyInfos.value.electricQuantity = int.parse(event.setResult);
|
||||
} else if (event.type == 5) {
|
||||
// 5 远程开锁
|
||||
state.keyInfos.value.lockSetting!.remoteUnlock =
|
||||
int.parse(event.setResult);
|
||||
}
|
||||
CommonDataManage().currentKeyInfo = state.keyInfos.value;
|
||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||
});
|
||||
}
|
||||
|
||||
String getKeyStatusTextAndShow() {
|
||||
String text = '';
|
||||
if (state.keyInfos.value.keyStatus ==
|
||||
XSConstantMacro.keyStatusWaitIneffective ||
|
||||
XSConstantMacro.keyStatusWaitIneffective ||
|
||||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusFrozen ||
|
||||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusExpired ||
|
||||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusDeleted ||
|
||||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusReset) {
|
||||
text =
|
||||
"${"你的钥匙".tr}${XSConstantMacro.getKeyStatusStr(
|
||||
state.keyInfos.value.keyStatus!)}";
|
||||
"${"你的钥匙".tr}${XSConstantMacro.getKeyStatusStr(state.keyInfos.value.keyStatus!)}";
|
||||
} else {
|
||||
text = state.isOpenPassageMode.value == 1
|
||||
? '常开模式启动!长按闭锁'.tr
|
||||
@ -517,8 +498,8 @@ class LockDetailLogic extends BaseGetXController {
|
||||
await PermissionDialog.request(Permission.location);
|
||||
await PermissionDialog.requestBluetooth();
|
||||
|
||||
final String connectDeviceName = state.keyInfos.value.bluetooth!
|
||||
.bluetoothDeviceName!;
|
||||
final String connectDeviceName =
|
||||
state.keyInfos.value.bluetooth!.bluetoothDeviceName!;
|
||||
if (!BlueManage().isExistScanDevices(connectDeviceName)) {
|
||||
BlueManage().startScanSingle(
|
||||
connectDeviceName, 15, (List<ScanResult> p0) => null);
|
||||
@ -528,6 +509,5 @@ class LockDetailLogic extends BaseGetXController {
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1249,9 +1249,10 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
),
|
||||
Positioned(
|
||||
top: 180.h,
|
||||
left: 55.w,
|
||||
width: 358.w,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
state.keyInfos.value.lockAlias!,
|
||||
@ -1318,15 +1319,13 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
}
|
||||
}
|
||||
|
||||
void startOpenLock() {
|
||||
void startOpenLock() {
|
||||
if (state.openLockBtnState.value == 1) {
|
||||
return;
|
||||
}
|
||||
state.iSOpenLock.value = true;
|
||||
state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||
state.openLockBtnState.value = 1;
|
||||
state.animationController!.forward();
|
||||
|
||||
AppLog.log('点击开锁');
|
||||
if (state.isOpenLockNeedOnline.value == 0) {
|
||||
// 不需要联网
|
||||
@ -1346,10 +1345,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
return;
|
||||
}
|
||||
state.iSOpenLock.value = false;
|
||||
state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||
state.openLockBtnState.value = 1;
|
||||
state.animationController!.forward();
|
||||
|
||||
EasyLoading.showToast('正在尝试闭锁……'.tr, duration: 2000.milliseconds);
|
||||
AppLog.log('长按闭锁');
|
||||
if (state.isOpenLockNeedOnline.value == 0) {
|
||||
|
||||
@ -97,7 +97,7 @@ class LockOperatingRecordLogic extends BaseGetXController {
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionStateState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionStateState) async {
|
||||
if (connectionStateState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -116,7 +116,7 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -188,7 +188,7 @@ class AdminOpenLockPasswordLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
@ -50,7 +50,7 @@ class UploadElectricQuantityLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
dismissEasyLoading();
|
||||
|
||||
@ -99,7 +99,7 @@ class BurglarAlarmLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -136,7 +136,7 @@ class ConfiguringWifiLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected){
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -113,7 +113,7 @@ class WifiListLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected){
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
@ -80,7 +80,7 @@ class LockEscalationLogic extends BaseGetXController {
|
||||
|
||||
//蓝牙操作 ota 升级
|
||||
void blueOTAUpgrade(Map data, List<int> token) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
|
||||
@ -245,7 +245,7 @@ class LockSetLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
showDeletAlertTipDialog();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -306,7 +306,7 @@ class LockSetLogic extends BaseGetXController {
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -103,7 +103,7 @@ class LockSoundSetLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -103,7 +103,7 @@ class LockTimeLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -84,7 +84,7 @@ class MotorPowerLogic extends BaseGetXController {
|
||||
|
||||
// 读取支持功能-带参数
|
||||
Future<void> _readSupportFunctionsNoParameters() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -110,7 +110,7 @@ class MotorPowerLogic extends BaseGetXController {
|
||||
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendOpenDoorDirection() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -120,7 +120,7 @@ class NormallyOpenModeLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -86,7 +86,7 @@ class OpenDoorDirectionLogic extends BaseGetXController {
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendOpenDoorDirection() async {
|
||||
showEasyLoading();
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
dismissEasyLoading();
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
|
||||
@ -109,7 +109,7 @@ class RemoteUnlockingLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
|
||||
@ -98,7 +98,7 @@ class ResetButtonLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -89,7 +89,7 @@ class PalmDetailLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
|
||||
@ -185,7 +185,7 @@ class PalmListLogic extends BaseGetXController {
|
||||
|
||||
// 获取人脸状态
|
||||
Future<void> senderQueryingFaceStatus() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
@ -214,7 +214,7 @@ class PalmListLogic extends BaseGetXController {
|
||||
|
||||
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
||||
Future<void> senderCheckingUserInfoCount() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
@ -246,7 +246,7 @@ class PalmListLogic extends BaseGetXController {
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
|
||||
@ -127,7 +127,7 @@ class PasswordKeyDetailLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
@ -121,7 +121,7 @@ class PasswordKeyDetailChangeDateLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
@ -128,7 +128,7 @@ class PasswordKeyListLogic extends BaseGetXController {
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
@ -177,7 +177,7 @@ class PasswordKeyListLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
@ -342,7 +342,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
@ -252,6 +252,11 @@ class LockListInfoItemEntity {
|
||||
data['hasGateway'] = hasGateway;
|
||||
return data;
|
||||
}
|
||||
|
||||
//是否是锁拥有者 也代表是超级管理员
|
||||
bool isLockOwnerBool(){
|
||||
return isLockOwner== 1;
|
||||
}
|
||||
}
|
||||
|
||||
class Bluetooth {
|
||||
|
||||
@ -181,7 +181,7 @@ class LockListLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
showDeletAlertTipDialog();
|
||||
});
|
||||
BlueManage().bludSendData(state.lockListInfoItemEntity.lockName!, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(state.lockListInfoItemEntity.lockName!, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
List<int> publicKeyData = state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>();
|
||||
var saveStrList = changeIntListToStringList(publicKeyData);
|
||||
|
||||
@ -108,7 +108,7 @@ class DebugConsoleController {
|
||||
return;
|
||||
}
|
||||
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
@ -179,7 +179,7 @@ class DebugConsoleController {
|
||||
tokenList = changeStringListToIntList(tokenKey!);
|
||||
}
|
||||
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
IoSenderManage.senderCleanUpUsersCommand(
|
||||
|
||||
@ -54,7 +54,7 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
// state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(deviceName,
|
||||
BlueManage().blueSendData(deviceName,
|
||||
(BluetoothConnectionState state) async {
|
||||
AppLog.log("点击要添加的设备了");
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
@ -415,7 +415,7 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
void oTAUpgrade(String deviceName) {
|
||||
showTitleEasyLoading("连接设备中...");
|
||||
this.deviceName = deviceName;
|
||||
BlueManage().bludSendData(deviceName,
|
||||
BlueManage().blueSendData(deviceName,
|
||||
(BluetoothConnectionState state) async {
|
||||
AppLog.log("连接设备");
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
@ -460,7 +460,7 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
AppLog.log('blueOTAUpgrade:设备名字为 null');
|
||||
return;
|
||||
}
|
||||
BlueManage().bludSendData(deviceName!,
|
||||
BlueManage().blueSendData(deviceName!,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
String uid = await Storage.getUid() ?? '';
|
||||
|
||||
@ -212,7 +212,7 @@ class SaveLockLogic extends BaseGetXController {
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
// 私钥
|
||||
|
||||
@ -94,7 +94,7 @@ class ExpireCardLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(state.deletExpireCardItemEntity.lockInfo!.btDeviceName!, (BluetoothConnectionState deviceConnectionState) async {
|
||||
BlueManage().blueSendData(state.deletExpireCardItemEntity.lockInfo!.btDeviceName!, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
@ -95,7 +95,7 @@ class ExpireFingerprintLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(state.deletExpireFingerprintItemEntity.lockInfo!.btDeviceName!, (BluetoothConnectionState deviceConnectionState) async {
|
||||
BlueManage().blueSendData(state.deletExpireFingerprintItemEntity.lockInfo!.btDeviceName!, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
@ -5,7 +5,7 @@ import 'package:get/get_connect/http/src/request/request.dart';
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
|
||||
FutureOr<dynamic> responseLogInterceptor(Request request, Response response) {
|
||||
AppLog.log('HTTP request:${request.url}\n RESPONSE => stataCode:${response.statusCode} ${response.bodyString}'); // \n ${response.headers}
|
||||
// AppLog.log('HTTP request:${request.url}\n RESPONSE => stataCode:${response.statusCode} ${response.bodyString}'); // \n ${response.headers}
|
||||
EasyLoading.dismiss(animation: true);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -54,8 +54,9 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
# 1.0.44+2024052002:打包给公司测试
|
||||
# 1.0.45+2024052003:打包给公司测试
|
||||
# 1.0.46+2024052004:打包给公司测试
|
||||
# 1.0.47+2024052101:打包给欧阳回归测试
|
||||
|
||||
version: 1.0.46+2024052004
|
||||
version: 1.0.47+2024052101
|
||||
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user