feat:解决硬件多次发数据包的问题

This commit is contained in:
anfe 2024-05-21 15:33:06 +08:00
parent f05f74be0f
commit 4c68c60f1d
50 changed files with 374 additions and 488 deletions

View File

@ -17,6 +17,12 @@ typedef ConnectStateCallBack = Function(
typedef ScanDevicesCallBack = Function(List<ScanResult>); typedef ScanDevicesCallBack = Function(List<ScanResult>);
class BlueManage { class BlueManage {
factory BlueManage() => shareManager()!;
BlueManage._init() {
_initBlue();
}
final List<ScanResult> scanDevices = <ScanResult>[]; final List<ScanResult> scanDevices = <ScanResult>[];
// id // id
@ -34,12 +40,6 @@ class BlueManage {
// //
StreamSubscription<EventSendModel>? _sendStreamSubscription; StreamSubscription<EventSendModel>? _sendStreamSubscription;
//
// StreamSubscription? _scanSubscription;
//
// StreamSubscription<dynamic>? _currentConnectionStream;
// StreamSubscription<List<ScanResult>>? _scanResultsSubscription;
StreamSubscription<BluetoothConnectionState>? _connectionStateSubscription; StreamSubscription<BluetoothConnectionState>? _connectionStateSubscription;
StreamSubscription<int>? _mtuSubscription; StreamSubscription<int>? _mtuSubscription;
@ -64,11 +64,14 @@ class BlueManage {
BluetoothAdapterState? _adapterState = BluetoothAdapterState.unknown; BluetoothAdapterState? _adapterState = BluetoothAdapterState.unknown;
StreamSubscription<BluetoothAdapterState>? _adapterStateStateSubscription; 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() { static BlueManage? shareManager() {
_manager ??= BlueManage._init(); _manager ??= BlueManage._init();
@ -76,16 +79,12 @@ class BlueManage {
return _manager; return _manager;
} }
factory BlueManage() => shareManager()!;
BlueManage? get manager => shareManager(); BlueManage? get manager => shareManager();
void _initBlue() { void _initBlue() {
FlutterBluePlus.setLogLevel(LogLevel.error, color: true); FlutterBluePlus.setLogLevel(LogLevel.error, color: true);
_initSendStreamSubscription(); _initSendStreamSubscription();
_initAdapterStateStateSubscription(); _initAdapterStateStateSubscription();
// _initListenscanResults();
// _initListenConnectionState();
} }
void _initGetMtuSubscription() { 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() { void _initListenConnectionState() {
_connectionStateSubscription?.cancel(); _connectionStateSubscription?.cancel();
_connectionStateSubscription = null; _connectionStateSubscription = null;
@ -185,7 +145,7 @@ class BlueManage {
if (_adapterState == BluetoothAdapterState.on) { if (_adapterState == BluetoothAdapterState.on) {
try { try {
//android 8 //android 8
final int divisor = Platform.isAndroid ? 8 : 1; final int divisor = Platform.isAndroid ? 3 : 1;
FlutterBluePlus.startScan( FlutterBluePlus.startScan(
continuousDivisor: divisor, continuousDivisor: divisor,
continuousUpdates: true, continuousUpdates: true,
@ -316,7 +276,7 @@ class BlueManage {
} }
/// List senderData, /// List senderData,
Future<void> bludSendData( Future<void> blueSendData(
String deviceName, ConnectStateCallBack stateCallBack, String deviceName, ConnectStateCallBack stateCallBack,
{bool isAddEquipment = false}) async { {bool isAddEquipment = false}) async {
FlutterBluePlus.isSupported.then((bool isAvailable) 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) => final bool isExistDevice = scanDevices.any((ScanResult element) =>
element.device.platformName == connectDeviceName || element.device.platformName == connectDeviceName ||
element.advertisementData.advName == connectDeviceName); element.advertisementData.advName == connectDeviceName);
return isExistDevice; return isExistDevice;
} }
Future<void> _connectDevice(List<ScanResult> devicesList, String deviceName, Future<void> _connectDevice(List<ScanResult> devicesList, String deviceName,
ConnectStateCallBack connectStateCallBack, ConnectStateCallBack connectStateCallBack,
{bool isAddEquipment = false}) async { {bool isAddEquipment = false}) async {
@ -400,13 +359,9 @@ class BlueManage {
_initGetMtuSubscription(); _initGetMtuSubscription();
_initListenConnectionState(); _initListenConnectionState();
} }
// AppLog.log("1 connectDeviceId:$connectDeviceMacAddress connectDeviceName:$connectDeviceName");
// stopScan();
if (scanResult == null || connectDeviceMacAddress.isEmpty) { if (scanResult == null || connectDeviceMacAddress.isEmpty) {
// connectStateCallBack(BluetoothConnectionState.disconnected!);
return; return;
} }
// AppLog.log("调用了停止扫描的方法"); // AppLog.log("调用了停止扫描的方法");
await stopScan(); await stopScan();
@ -438,28 +393,18 @@ class BlueManage {
connectStateCallBack(BluetoothConnectionState.disconnected); connectStateCallBack(BluetoothConnectionState.disconnected);
} }
// await bluetoothConnectDevice!.connect();
if (bluetoothConnectionState == BluetoothConnectionState.connected) { if (bluetoothConnectionState == BluetoothConnectionState.connected) {
try { try {
bluetoothConnectDevice! bluetoothConnectDevice!
.discoverServices() .discoverServices()
.then((List<BluetoothService> services) { .then((List<BluetoothService> services) {
for (final BluetoothService service in 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) { if (service.uuid == _serviceIdConnect) {
for (final BluetoothCharacteristic characteristic for (final BluetoothCharacteristic characteristic
in service.characteristics) { in service.characteristics) {
// Get.log("22222characteristic.remoteId:${characteristic.remoteId}"
// " characteristic.uuid:${characteristic.uuid}"
// " characteristic.secondaryServiceUuid:${characteristic.secondaryServiceUuid}"
// " characteristic.characteristicUuid:${characteristic.characteristicUuid}");
if (characteristic.characteristicUuid == if (characteristic.characteristicUuid ==
_characteristicIdSubscription) { _characteristicIdSubscription) {
_subScribeToCharacteristic(characteristic); _subScribeToCharacteristic(characteristic);
// AppLog.log('Discovering services finished');
bluetoothConnectionState = BluetoothConnectionState.connected; bluetoothConnectionState = BluetoothConnectionState.connected;
connectStateCallBack(bluetoothConnectionState!); connectStateCallBack(bluetoothConnectionState!);
} }
@ -477,49 +422,41 @@ class BlueManage {
} }
} }
// ,
List<int> allData = <int>[];
//
List<int> lastTimeData = <int>[];
int? dataLen;
Future<void> _subScribeToCharacteristic( Future<void> _subScribeToCharacteristic(
BluetoothCharacteristic characteristic) async { BluetoothCharacteristic characteristic) async {
final StreamSubscription<List<int>> subscription = final StreamSubscription<List<int>> subscription =
characteristic.onValueReceived.listen((List<int> data) { characteristic.onValueReceived.listen((List<int> data) {
// AppLog.log("订阅获取的数据:$data"); AppLog.log('订阅获取的数据: $data ');
if (data == lastTimeData || data.isEmpty) { if (data == lastTimeData || data.isEmpty) {
return; return;
} else { } else {
lastTimeData = data; lastTimeData = data;
} }
// code to handle incoming data final bool dataHeadCorrect = isDataHeadCorrect(data);
// AppLog.log("subscribeToCharacteristic: deviceId = ${characteristic.deviceId} characteristicId =${characteristic.characteristicId}---上报来的数据data = $data"); final bool allDataHeadCorrect = isDataHeadCorrect(allData);
if ((data[0] == 0xEF) && if (dataHeadCorrect && allDataHeadCorrect) {
(data[1] == 0x01) && //
(data[2] == 0xEE) && allData = <int>[];
(data[3] == 0x02)) { }
if (dataHeadCorrect) {
// //
// //
dataLen = data[8] * 256 + data[9]; // 16 dataLen = data[8] * 256 + data[9]; // 16
// AppLog.log("dataLen1111:$dataLen getDataLength:${data.length} data:$data");
if (dataLen! + 14 > data.length) { if (dataLen! + 14 > data.length) {
// //
allData.addAll(data); allData.addAll(data);
} else { } else {
// //
allData.addAll(data); allData.addAll(data);
// AppLog.log("dataLen2222:$dataLen getDataLength:${data.length}");
CommandReciverManager.appDataReceive(allData); CommandReciverManager.appDataReceive(allData);
// //
allData = <int>[]; allData = <int>[];
} }
} else { } else if (allDataHeadCorrect) {
// //
allData.addAll(data); 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) { if (((dataLen ?? 0) + 14) <= allData.length) {
// //
CommandReciverManager.appDataReceive(allData); CommandReciverManager.appDataReceive(allData);
@ -532,24 +469,30 @@ class BlueManage {
await characteristic.setNotifyValue(true); 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 { Future<void> writeCharacteristicWithResponse(List<int> value) async {
final List<BluetoothService> services = final List<BluetoothService> services =
await bluetoothConnectDevice!.discoverServices(); await bluetoothConnectDevice!.discoverServices();
for (final BluetoothService service in services) { 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) { if (service.uuid == _serviceIdConnect) {
for (final BluetoothCharacteristic characteristic for (final BluetoothCharacteristic characteristic
in service.characteristics) { 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) { if (characteristic.characteristicUuid == _characteristicIdWrite) {
try { try {
final List<int> valueList = value; final List<int> valueList = value;
@ -558,22 +501,10 @@ class BlueManage {
for (int i = 0; i < subData.length; i++) { for (int i = 0; i < subData.length; i++) {
if (characteristic.properties.writeWithoutResponse) { if (characteristic.properties.writeWithoutResponse) {
// 使WRITE_NO_RESPONSE属性写入值 // 使WRITE_NO_RESPONSE属性写入值
await characteristic await characteristic.write(subData[i], withoutResponse: true);
.write(subData[i], withoutResponse: true)
.then((value) async {
// await Future.delayed(const Duration(milliseconds: 1)).then((
// value) async {
// AppLog.log('分包发送成功了');
// });
});
} else if (characteristic.properties.write) { } else if (characteristic.properties.write) {
// 使WRITE属性写入值 // 使WRITE属性写入值
await characteristic.write(subData[i]).then((value) async { await characteristic.write(subData[i]);
// await Future.delayed(const Duration(milliseconds: 1)).then((
// value) async {
// AppLog.log('分包发送成功了');
// });
});
} else { } else {
// //
throw Exception( 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 { Future<void> disconnect() async {
try { try {
// if(bluetoothConnectDevice != null && bluetoothConnectDevice!.connectionState == BluetoothConnectionState.connected){
connectDeviceMacAddress = ''; connectDeviceMacAddress = '';
if (bluetoothConnectionState == BluetoothConnectionState.connected) { if (bluetoothConnectionState == BluetoothConnectionState.connected) {
// await writeNull();
// await Future.delayed(const Duration(milliseconds: 1000));
// //
await bluetoothConnectDevice!.disconnect(timeout: 2); await bluetoothConnectDevice!.disconnect(timeout: 3);
AppLog.log('断开连接成功'); AppLog.log('断开连接成功');
} }
// }
} on Exception catch (e, _) { } on Exception catch (e, _) {
AppLog.log('断开连接失败: $e'); AppLog.log('断开连接失败: $e');
} finally { } finally {
@ -641,7 +546,7 @@ class BlueManage {
} }
} }
openBlue() async { Future<void> openBlue() async {
if (Platform.isAndroid) { if (Platform.isAndroid) {
await FlutterBluePlus.turnOn(); await FlutterBluePlus.turnOn();
} }
@ -650,10 +555,9 @@ class BlueManage {
} }
} }
disposed() { void disposed() {
_sendStreamSubscription?.cancel(); _sendStreamSubscription?.cancel();
_mtuSubscription!.cancel(); _mtuSubscription!.cancel();
// _scanResultsSubscription!.cancel();
_adapterStateStateSubscription!.cancel(); _adapterStateStateSubscription!.cancel();
_connectionStateSubscription!.cancel(); _connectionStateSubscription!.cancel();
} }

View File

@ -6,6 +6,7 @@ import '../app_settings/app_settings.dart';
import 'io_type.dart'; import 'io_type.dart';
abstract class Reply{ abstract class Reply{
Reply.parseData(this.commandType, List<int> dataDetail);
CommandType? commandType; CommandType? commandType;
@ -13,122 +14,121 @@ abstract class Reply{
int status = 0; int status = 0;
List<int> data = []; List<int> data = [];
static String logTag= '锁 -> App指令订阅类型 :'; static String logTag= '锁 -> App指令订阅类型 :';
Reply.parseData(this.commandType, List<int> dataDetail);
void errorWithStstus(int status){ void errorWithStstus(int status){
switch(status){ switch(status){
case 0x00: case 0x00:
// //
AppLog.log("$logTag ${commandType?.typeName} 0x00 成功"); AppLog.log('$logTag ${commandType?.typeName} 0x00 成功');
break; break;
case 0x01: case 0x01:
// //
AppLog.log("$logTag ${commandType!.typeName} 0x01 包格式错误"); AppLog.log('$logTag ${commandType!.typeName} 0x01 包格式错误');
showErrorMessage("包格式错误"); showErrorMessage('包格式错误');
break; break;
case 0x02: case 0x02:
// //
AppLog.log("$logTag ${commandType!.typeName} 0x02 密码错误"); AppLog.log('$logTag ${commandType!.typeName} 0x02 密码错误');
showErrorMessage("密码错误"); showErrorMessage('密码错误');
break; break;
case 0x03: case 0x03:
// //
AppLog.log("$logTag ${commandType!.typeName} 0x03 网络中断"); AppLog.log('$logTag ${commandType!.typeName} 0x03 网络中断');
showErrorMessage("网络中断"); showErrorMessage('网络中断');
break; break;
case 0x04: case 0x04:
// //
AppLog.log("$logTag ${commandType!.typeName} 0x04 用户未登记"); AppLog.log('$logTag ${commandType!.typeName} 0x04 用户未登记');
showErrorMessage("用户未登记"); showErrorMessage('用户未登记');
break; break;
case 0x05: case 0x05:
// //
AppLog.log("$logTag ${commandType!.typeName} 0x05 参数错误"); AppLog.log('$logTag ${commandType!.typeName} 0x05 参数错误');
showErrorMessage("参数错误"); showErrorMessage('参数错误');
break; break;
case 0x06: case 0x06:
// //
AppLog.log("$logTag ${commandType!.typeName} 0x06 需要鉴权"); AppLog.log('$logTag ${commandType!.typeName} 0x06 需要鉴权');
// showErrorMessage("需要鉴权"); // showErrorMessage("需要鉴权");
break; break;
case 0x07: case 0x07:
// //
AppLog.log("$logTag ${commandType!.typeName} 0x07 无权限"); AppLog.log('$logTag ${commandType!.typeName} 0x07 无权限');
// showErrorMessage("无权限"); // showErrorMessage("无权限");
break; break;
case 0x08: case 0x08:
// //
AppLog.log("$logTag ${commandType!.typeName} 0x08 应答超时"); AppLog.log('$logTag ${commandType!.typeName} 0x08 应答超时');
showErrorMessage("应答超时"); showErrorMessage('应答超时');
break; break;
case 0x09: case 0x09:
// //
AppLog.log("$logTag ${commandType!.typeName} 0x09 权限校验错误"); AppLog.log('$logTag ${commandType!.typeName} 0x09 权限校验错误');
showErrorMessage("权限校验错误"); showErrorMessage('权限校验错误');
break; break;
case 0x0a: case 0x0a:
// //
showErrorMessage("钥匙不存在"); showErrorMessage('钥匙不存在');
AppLog.log("$logTag ${commandType!.typeName} 0x0a 钥匙不存在"); AppLog.log('$logTag ${commandType!.typeName} 0x0a 钥匙不存在');
break; break;
case 0x0b: case 0x0b:
// //
showErrorMessage("钥匙过期"); showErrorMessage('钥匙过期');
AppLog.log("$logTag ${commandType!.typeName} 0x0b 钥匙过期"); AppLog.log('$logTag ${commandType!.typeName} 0x0b 钥匙过期');
break; break;
case 0x0c: case 0x0c:
// //
showErrorMessage("钥匙数量已到上限"); showErrorMessage('钥匙数量已到上限');
AppLog.log("$logTag ${commandType!.typeName} 0x0c 钥匙数量已到上限"); AppLog.log('$logTag ${commandType!.typeName} 0x0c 钥匙数量已到上限');
break; break;
case 0x0d: case 0x0d:
// //
showErrorMessage("钥匙无效"); showErrorMessage('钥匙无效');
AppLog.log("$logTag ${commandType!.typeName} 0x0d 钥匙无效"); AppLog.log('$logTag ${commandType!.typeName} 0x0d 钥匙无效');
break; break;
case 0x0e: case 0x0e:
// //
showErrorMessage("钥匙已存在"); showErrorMessage('钥匙已存在');
AppLog.log("$logTag ${commandType!.typeName} 0x0e 钥匙已存在"); AppLog.log('$logTag ${commandType!.typeName} 0x0e 钥匙已存在');
break; break;
case 0x0f: case 0x0f:
// //
AppLog.log("$logTag ${commandType!.typeName} 0x0f 用户已存在"); AppLog.log('$logTag ${commandType!.typeName} 0x0f 用户已存在');
showErrorMessage("用户已存在"); showErrorMessage('用户已存在');
break; break;
case 0x10: case 0x10:
// //
AppLog.log("$logTag ${commandType!.typeName} 0x11 密码失效"); AppLog.log('$logTag ${commandType!.typeName} 0x11 密码失效');
showErrorMessage("密码失效"); showErrorMessage('密码失效');
break; break;
case 0x11: case 0x11:
// //
AppLog.log("$logTag ${commandType!.typeName} 0x11 无效指令"); AppLog.log('$logTag ${commandType!.typeName} 0x11 无效指令');
showErrorMessage("无效指令"); showErrorMessage('无效指令');
break; break;
case 0x12: case 0x12:
// //
AppLog.log("$logTag ${commandType!.typeName} 0x12 门锁时间异常"); AppLog.log('$logTag ${commandType!.typeName} 0x12 门锁时间异常');
showErrorMessage("门锁时间异常"); showErrorMessage('门锁时间异常');
break; break;
case 0x15: case 0x15:
// APP() // APP()
AppLog.log("$logTag ${commandType!.typeName} 0x15 APP(手机)未联网"); AppLog.log('$logTag ${commandType!.typeName} 0x15 APP(手机)未联网');
showErrorMessage("APP(手机)未联网"); showErrorMessage('APP(手机)未联网');
break; break;
case 0x16: case 0x16:
// ... // ...
AppLog.log("$logTag ${commandType!.typeName} $status 正在开锁中..."); AppLog.log('$logTag ${commandType!.typeName} $status 正在开锁中...');
showErrorMessage("正在开锁中..."); showErrorMessage('正在开锁中...');
break; break;
case 0xff: case 0xff:
// //
AppLog.log("$logTag ${commandType!.typeName} 0xff 异常,未知错误"); AppLog.log('$logTag ${commandType!.typeName} 0xff 异常,未知错误');
showErrorMessage("异常,未知错误"); showErrorMessage('异常,未知错误');
break; break;
default: default:
// //
AppLog.log("$logTag ${commandType!.typeName} $status 蓝牙返回其他错误问题"); AppLog.log('$logTag ${commandType!.typeName} $status 蓝牙返回其他错误问题');
break; break;
} }
} }

View File

@ -34,9 +34,9 @@ abstract class SenderProtocol extends IOData {
} }
void printLog(List<int> data) { void printLog(List<int> data) {
AppLog.log( // AppLog.log(
"App -> 锁,指令类型:${commandType!.typeName} ${commandType!.typeValue == 0x3030 // "App -> 锁,指令类型:${commandType!.typeName} ${commandType!.typeValue == 0x3030
? '子命令:${data[3]}' : ''} \n参数是:\n${toString()} \n加密之前数据是:\n$data :${data.length}"); // ? '子命令:${data[3]}' : ''} \n参数是:\n${toString()} \n加密之前数据是:\n$data :${data.length}");
} }
//TODO:Ï //TODO:Ï

View File

@ -47,12 +47,12 @@ import 'io_tool/manager_event_bus.dart';
import 'sm4Encipher/sm4.dart'; import 'sm4Encipher/sm4.dart';
class CommandReciverManager { class CommandReciverManager {
static void appDataReceive(List<int> data) async { static Future<void> appDataReceive(List<int> data) async {
/// ///
if (data.isEmpty) { if (data.isEmpty) {
return; return;
} }
int dataSize = data.length; final int dataSize = data.length;
// 13 // 13
if (dataSize < 13) { if (dataSize < 13) {
return; return;
@ -62,20 +62,20 @@ class CommandReciverManager {
(data[1] == 0x01) && (data[1] == 0x01) &&
(data[2] == 0xEE) && (data[2] == 0xEE) &&
(data[3] == 0x02)) { (data[3] == 0x02)) {
var tmpType = (data[7] & 0x0f); // final int tmpType = data[7] & 0x0f; //
// AppLog.log("temType:$tmpType"); // AppLog.log('temType:$tmpType');
var dataLen = data[8] * 256 + data[9]; // 16 final int dataLen = data[8] * 256 + data[9]; // 16
var oriLen = data[10] * 256 + data[11]; // 16 final int oriLen = data[10] * 256 + data[11]; // 16
// AppLog.log("dataLen:$dataLen oriLen:$oriLen"); // AppLog.log("dataLen:$dataLen oriLen:$oriLen");
List<int> oriDataList = []; List<int> oriDataList = <int>[];
switch (tmpType) { switch (tmpType) {
case 0: // case 0: //
// for (var i = 0; i < oriLen ; i++) { // for (var i = 0; i < oriLen ; i++) {
// oriDataList.add(data[12 + i]); // oriDataList.add(data[12 + i]);
// } // }
oriDataList = data.sublist(12, 12 + dataLen); oriDataList = data.sublist(12, 12 + dataLen);
AppLog.log("不加密 :$oriDataList"); AppLog.log('不加密 :$oriDataList');
break; break;
case 1: case 1:
//AES128 //AES128
@ -83,7 +83,7 @@ class CommandReciverManager {
case 2: case 2:
// SM4 // SM4
// //
var getDataList = data.sublist(12, 12 + dataLen); final List<int> getDataList = data.sublist(12, 12 + dataLen);
// //
// String key = SM4.createHexKey(key: IoManager().getCurrentDeviceLockId); // String key = SM4.createHexKey(key: IoManager().getCurrentDeviceLockId);
@ -91,39 +91,39 @@ class CommandReciverManager {
key: utf8.encode(BlueManage().connectDeviceName), key: utf8.encode(BlueManage().connectDeviceName),
mode: SM4CryptoMode.ECB); mode: SM4CryptoMode.ECB);
oriDataList = oriDataList.sublist(0, oriLen); oriDataList = oriDataList.sublist(0, oriLen);
AppLog.log("APP收到的解密后的数据:$oriDataList"); AppLog.log('APP收到的解密后的数据:$oriDataList');
break; break;
case 3: case 3:
//SM4 //SM4
// //
var getDataList = data.sublist(12, 12 + dataLen); final List<int> getDataList = data.sublist(12, 12 + dataLen);
var res = await Storage.getStringList(saveBluePrivateKey); final List<String>? res = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(res!); final List<int> getPrivateKeyList = changeStringListToIntList(res!);
// //
oriDataList = SM4.decrypt(getDataList, oriDataList = SM4.decrypt(getDataList,
key: getPrivateKeyList, mode: SM4CryptoMode.ECB); key: getPrivateKeyList, mode: SM4CryptoMode.ECB);
oriDataList = oriDataList.sublist(0, oriLen); oriDataList = oriDataList.sublist(0, oriLen);
AppLog.log("APP收到的解密后的数据:$oriDataList"); AppLog.log('APP收到的解密后的数据:$oriDataList data:$data');
break; break;
} }
parseData(oriDataList).then((Reply? value) async { parseData(oriDataList).then((Reply? value) async {
EasyLoading.dismiss(); EasyLoading.dismiss();
await EventBusManager().eventBusFir(value); await EventBusManager().eventBusFir(value);
}).catchError((error) { }).catchError((error) {
AppLog.log("APP解析数据时发生错误: $error"); AppLog.log('APP解析数据时发生错误: $error');
}); });
} }
} }
static Future<Reply?> parseData(List<int> data) async { static Future<Reply?> parseData(List<int> data) async {
if (data.isNotEmpty) { if (data.isNotEmpty) {
var cmd = data[0] * 256 + data[1]; final int cmd = data[0] * 256 + data[1];
CommandType commandType = ExtensionCommandType.getCommandType(cmd); final CommandType commandType = ExtensionCommandType.getCommandType(cmd);
await IoManager().increaseCommandIndex(); await IoManager().increaseCommandIndex();
// data.removeRange(0, 2); // data.removeRange(0, 2);
var reply; Reply? reply;
switch (commandType) { switch (commandType) {
case CommandType.getLockPublicKey: case CommandType.getLockPublicKey:
{ {
@ -204,7 +204,7 @@ class CommandReciverManager {
case CommandType.generalExtendedCommond: case CommandType.generalExtendedCommond:
{ {
// //
int subType = data[3]; final int subType = data[3];
switch (subType) { switch (subType) {
case 2: case 2:
{ {
@ -437,5 +437,6 @@ class CommandReciverManager {
} }
return reply; return reply;
} }
return null;
} }
} }

View File

@ -73,7 +73,7 @@ class AuthorizedAdminLogic extends BaseGetXController {
// //
Future<void> transferPermissionsAction() async { Future<void> transferPermissionsAction() async {
BlueManage().bludSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState state) async { (BluetoothConnectionState state) async {
if (state == BluetoothConnectionState.connected) { if (state == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);

View File

@ -147,7 +147,7 @@ class AddICCardLogic extends BaseGetXController{
showBlueConnetctToastTimer(action: (){ showBlueConnetctToastTimer(action: (){
Get.close(1); Get.close(1);
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected){ if (deviceConnectionState == BluetoothConnectionState.connected){
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
// var publicKey = await Storage.getStringList(saveBluePublicKey); // var publicKey = await Storage.getStringList(saveBluePublicKey);
@ -193,7 +193,7 @@ class AddICCardLogic extends BaseGetXController{
// //
Future<void> senderCancelAddCardCommand() async { Future<void> senderCancelAddCardCommand() async {
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected){ if (deviceConnectionState == BluetoothConnectionState.connected){
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);

View File

@ -100,7 +100,7 @@ class CardDetailLogic extends BaseGetXController{
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected){ if (deviceConnectionState == BluetoothConnectionState.connected){
var signKey = await Storage.getStringList(saveBlueSignKey); var signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); List<int> signKeyDataList = changeStringListToIntList(signKey!);

View File

@ -229,7 +229,7 @@ class CardListLogic extends BaseGetXController {
showBlueConnetctToastTimer(action: (){ showBlueConnetctToastTimer(action: (){
dismissEasyLoading(); dismissEasyLoading();
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected){ if (deviceConnectionState == BluetoothConnectionState.connected){
// var publicKey = await Storage.getStringList(saveBluePublicKey); // var publicKey = await Storage.getStringList(saveBluePublicKey);
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!); // List<int> publicKeyDataList = changeStringListToIntList(publicKey!);

View File

@ -105,7 +105,7 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
@ -257,7 +257,7 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected){ if (deviceConnectionState == BluetoothConnectionState.connected){
// var publicKey = await Storage.getStringList(saveBluePublicKey); // var publicKey = await Storage.getStringList(saveBluePublicKey);
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!); // List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
@ -313,7 +313,7 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected){ if (deviceConnectionState == BluetoothConnectionState.connected){
var signKey = await Storage.getStringList(saveBlueSignKey); var signKey = await Storage.getStringList(saveBlueSignKey);

View File

@ -107,7 +107,7 @@ class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
@ -259,7 +259,7 @@ class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected){ if (deviceConnectionState == BluetoothConnectionState.connected){
// var publicKey = await Storage.getStringList(saveBluePublicKey); // var publicKey = await Storage.getStringList(saveBluePublicKey);
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!); // List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
@ -315,7 +315,7 @@ class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected){ if (deviceConnectionState == BluetoothConnectionState.connected){
var signKey = await Storage.getStringList(saveBlueSignKey); var signKey = await Storage.getStringList(saveBlueSignKey);

View File

@ -106,7 +106,7 @@ class DoorLockLogLogic extends BaseGetXController {
showBlueConnetctToastTimer(action: () { showBlueConnetctToastTimer(action: () {
dismissEasyLoading(); dismissEasyLoading();
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState connectionStateState) async { (BluetoothConnectionState connectionStateState) async {
if (connectionStateState == BluetoothConnectionState.connected) { if (connectionStateState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);

View File

@ -186,7 +186,7 @@ class AddFaceLogic extends BaseGetXController {
showBlueConnetctToastTimer(action: () { showBlueConnetctToastTimer(action: () {
Get.close(1); Get.close(1);
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async { (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
@ -231,7 +231,7 @@ class AddFaceLogic extends BaseGetXController {
// //
Future<void> senderCancelAddFaceCommand() async { Future<void> senderCancelAddFaceCommand() async {
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected){ if (deviceConnectionState == BluetoothConnectionState.connected){
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);

View File

@ -97,7 +97,7 @@ class FaceDetailLogic extends BaseGetXController {
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async { (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);

View File

@ -256,7 +256,7 @@ class FaceListLogic extends BaseGetXController {
showBlueConnetctToastTimer(action: () { showBlueConnetctToastTimer(action: () {
dismissEasyLoading(); dismissEasyLoading();
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async { (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {

View File

@ -185,7 +185,7 @@ class AddFingerprintLogic extends BaseGetXController {
showBlueConnetctToastTimer(action: (){ showBlueConnetctToastTimer(action: (){
Get.close(1); Get.close(1);
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected){ if (deviceConnectionState == BluetoothConnectionState.connected){
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
@ -227,7 +227,7 @@ class AddFingerprintLogic extends BaseGetXController {
// //
Future<void> senderCancelAddFingerprintCommand() async { Future<void> senderCancelAddFingerprintCommand() async {
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected){ if (deviceConnectionState == BluetoothConnectionState.connected){
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);

View File

@ -98,7 +98,7 @@ class FingerprintDetailLogic extends BaseGetXController{
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected){ if (deviceConnectionState == BluetoothConnectionState.connected){
// var publicKey = await Storage.getStringList(saveBluePublicKey); // var publicKey = await Storage.getStringList(saveBluePublicKey);
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!); // List<int> publicKeyDataList = changeStringListToIntList(publicKey!);

View File

@ -189,7 +189,7 @@ class FingerprintListLogic extends BaseGetXController{
} }
// //
Future<void> senderQueryingFingerprintStatus() async { Future<void> senderQueryingFingerprintStatus() async {
BlueManage().bludSendData(BlueManage().connectDeviceName,(BluetoothConnectionState state) async { BlueManage().blueSendData(BlueManage().connectDeviceName,(BluetoothConnectionState state) async {
if (state == BluetoothConnectionState.connected) { if (state == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
@ -217,7 +217,7 @@ class FingerprintListLogic extends BaseGetXController{
// () // ()
Future<void> senderCheckingUserInfoCount() async { Future<void> senderCheckingUserInfoCount() async {
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async {
if (state == BluetoothConnectionState.connected) { if (state == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
@ -248,7 +248,7 @@ class FingerprintListLogic extends BaseGetXController{
showBlueConnetctToastTimer(action: (){ showBlueConnetctToastTimer(action: (){
dismissEasyLoading(); dismissEasyLoading();
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected){ if (deviceConnectionState == BluetoothConnectionState.connected){
// var publicKey = await Storage.getStringList(saveBluePublicKey); // var publicKey = await Storage.getStringList(saveBluePublicKey);
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!); // List<int> publicKeyDataList = changeStringListToIntList(publicKey!);

View File

@ -90,7 +90,7 @@ class IrisDetailLogic extends BaseGetXController {
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async { (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
// var publicKey = await Storage.getStringList(saveBluePublicKey); // var publicKey = await Storage.getStringList(saveBluePublicKey);

View File

@ -189,7 +189,7 @@ class IrisListLogic extends BaseGetXController {
// //
Future<void> senderQueryingFaceStatus() async { Future<void> senderQueryingFaceStatus() async {
BlueManage().bludSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState state) async { (BluetoothConnectionState state) async {
if (state == BluetoothConnectionState.connected) { if (state == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
@ -218,7 +218,7 @@ class IrisListLogic extends BaseGetXController {
// () // ()
Future<void> senderCheckingUserInfoCount() async { Future<void> senderCheckingUserInfoCount() async {
BlueManage().bludSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState state) async { (BluetoothConnectionState state) async {
if (state == BluetoothConnectionState.connected) { if (state == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
@ -250,7 +250,7 @@ class IrisListLogic extends BaseGetXController {
showBlueConnetctToastTimer(action: () { showBlueConnetctToastTimer(action: () {
dismissEasyLoading(); dismissEasyLoading();
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async { (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
var signKey = await Storage.getStringList(saveBlueSignKey); var signKey = await Storage.getStringList(saveBlueSignKey);

View File

@ -33,21 +33,22 @@ import 'lockNetToken_entity.dart';
class LockDetailLogic extends BaseGetXController { class LockDetailLogic extends BaseGetXController {
final LockDetailState state = LockDetailState(); final LockDetailState state = LockDetailState();
// //
void initReplySubscription() { void initReplySubscription() {
state.replySubscription = state.replySubscription =
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async { EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
// //
if (reply is OpenDoorReply && state.ifCurrentScreen.value == true) { if (reply is OpenDoorReply && state.ifCurrentScreen.value == true) {
_replyOpenLock(reply); _replyOpenLock(reply);
} }
// //
if (reply is SenderReferEventRecordTimeReply && if (reply is SenderReferEventRecordTimeReply &&
state.ifCurrentScreen.value == true) { state.ifCurrentScreen.value == true) {
_replyReferEventRecordTime(reply); _replyReferEventRecordTime(reply);
} }
}); });
} }
// //
@ -56,8 +57,8 @@ class LockDetailLogic extends BaseGetXController {
switch (status) { switch (status) {
case 0x00: case 0x00:
// //
// _showFullScreenOverlay(Get.context!); // _showFullScreenOverlay(Get.context!);
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
state.iSClosedUnlockSuccessfulPopup.value = true; state.iSClosedUnlockSuccessfulPopup.value = true;
@ -65,10 +66,10 @@ class LockDetailLogic extends BaseGetXController {
// 3 // 3
state.closedUnlockSuccessfulTimer = state.closedUnlockSuccessfulTimer =
Timer.periodic(3.seconds, (Timer timer) { Timer.periodic(3.seconds, (Timer timer) {
state.iSClosedUnlockSuccessfulPopup.value = false; state.iSClosedUnlockSuccessfulPopup.value = false;
timer.cancel(); timer.cancel();
eventBus.fire(RefreshLockDetailInfoDataEvent()); eventBus.fire(RefreshLockDetailInfoDataEvent());
}); });
// //
final int power = reply.data[7]; final int power = reply.data[7];
@ -86,14 +87,14 @@ class LockDetailLogic extends BaseGetXController {
resetOpenDoorState(); resetOpenDoorState();
break; break;
case 0x06: case 0x06:
// //
final List<String>? privateKey = final List<String>? privateKey =
await Storage.getStringList(saveBluePrivateKey); await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList = final List<int> getPrivateKeyList =
changeStringListToIntList(privateKey!); changeStringListToIntList(privateKey!);
final List<String>? signKey = final List<String>? signKey =
await Storage.getStringList(saveBlueSignKey); await Storage.getStringList(saveBlueSignKey);
final List<int> signKeyDataList = changeStringListToIntList(signKey!); final List<int> signKeyDataList = changeStringListToIntList(signKey!);
final List<int> tokenData = reply.data.sublist(2, 6); final List<int> tokenData = reply.data.sublist(2, 6);
@ -113,71 +114,58 @@ class LockDetailLogic extends BaseGetXController {
); );
break; break;
case 0x16: case 0x16:
// ... // ...
resetOpenDoorState(); resetOpenDoorState();
showToast('正在开锁中...'.tr, something: () { showToast('正在开锁中...'.tr, something: () {
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
}); });
break; break;
case 0x0d: case 0x0d:
// //
showToast('钥匙无效'.tr); showToast('钥匙无效'.tr);
// state.animationController!.stop(); openDoorError();
resetOpenDoorState();
cancelBlueConnetctToastTimer();
BlueManage().disconnect();
break; break;
case 0x0b: case 0x0b:
// //
showToast('钥匙过期'.tr); showToast('钥匙过期'.tr);
resetOpenDoorState(); openDoorError();
cancelBlueConnetctToastTimer();
BlueManage().disconnect();
break; break;
case 0x0a: case 0x0a:
// //
showToast('钥匙不存在'); showToast('钥匙不存在');
resetOpenDoorState(); openDoorError();
cancelBlueConnetctToastTimer();
BlueManage().disconnect();
break; break;
case 0x0c: case 0x0c:
// //
showToast('钥匙数量已到上限'); showToast('钥匙数量已到上限');
resetOpenDoorState(); openDoorError();
cancelBlueConnetctToastTimer();
BlueManage().disconnect();
break; break;
case 0x0e: case 0x0e:
// //
showToast('钥匙已存在'); showToast('钥匙已存在');
resetOpenDoorState(); openDoorError();
cancelBlueConnetctToastTimer();
BlueManage().disconnect();
break; break;
case 0x0f: case 0x0f:
// //
showToast('用户已存在'); showToast('用户已存在');
resetOpenDoorState(); openDoorError();
cancelBlueConnetctToastTimer();
BlueManage().disconnect();
break; break;
default: default:
// //
AppLog.log('开锁失败'); AppLog.log('开锁失败');
// state.animationController!.stop(); openDoorError();
resetOpenDoorState();
cancelBlueConnetctToastTimer();
BlueManage().disconnect();
break; break;
} }
} }
//
void openDoorError() {
resetOpenDoorState();
state.animationController!.stop();
cancelBlueConnetctToastTimer();
BlueManage().disconnect();
}
// //
void closeLuckStatus() { void closeLuckStatus() {
state.openLockBtnState.value = 0; state.openLockBtnState.value = 0;
@ -190,67 +178,67 @@ class LockDetailLogic extends BaseGetXController {
Future<void> _replyReferEventRecordTime(Reply reply) async { Future<void> _replyReferEventRecordTime(Reply reply) async {
final int status = reply.data[2]; final int status = reply.data[2];
switch (status) { switch (status) {
case 0x00: case 0x00:
// //
final int dataLength = (reply.data[5] << 8) + reply.data[6]; final int dataLength = (reply.data[5] << 8) + reply.data[6];
// AppLog.log("dataLength:$dataLength"); // AppLog.log("dataLength:$dataLength");
if (dataLength > 0) { if (dataLength > 0) {
reply.data.removeRange(0, 7); reply.data.removeRange(0, 7);
// 17 // 17
if (reply.data.length < 17) { if (reply.data.length < 17) {
return; return;
} }
final List<List<int>> getList = splitList(reply.data, 17); final List<List<int>> getList = splitList(reply.data, 17);
// AppLog.log("getList:$getList"); // AppLog.log("getList:$getList");
final List uploadList = []; final List uploadList = [];
for (int i = 0; i < getList.length; i++) { for (int i = 0; i < getList.length; i++) {
final List<int> indexList = getList[i]; final List<int> indexList = getList[i];
// AppLog.log("indexList:$indexList"); // AppLog.log("indexList:$indexList");
final Map indexMap = {}; final Map indexMap = {};
indexMap['type'] = indexList[0].toString(); indexMap['type'] = indexList[0].toString();
int operateDate = 0; int operateDate = 0;
if (indexList[0] == 2) { if (indexList[0] == 2) {
final List<int> passwordData = reply.data.sublist(7, 17); final List<int> passwordData = reply.data.sublist(7, 17);
final String password = utf8String(passwordData); final String password = utf8String(passwordData);
indexMap['user'] = password.toString(); indexMap['user'] = password.toString();
} else { } else {
final int userNo = (indexList[1] * 256) + indexList[2]; final int userNo = (indexList[1] * 256) + indexList[2];
indexMap['user'] = userNo.toString(); indexMap['user'] = userNo.toString();
} }
indexMap['success'] = '1'; indexMap['success'] = '1';
final int time = ((0xff & indexList[(3)]) << 24 | final int time = ((0xff & indexList[(3)]) << 24 |
(0xff & indexList[4]) << 16 | (0xff & indexList[4]) << 16 |
(0xff & indexList[5]) << 8 | (0xff & indexList[5]) << 8 |
(0xFF & indexList[6])); (0xFF & indexList[6]));
operateDate = time * 1000; operateDate = time * 1000;
indexMap['date'] = '$operateDate'; indexMap['date'] = '$operateDate';
uploadList.add(indexMap); uploadList.add(indexMap);
if (i == getList.length - 1) { if (i == getList.length - 1) {
// //
state.operateDate = operateDate; state.operateDate = operateDate;
} }
} }
lockRecordUploadData(uploadList); lockRecordUploadData(uploadList);
if (dataLength == state.logCountPage) { if (dataLength == state.logCountPage) {
senderReferEventRecordTime(); senderReferEventRecordTime();
} else { } else {
await BlueManage().disconnect(); await BlueManage().disconnect();
} }
} }
break; break;
case 0x06: case 0x06:
// //
BlueManage().disconnect(); BlueManage().disconnect();
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
break; break;
default: default:
BlueManage().disconnect(); BlueManage().disconnect();
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
break; break;
} }
} }
@ -258,11 +246,11 @@ class LockDetailLogic extends BaseGetXController {
Future<void> openDoorAction() async { Future<void> openDoorAction() async {
showBlueConnetctToastTimer(action: () { showBlueConnetctToastTimer(action: () {
resetOpenDoorState(); resetOpenDoorState();
// BlueManage().stopScan(); closeLuckStatus();
BlueManage().disconnect(); BlueManage().disconnect();
}); });
final List<String>? privateKey = final List<String>? privateKey =
await Storage.getStringList(saveBluePrivateKey); await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey); final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
@ -272,89 +260,83 @@ class LockDetailLogic extends BaseGetXController {
final List<int> getTokenList = changeStringListToIntList(token!); final List<int> getTokenList = changeStringListToIntList(token!);
BlueManage() BlueManage()
.bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, .blueSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!,
(BluetoothConnectionState deviceConnectionState) async { (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
IoSenderManage.senderOpenLock( IoSenderManage.senderOpenLock(
keyID: BlueManage().connectDeviceName, keyID: BlueManage().connectDeviceName,
userID: await Storage.getUid(), userID: await Storage.getUid(),
openMode: state.openDoorModel, openMode: state.openDoorModel,
openTime: getUTCNetTime(), openTime: getUTCNetTime(),
onlineToken: state.lockNetToken, onlineToken: state.lockNetToken,
token: getTokenList, token: getTokenList,
needAuthor: 1, needAuthor: 1,
signKey: signKeyDataList, signKey: signKeyDataList,
privateKey: getPrivateKeyList, privateKey: getPrivateKeyList,
); );
} else if (deviceConnectionState == } else if (deviceConnectionState ==
BluetoothConnectionState.disconnected) { BluetoothConnectionState.disconnected) {
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
if (state.ifCurrentScreen.value == true) { if (state.ifCurrentScreen.value == true) {
showBlueConnetctToast(); showBlueConnetctToast();
} }
resetOpenDoorState(); resetOpenDoorState();
} }
}); });
} }
// () // ()
Future<void> senderReferEventRecordTime() async { Future<void> senderReferEventRecordTime() async {
showBlueConnetctToastTimer( showBlueConnetctToastTimer(
isShowBlueConnetctToast: false, isShowBlueConnetctToast: false,
outTimer: 10,
action: () { action: () {
BlueManage().disconnect(); BlueManage().disconnect();
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState connectionState) async { (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) { if (connectionState == BluetoothConnectionState.connected) {
final List<String>? privateKey = final List<String>? privateKey =
await Storage.getStringList(saveBluePrivateKey); await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList = final List<int> getPrivateKeyList =
changeStringListToIntList(privateKey!); changeStringListToIntList(privateKey!);
final List<String>? token = await Storage.getStringList( final List<String>? token = await Storage.getStringList(saveBlueToken);
saveBlueToken); final List<int> getTokenList = changeStringListToIntList(token!);
final List<int> getTokenList = changeStringListToIntList(token!);
final List<String>? publicKey = final List<String>? publicKey =
await Storage.getStringList(saveBluePublicKey); await Storage.getStringList(saveBluePublicKey);
final List<int> getPublicKeyList = final List<int> getPublicKeyList =
changeStringListToIntList(publicKey!); changeStringListToIntList(publicKey!);
IoSenderManage.senderReferEventRecordTimeCommand( IoSenderManage.senderReferEventRecordTimeCommand(
keyID: BlueManage().connectDeviceName, keyID: BlueManage().connectDeviceName,
userID: await Storage.getUid(), userID: await Storage.getUid(),
logsCount: state.logCountPage, logsCount: state.logCountPage,
// time:DateTime.now().millisecondsSinceEpoch~/1000, // time:DateTime.now().millisecondsSinceEpoch~/1000,
time: state.operateDate, time: state.operateDate,
token: getTokenList, token: getTokenList,
needAuthor: 1, needAuthor: 1,
publicKey: getPublicKeyList, publicKey: getPublicKeyList,
privateKey: getPrivateKeyList, privateKey: getPrivateKeyList,
); );
} }
}); });
} }
// //
void getServerDatetime() async { void getServerDatetime() async {
final GetServerDatetimeEntity entity = final GetServerDatetimeEntity entity =
await ApiRepository.to.getServerDatetimeData(); await ApiRepository.to.getServerDatetimeData();
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.differentialTime = entity.data!.date! ~/ 1000 - state.differentialTime = entity.data!.date! ~/ 1000 -
DateTime DateTime.now().millisecondsSinceEpoch ~/ 1000;
.now()
.millisecondsSinceEpoch ~/ 1000;
// AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}"); // AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}");
} }
} }
int getUTCNetTime() { int getUTCNetTime() {
return DateTime return DateTime.now().millisecondsSinceEpoch ~/ 1000 +
.now()
.millisecondsSinceEpoch ~/ 1000 +
state.differentialTime; state.differentialTime;
} }
@ -380,11 +362,11 @@ class LockDetailLogic extends BaseGetXController {
Future<void> uploadElectricQuantityRequest() async { Future<void> uploadElectricQuantityRequest() async {
final KeyOperationRecordEntity entity = await ApiRepository.to final KeyOperationRecordEntity entity = await ApiRepository.to
.uploadElectricQuantity( .uploadElectricQuantity(
electricQuantity: state.electricQuantity.value.toString(), electricQuantity: state.electricQuantity.value.toString(),
electricQuantityStandby: electricQuantityStandby:
state.electricQuantityStandby.value.toString(), state.electricQuantityStandby.value.toString(),
lockId: state.keyInfos.value.lockId.toString(), lockId: state.keyInfos.value.lockId.toString(),
isUnShowLoading: true); isUnShowLoading: true);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
SchedulerBinding.instance.addPostFrameCallback((_) { SchedulerBinding.instance.addPostFrameCallback((_) {
eventBus.fire(RefreshLockListInfoDataEvent(isUnShowLoading: true)); eventBus.fire(RefreshLockListInfoDataEvent(isUnShowLoading: true));
@ -395,8 +377,8 @@ class LockDetailLogic extends BaseGetXController {
// //
void getLockRecordLastUploadDataTime() async { void getLockRecordLastUploadDataTime() async {
final LockOperatingRecordGetLastRecordTimeEntity entity = final LockOperatingRecordGetLastRecordTimeEntity entity =
await ApiRepository.to.getLockRecordLastUploadDataTime( await ApiRepository.to.getLockRecordLastUploadDataTime(
lockId: state.keyInfos.value.lockId.toString()); lockId: state.keyInfos.value.lockId.toString());
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.operateDate = entity.data!.operateDate! ~/ 1000; state.operateDate = entity.data!.operateDate! ~/ 1000;
senderReferEventRecordTime(); senderReferEventRecordTime();
@ -407,7 +389,7 @@ class LockDetailLogic extends BaseGetXController {
Future<void> lockRecordUploadData(List list) async { Future<void> lockRecordUploadData(List list) async {
final KeyOperationRecordEntity entity = await ApiRepository.to final KeyOperationRecordEntity entity = await ApiRepository.to
.lockRecordUploadData( .lockRecordUploadData(
lockId: state.keyInfos.value.lockId.toString(), records: list); lockId: state.keyInfos.value.lockId.toString(), records: list);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
// mockNetworkDataRequest(); // mockNetworkDataRequest();
AppLog.log( AppLog.log(
@ -423,7 +405,7 @@ class LockDetailLogic extends BaseGetXController {
void deletKeyData() async { void deletKeyData() async {
final ElectronicKeyListEntity entity = await ApiRepository.to final ElectronicKeyListEntity entity = await ApiRepository.to
.deleteElectronicKey( .deleteElectronicKey(
keyId: state.keyInfos.value.keyId.toString(), includeUnderlings: 0); keyId: state.keyInfos.value.keyId.toString(), includeUnderlings: 0);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
BlueManage().connectDeviceMacAddress = ''; BlueManage().connectDeviceMacAddress = '';
SchedulerBinding.instance.addPostFrameCallback((_) { SchedulerBinding.instance.addPostFrameCallback((_) {
@ -440,51 +422,50 @@ class LockDetailLogic extends BaseGetXController {
eventBus eventBus
.on<LockSetChangeSetRefreshLockDetailWithType>() .on<LockSetChangeSetRefreshLockDetailWithType>()
.listen((LockSetChangeSetRefreshLockDetailWithType event) { .listen((LockSetChangeSetRefreshLockDetailWithType event) {
if (event.type == 0) { if (event.type == 0) {
// 0 // 0
state.isAttendance.value = int.parse(event.setResult); state.isAttendance.value = int.parse(event.setResult);
state.keyInfos.value.lockSetting!.attendance = state.keyInfos.value.lockSetting!.attendance =
int.parse(event.setResult); int.parse(event.setResult);
} else if (event.type == 1) { } else if (event.type == 1) {
// 1 // 1
state.isOpenLockNeedOnline.value = int.parse(event.setResult); state.isOpenLockNeedOnline.value = int.parse(event.setResult);
state.keyInfos.value.lockSetting!.appUnlockOnline = state.keyInfos.value.lockSetting!.appUnlockOnline =
int.parse(event.setResult); int.parse(event.setResult);
state.lockNetToken = ''; // token state.lockNetToken = ''; // token
} else if (event.type == 2) { } else if (event.type == 2) {
// 2 // 2
state.isOpenPassageMode.value = int.parse(event.setResult); state.isOpenPassageMode.value = int.parse(event.setResult);
state.keyInfos.value.passageMode = int.parse(event.setResult); state.keyInfos.value.passageMode = int.parse(event.setResult);
} else if (event.type == 3) { } else if (event.type == 3) {
// 3 // 3
state.lockAlias.value = event.setResult; state.lockAlias.value = event.setResult;
state.keyInfos.value.lockAlias = event.setResult; state.keyInfos.value.lockAlias = event.setResult;
Storage.setString(saveLockAlias, state.lockAlias.value); Storage.setString(saveLockAlias, state.lockAlias.value);
} else if (event.type == 4) { } else if (event.type == 4) {
// 4 // 4
state.electricQuantity.value = int.parse(event.setResult); state.electricQuantity.value = int.parse(event.setResult);
state.keyInfos.value.electricQuantity = int.parse(event.setResult); state.keyInfos.value.electricQuantity = int.parse(event.setResult);
} else if (event.type == 5) { } else if (event.type == 5) {
// 5 // 5
state.keyInfos.value.lockSetting!.remoteUnlock = state.keyInfos.value.lockSetting!.remoteUnlock =
int.parse(event.setResult); int.parse(event.setResult);
} }
CommonDataManage().currentKeyInfo = state.keyInfos.value; CommonDataManage().currentKeyInfo = state.keyInfos.value;
eventBus.fire(RefreshLockDetailInfoDataEvent()); eventBus.fire(RefreshLockDetailInfoDataEvent());
}); });
} }
String getKeyStatusTextAndShow() { String getKeyStatusTextAndShow() {
String text = ''; String text = '';
if (state.keyInfos.value.keyStatus == if (state.keyInfos.value.keyStatus ==
XSConstantMacro.keyStatusWaitIneffective || XSConstantMacro.keyStatusWaitIneffective ||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusFrozen || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusFrozen ||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusExpired || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusExpired ||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusDeleted || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusDeleted ||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusReset) { state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusReset) {
text = text =
"${"你的钥匙".tr}${XSConstantMacro.getKeyStatusStr( "${"你的钥匙".tr}${XSConstantMacro.getKeyStatusStr(state.keyInfos.value.keyStatus!)}";
state.keyInfos.value.keyStatus!)}";
} else { } else {
text = state.isOpenPassageMode.value == 1 text = state.isOpenPassageMode.value == 1
? '常开模式启动!长按闭锁'.tr ? '常开模式启动!长按闭锁'.tr
@ -517,8 +498,8 @@ class LockDetailLogic extends BaseGetXController {
await PermissionDialog.request(Permission.location); await PermissionDialog.request(Permission.location);
await PermissionDialog.requestBluetooth(); await PermissionDialog.requestBluetooth();
final String connectDeviceName = state.keyInfos.value.bluetooth! final String connectDeviceName =
.bluetoothDeviceName!; state.keyInfos.value.bluetooth!.bluetoothDeviceName!;
if (!BlueManage().isExistScanDevices(connectDeviceName)) { if (!BlueManage().isExistScanDevices(connectDeviceName)) {
BlueManage().startScanSingle( BlueManage().startScanSingle(
connectDeviceName, 15, (List<ScanResult> p0) => null); connectDeviceName, 15, (List<ScanResult> p0) => null);
@ -528,6 +509,5 @@ class LockDetailLogic extends BaseGetXController {
@override @override
void onInit() { void onInit() {
super.onInit(); super.onInit();
} }
} }

View File

@ -1249,9 +1249,10 @@ class _LockDetailPageState extends State<LockDetailPage>
), ),
Positioned( Positioned(
top: 180.h, top: 180.h,
left: 55.w, width: 358.w,
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Text( Text(
state.keyInfos.value.lockAlias!, state.keyInfos.value.lockAlias!,
@ -1318,7 +1319,7 @@ class _LockDetailPageState extends State<LockDetailPage>
} }
} }
void startOpenLock() { void startOpenLock() {
if (state.openLockBtnState.value == 1) { if (state.openLockBtnState.value == 1) {
return; return;
} }

View File

@ -97,7 +97,7 @@ class LockOperatingRecordLogic extends BaseGetXController {
showBlueConnetctToastTimer(action: (){ showBlueConnetctToastTimer(action: (){
dismissEasyLoading(); dismissEasyLoading();
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionStateState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionStateState) async {
if (connectionStateState == BluetoothConnectionState.connected) { if (connectionStateState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);

View File

@ -116,7 +116,7 @@ class AutomaticBlockingLogic extends BaseGetXController{
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) { if (connectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);

View File

@ -188,7 +188,7 @@ class AdminOpenLockPasswordLogic extends BaseGetXController{
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
var signKey = await Storage.getStringList(saveBlueSignKey); var signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); List<int> signKeyDataList = changeStringListToIntList(signKey!);

View File

@ -50,7 +50,7 @@ class UploadElectricQuantityLogic extends BaseGetXController {
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async { (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
dismissEasyLoading(); dismissEasyLoading();

View File

@ -99,7 +99,7 @@ class BurglarAlarmLogic extends BaseGetXController{
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) { if (connectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);

View File

@ -136,7 +136,7 @@ class ConfiguringWifiLogic extends BaseGetXController{
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected){ if (connectionState == BluetoothConnectionState.connected){
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);

View File

@ -113,7 +113,7 @@ class WifiListLogic extends BaseGetXController {
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected){ if (connectionState == BluetoothConnectionState.connected){
var token = await Storage.getStringList(saveBlueToken); var token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!); List<int> getTokenList = changeStringListToIntList(token!);

View File

@ -80,7 +80,7 @@ class LockEscalationLogic extends BaseGetXController {
// ota // ota
void blueOTAUpgrade(Map data, List<int> token) { void blueOTAUpgrade(Map data, List<int> token) {
BlueManage().bludSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async { (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);

View File

@ -245,7 +245,7 @@ class LockSetLogic extends BaseGetXController {
dismissEasyLoading(); dismissEasyLoading();
showDeletAlertTipDialog(); showDeletAlertTipDialog();
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) { if (connectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
@ -306,7 +306,7 @@ class LockSetLogic extends BaseGetXController {
showBlueConnetctToastTimer(action: (){ showBlueConnetctToastTimer(action: (){
dismissEasyLoading(); dismissEasyLoading();
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) { if (connectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);

View File

@ -103,7 +103,7 @@ class LockSoundSetLogic extends BaseGetXController {
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) { if (connectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);

View File

@ -103,7 +103,7 @@ class LockTimeLogic extends BaseGetXController{
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) { if (connectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);

View File

@ -84,7 +84,7 @@ class MotorPowerLogic extends BaseGetXController {
// - // -
Future<void> _readSupportFunctionsNoParameters() async { Future<void> _readSupportFunctionsNoParameters() async {
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) { if (connectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
@ -110,7 +110,7 @@ class MotorPowerLogic extends BaseGetXController {
// () // ()
Future<void> sendOpenDoorDirection() async { Future<void> sendOpenDoorDirection() async {
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) { if (connectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);

View File

@ -120,7 +120,7 @@ class NormallyOpenModeLogic extends BaseGetXController{
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) { if (connectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);

View File

@ -86,7 +86,7 @@ class OpenDoorDirectionLogic extends BaseGetXController {
// () // ()
Future<void> sendOpenDoorDirection() async { Future<void> sendOpenDoorDirection() async {
showEasyLoading(); showEasyLoading();
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
dismissEasyLoading(); dismissEasyLoading();
if (connectionState == BluetoothConnectionState.connected) { if (connectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);

View File

@ -109,7 +109,7 @@ class RemoteUnlockingLogic extends BaseGetXController {
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState connectionState) async { (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) { if (connectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);

View File

@ -98,7 +98,7 @@ class ResetButtonLogic extends BaseGetXController{
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) { if (connectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);

View File

@ -89,7 +89,7 @@ class PalmDetailLogic extends BaseGetXController {
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async { (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
// var publicKey = await Storage.getStringList(saveBluePublicKey); // var publicKey = await Storage.getStringList(saveBluePublicKey);

View File

@ -185,7 +185,7 @@ class PalmListLogic extends BaseGetXController {
// //
Future<void> senderQueryingFaceStatus() async { Future<void> senderQueryingFaceStatus() async {
BlueManage().bludSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState state) async { (BluetoothConnectionState state) async {
if (state == BluetoothConnectionState.connected) { if (state == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
@ -214,7 +214,7 @@ class PalmListLogic extends BaseGetXController {
// () // ()
Future<void> senderCheckingUserInfoCount() async { Future<void> senderCheckingUserInfoCount() async {
BlueManage().bludSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState state) async { (BluetoothConnectionState state) async {
if (state == BluetoothConnectionState.connected) { if (state == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
@ -246,7 +246,7 @@ class PalmListLogic extends BaseGetXController {
showBlueConnetctToastTimer(action: () { showBlueConnetctToastTimer(action: () {
dismissEasyLoading(); dismissEasyLoading();
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async { (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
var signKey = await Storage.getStringList(saveBlueSignKey); var signKey = await Storage.getStringList(saveBlueSignKey);

View File

@ -127,7 +127,7 @@ class PasswordKeyDetailLogic extends BaseGetXController {
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
var signKey = await Storage.getStringList(saveBlueSignKey); var signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); List<int> signKeyDataList = changeStringListToIntList(signKey!);

View File

@ -121,7 +121,7 @@ class PasswordKeyDetailChangeDateLogic extends BaseGetXController {
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
var signKey = await Storage.getStringList(saveBlueSignKey); var signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); List<int> signKeyDataList = changeStringListToIntList(signKey!);

View File

@ -128,7 +128,7 @@ class PasswordKeyListLogic extends BaseGetXController {
showBlueConnetctToastTimer(action: (){ showBlueConnetctToastTimer(action: (){
dismissEasyLoading(); dismissEasyLoading();
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
var signKey = await Storage.getStringList(saveBlueSignKey); var signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); List<int> signKeyDataList = changeStringListToIntList(signKey!);
@ -177,7 +177,7 @@ class PasswordKeyListLogic extends BaseGetXController {
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
var signKey = await Storage.getStringList(saveBlueSignKey); var signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); List<int> signKeyDataList = changeStringListToIntList(signKey!);

View File

@ -342,7 +342,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
var signKey = await Storage.getStringList(saveBlueSignKey); var signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); List<int> signKeyDataList = changeStringListToIntList(signKey!);

View File

@ -181,7 +181,7 @@ class LockListLogic extends BaseGetXController{
dismissEasyLoading(); dismissEasyLoading();
showDeletAlertTipDialog(); showDeletAlertTipDialog();
}); });
BlueManage().bludSendData(state.lockListInfoItemEntity.lockName!, (BluetoothConnectionState connectionState) async { BlueManage().blueSendData(state.lockListInfoItemEntity.lockName!, (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) { if (connectionState == BluetoothConnectionState.connected) {
List<int> publicKeyData = state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>(); List<int> publicKeyData = state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>();
var saveStrList = changeIntListToStringList(publicKeyData); var saveStrList = changeIntListToStringList(publicKeyData);

View File

@ -108,7 +108,7 @@ class DebugConsoleController {
return; return;
} }
BlueManage().bludSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async { (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
@ -179,7 +179,7 @@ class DebugConsoleController {
tokenList = changeStringListToIntList(tokenKey!); tokenList = changeStringListToIntList(tokenKey!);
} }
BlueManage().bludSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async { (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
IoSenderManage.senderCleanUpUsersCommand( IoSenderManage.senderCleanUpUsersCommand(

View File

@ -54,7 +54,7 @@ class NearbyLockLogic extends BaseGetXController {
dismissEasyLoading(); dismissEasyLoading();
// state.sureBtnState.value = 0; // state.sureBtnState.value = 0;
}); });
BlueManage().bludSendData(deviceName, BlueManage().blueSendData(deviceName,
(BluetoothConnectionState state) async { (BluetoothConnectionState state) async {
AppLog.log("点击要添加的设备了"); AppLog.log("点击要添加的设备了");
if (state == BluetoothConnectionState.connected) { if (state == BluetoothConnectionState.connected) {
@ -415,7 +415,7 @@ class NearbyLockLogic extends BaseGetXController {
void oTAUpgrade(String deviceName) { void oTAUpgrade(String deviceName) {
showTitleEasyLoading("连接设备中..."); showTitleEasyLoading("连接设备中...");
this.deviceName = deviceName; this.deviceName = deviceName;
BlueManage().bludSendData(deviceName, BlueManage().blueSendData(deviceName,
(BluetoothConnectionState state) async { (BluetoothConnectionState state) async {
AppLog.log("连接设备"); AppLog.log("连接设备");
if (state == BluetoothConnectionState.connected) { if (state == BluetoothConnectionState.connected) {
@ -460,7 +460,7 @@ class NearbyLockLogic extends BaseGetXController {
AppLog.log('blueOTAUpgrade:设备名字为 null'); AppLog.log('blueOTAUpgrade:设备名字为 null');
return; return;
} }
BlueManage().bludSendData(deviceName!, BlueManage().blueSendData(deviceName!,
(BluetoothConnectionState deviceConnectionState) async { (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
String uid = await Storage.getUid() ?? ''; String uid = await Storage.getUid() ?? '';

View File

@ -212,7 +212,7 @@ class SaveLockLogic extends BaseGetXController {
showBlueConnetctToast(); showBlueConnetctToast();
} }
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async { (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
// //

View File

@ -94,7 +94,7 @@ class ExpireCardLogic extends BaseGetXController {
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; 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){ if (deviceConnectionState == BluetoothConnectionState.connected){
// var publicKey = await Storage.getStringList(saveBluePublicKey); // var publicKey = await Storage.getStringList(saveBluePublicKey);
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!); // List<int> publicKeyDataList = changeStringListToIntList(publicKey!);

View File

@ -95,7 +95,7 @@ class ExpireFingerprintLogic extends BaseGetXController {
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; 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){ if (deviceConnectionState == BluetoothConnectionState.connected){
// var publicKey = await Storage.getStringList(saveBluePublicKey); // var publicKey = await Storage.getStringList(saveBluePublicKey);
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!); // List<int> publicKeyDataList = changeStringListToIntList(publicKey!);

View File

@ -5,7 +5,7 @@ import 'package:get/get_connect/http/src/request/request.dart';
import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/app_settings/app_settings.dart';
FutureOr<dynamic> responseLogInterceptor(Request request, Response response) { 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); EasyLoading.dismiss(animation: true);
return response; return response;
} }