1、切换蓝牙插件。2、修复蓝牙概率连接失败问题。3、修复概率闪退问题。4、修复其他问题
This commit is contained in:
parent
38ab3c161b
commit
b07ac6302b
@ -27,6 +27,8 @@ PODS:
|
|||||||
- AMapFoundation (1.8.2)
|
- AMapFoundation (1.8.2)
|
||||||
- AMapLocation (2.10.0):
|
- AMapLocation (2.10.0):
|
||||||
- AMapFoundation (>= 1.8.0)
|
- AMapFoundation (>= 1.8.0)
|
||||||
|
- app_settings (5.1.1):
|
||||||
|
- Flutter
|
||||||
- audio_service (0.0.1):
|
- audio_service (0.0.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
- audio_session (0.0.1):
|
- audio_session (0.0.1):
|
||||||
@ -109,6 +111,7 @@ DEPENDENCIES:
|
|||||||
- aliyun_push (from `.symlinks/plugins/aliyun_push/ios`)
|
- aliyun_push (from `.symlinks/plugins/aliyun_push/ios`)
|
||||||
- amap_flutter_location (from `.symlinks/plugins/amap_flutter_location/ios`)
|
- amap_flutter_location (from `.symlinks/plugins/amap_flutter_location/ios`)
|
||||||
- amap_flutter_map (from `.symlinks/plugins/amap_flutter_map/ios`)
|
- amap_flutter_map (from `.symlinks/plugins/amap_flutter_map/ios`)
|
||||||
|
- app_settings (from `.symlinks/plugins/app_settings/ios`)
|
||||||
- audio_service (from `.symlinks/plugins/audio_service/ios`)
|
- audio_service (from `.symlinks/plugins/audio_service/ios`)
|
||||||
- audio_session (from `.symlinks/plugins/audio_session/ios`)
|
- audio_session (from `.symlinks/plugins/audio_session/ios`)
|
||||||
- audioplayers_darwin (from `.symlinks/plugins/audioplayers_darwin/ios`)
|
- audioplayers_darwin (from `.symlinks/plugins/audioplayers_darwin/ios`)
|
||||||
@ -166,6 +169,8 @@ EXTERNAL SOURCES:
|
|||||||
:path: ".symlinks/plugins/amap_flutter_location/ios"
|
:path: ".symlinks/plugins/amap_flutter_location/ios"
|
||||||
amap_flutter_map:
|
amap_flutter_map:
|
||||||
:path: ".symlinks/plugins/amap_flutter_map/ios"
|
:path: ".symlinks/plugins/amap_flutter_map/ios"
|
||||||
|
app_settings:
|
||||||
|
:path: ".symlinks/plugins/app_settings/ios"
|
||||||
audio_service:
|
audio_service:
|
||||||
:path: ".symlinks/plugins/audio_service/ios"
|
:path: ".symlinks/plugins/audio_service/ios"
|
||||||
audio_session:
|
audio_session:
|
||||||
@ -236,6 +241,7 @@ SPEC CHECKSUMS:
|
|||||||
amap_flutter_map: 979e54d227cedac6c7504a2151bfbf3bcf96760a
|
amap_flutter_map: 979e54d227cedac6c7504a2151bfbf3bcf96760a
|
||||||
AMapFoundation: 9885c48fc3a78fdfb84a0299a2293e56ea3c9fec
|
AMapFoundation: 9885c48fc3a78fdfb84a0299a2293e56ea3c9fec
|
||||||
AMapLocation: 5248aec2455ebb5d104b367813c946430a2ee033
|
AMapLocation: 5248aec2455ebb5d104b367813c946430a2ee033
|
||||||
|
app_settings: 017320c6a680cdc94c799949d95b84cb69389ebc
|
||||||
audio_service: f509d65da41b9521a61f1c404dd58651f265a567
|
audio_service: f509d65da41b9521a61f1c404dd58651f265a567
|
||||||
audio_session: 4f3e461722055d21515cf3261b64c973c062f345
|
audio_session: 4f3e461722055d21515cf3261b64c973c062f345
|
||||||
audioplayers_darwin: 877d9a4d06331c5c374595e46e16453ac7eafa40
|
audioplayers_darwin: 877d9a4d06331c5c374595e46e16453ac7eafa40
|
||||||
@ -272,6 +278,6 @@ SPEC CHECKSUMS:
|
|||||||
video_player_avfoundation: 81e49bb3d9fb63dccf9fa0f6d877dc3ddbeac126
|
video_player_avfoundation: 81e49bb3d9fb63dccf9fa0f6d877dc3ddbeac126
|
||||||
webview_flutter_wkwebview: 4f3e50f7273d31e5500066ed267e3ae4309c5ae4
|
webview_flutter_wkwebview: 4f3e50f7273d31e5500066ed267e3ae4309c5ae4
|
||||||
|
|
||||||
PODFILE CHECKSUM: 2d54cef87a0ac87750282877d7a79b735ed5c517
|
PODFILE CHECKSUM: 8406bb0e8f1c4b5dff3955810b207d90193914a0
|
||||||
|
|
||||||
COCOAPODS: 1.14.3
|
COCOAPODS: 1.14.3
|
||||||
|
|||||||
@ -1,52 +1,67 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
import 'io_tool/io_model.dart';
|
import 'io_tool/io_model.dart';
|
||||||
import 'io_tool/io_tool.dart';
|
import 'io_tool/io_tool.dart';
|
||||||
import 'io_tool/manager_event_bus.dart';
|
import 'io_tool/manager_event_bus.dart';
|
||||||
import 'reciver_data.dart';
|
import 'reciver_data.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
|
|
||||||
//连接状态回调
|
//连接状态回调
|
||||||
typedef ConnectStateCallBack = Function(DeviceConnectionState connectionState);
|
typedef ConnectStateCallBack = Function(BluetoothConnectionState connectionState);
|
||||||
|
typedef ScanDevicesCallBack = Function(List<ScanResult>);
|
||||||
|
|
||||||
class BlueManage {
|
class BlueManage {
|
||||||
FlutterReactiveBle? _flutterReactiveBle;
|
final List<ScanResult> scanDevices = [];
|
||||||
final List<DiscoveredDevice> scanDevices = [];
|
|
||||||
|
|
||||||
// 用来写入的服务id
|
// 用来写入的服务id
|
||||||
final Uuid _serviceIdConnect = Uuid.parse("fff0");
|
final Guid _serviceIdConnect = Guid("fff0");
|
||||||
// 用来写入的服务id
|
// 用来写入的服务id
|
||||||
final Uuid _serviceIdWrite = Uuid.parse('0000FFF0-0000-1000-8000-00805F9B34FB');
|
final Guid _serviceIdWrite = Guid('0000FFF0-0000-1000-8000-00805F9B34FB');
|
||||||
// 用来订阅的特征id
|
// 用来订阅的特征id
|
||||||
final Uuid _characteristicIdSubscription = Uuid.parse("fff1");
|
final Guid _characteristicIdSubscription = Guid("fff1");
|
||||||
// 用来写入的特征id
|
// 用来写入的特征id
|
||||||
final Uuid _characteristicIdWrite = Uuid.parse("fff2");
|
final Guid _characteristicIdWrite = Guid("fff2");
|
||||||
|
|
||||||
// 监听发送事件
|
// 监听发送事件
|
||||||
StreamSubscription<EventSendModel>? _sendStreamSubscription;
|
StreamSubscription<EventSendModel>? _sendStreamSubscription;
|
||||||
// 监听蓝牙扫描的事件
|
// 监听蓝牙扫描的事件
|
||||||
StreamSubscription? _scanSubscription;
|
// StreamSubscription? _scanSubscription;
|
||||||
// 监听蓝牙连接的事件
|
// 监听蓝牙连接的事件
|
||||||
StreamSubscription<dynamic>? _currentConnectionStream;
|
// StreamSubscription<dynamic>? _currentConnectionStream;
|
||||||
|
|
||||||
|
// StreamSubscription<List<ScanResult>>? _scanResultsSubscription;
|
||||||
|
StreamSubscription<BluetoothConnectionState>? _connectionStateSubscription;
|
||||||
|
|
||||||
|
StreamSubscription<int>? _mtuSubscription;
|
||||||
|
int? _mtuSize = 20;
|
||||||
|
|
||||||
// 当前连接设备的名字
|
// 当前连接设备的名字
|
||||||
String connectDeviceName = "";
|
String connectDeviceName = "";
|
||||||
// 当前连接设备的mac地址
|
// 当前连接设备的mac地址
|
||||||
String connectDeviceMacAddress = "";
|
String connectDeviceMacAddress = "";
|
||||||
|
// 当前连接的设备
|
||||||
|
BluetoothDevice? bluetoothConnectDevice;
|
||||||
|
// 当前扫描到结果要连接设备
|
||||||
|
ScanResult? scanResult;
|
||||||
// 监听蓝牙连接状态
|
// 监听蓝牙连接状态
|
||||||
DeviceConnectionState? deviceConnectionState = DeviceConnectionState.disconnected;
|
BluetoothConnectionState? bluetoothConnectionState = BluetoothConnectionState.disconnected;
|
||||||
|
|
||||||
|
BluetoothAdapterState? _adapterState = BluetoothAdapterState.unknown;
|
||||||
|
StreamSubscription<BluetoothAdapterState>? _adapterStateStateSubscription;
|
||||||
|
|
||||||
static BlueManage? _manager;
|
static BlueManage? _manager;
|
||||||
BlueManage._init(){
|
BlueManage._init(){
|
||||||
// _initBlue();
|
_initBlue();
|
||||||
}
|
}
|
||||||
|
|
||||||
static BlueManage? shareManager() {
|
static BlueManage? shareManager() {
|
||||||
_manager ??= BlueManage._init();
|
_manager ??= BlueManage._init();
|
||||||
_manager!._initBlue();
|
// _manager!._initBlue();
|
||||||
return _manager;
|
return _manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,21 +69,94 @@ class BlueManage {
|
|||||||
BlueManage? get manager => shareManager();
|
BlueManage? get manager => shareManager();
|
||||||
|
|
||||||
void _initBlue(){
|
void _initBlue(){
|
||||||
// print("蓝牙功能初始化了");
|
print("蓝牙功能初始化监听");
|
||||||
_flutterReactiveBle ??= FlutterReactiveBle();
|
|
||||||
_initSendStreamSubscription();
|
_initSendStreamSubscription();
|
||||||
|
_initAdapterStateStateSubscription();
|
||||||
|
// _initListenscanResults();
|
||||||
|
// _initListenConnectionState();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _initGetMtuSubscription() {
|
||||||
|
_mtuSubscription ??= bluetoothConnectDevice!.mtu.listen((value) {
|
||||||
|
_mtuSize = value - 3;
|
||||||
|
print('mtuSize:$_mtuSize');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _initAdapterStateStateSubscription() {
|
||||||
|
_adapterStateStateSubscription ??= FlutterBluePlus.adapterState.listen((state) {
|
||||||
|
_adapterState = state;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// void _initListenscanResults() {
|
||||||
|
// var subscription = FlutterBluePlus.scanResults.listen((results) {
|
||||||
|
// scanDevices.clear();
|
||||||
|
// for (var scanResult in results) {
|
||||||
|
// // 判断名字为空的直接剔除
|
||||||
|
// // if (scanResult.device.advName.isEmpty) {
|
||||||
|
// // return;
|
||||||
|
// // }
|
||||||
|
// print("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) {
|
||||||
|
// print("Scan Error:$e", );
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// FlutterBluePlus.cancelWhenScanComplete(subscription);
|
||||||
|
|
||||||
|
// FlutterBluePlus.isScanning.listen((state) {
|
||||||
|
// if (state) {
|
||||||
|
// print('Scanning');
|
||||||
|
// } else {
|
||||||
|
// print('Not scanning');
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
void _initListenConnectionState() {
|
||||||
|
_connectionStateSubscription?.cancel();
|
||||||
|
_connectionStateSubscription = null;
|
||||||
|
|
||||||
|
_connectionStateSubscription = bluetoothConnectDevice!.connectionState.listen((state) async {
|
||||||
|
bluetoothConnectionState = state;
|
||||||
|
Get.log("蓝牙连接状态:$state");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _initSendStreamSubscription() {
|
void _initSendStreamSubscription() {
|
||||||
_sendStreamSubscription ??= EventBusManager().eventBus!.on<EventSendModel>().listen((EventSendModel model) {
|
_sendStreamSubscription ??= EventBusManager().eventBus!.on<EventSendModel>().listen((EventSendModel model) {
|
||||||
if (model.sendChannel == DataChannel.ble) {
|
if (model.sendChannel == DataChannel.ble) {
|
||||||
// managerAppWriteData(model.data);
|
FlutterBluePlus.isSupported.then((isAvailable) async {
|
||||||
_flutterReactiveBle!.statusStream.listen((status) {
|
if (isAvailable) {
|
||||||
if (status == BleStatus.ready) {
|
if (_adapterState == BluetoothAdapterState.on) {
|
||||||
// 蓝牙已开启,可以进行蓝牙操作
|
// 蓝牙已开启,可以进行蓝牙操作
|
||||||
writeCharacteristicWithResponse(model.data);
|
writeCharacteristicWithResponse(model.data);
|
||||||
}else{
|
} else {
|
||||||
Get.log("写入数据 蓝牙未开启,不能进行蓝牙操作");
|
try {
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
await FlutterBluePlus.turnOn();
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
Get.log("Error Turning On:");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Get.log("写入数据 蓝牙不可用,不能进行蓝牙操作");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -76,164 +164,196 @@ class BlueManage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 开始扫描蓝牙设备
|
/// 开始扫描蓝牙设备
|
||||||
void startScan({List<Uuid>? idList}) {
|
Future<void> startScan(int timeout, ScanDevicesCallBack scanDevicesCallBack, {List<Guid>? idList}) async {
|
||||||
// List<Service>? list = _flutterReactiveBle!.getDiscoveredServices("deviceId").then((value));
|
FlutterBluePlus.isSupported.then((isAvailable) async {
|
||||||
_flutterReactiveBle!.statusStream.listen((status) {
|
if (isAvailable) {
|
||||||
if (status == BleStatus.ready) {
|
if (_adapterState == BluetoothAdapterState.on) {
|
||||||
// 蓝牙已开启,可以进行蓝牙操作
|
try {
|
||||||
scanDevices.clear();
|
FlutterBluePlus.startScan(timeout: Duration(seconds: timeout));
|
||||||
_scanSubscription = _flutterReactiveBle!.scanForDevices(withServices:[]).listen((device) {
|
|
||||||
// 判断名字为空的直接剔除
|
var subscription = FlutterBluePlus.scanResults.listen((results) {
|
||||||
if (device.name.isEmpty) {
|
scanDevices.clear();
|
||||||
return;
|
for (var scanResult in results) {
|
||||||
}
|
// 判断名字为空的直接剔除
|
||||||
print("startScanDevice:$device");
|
// if (scanResult.device.advName.isEmpty) {
|
||||||
if (((device.serviceUuids.isNotEmpty ? device.serviceUuids[0] : "").toString().contains("758824")) && (device.rssi >= -100)) {
|
// return;
|
||||||
// 查询id相同的元素
|
// }
|
||||||
final knownDeviceIndex = scanDevices.indexWhere((d) => d.id == device.id);
|
Get.log("scanResult.device.advName:${scanResult.device.advName}"
|
||||||
// 不存在的时候返回-1
|
" scanResult.advertisementData.serviceUuids:${scanResult.advertisementData.serviceUuids}"
|
||||||
if (knownDeviceIndex >= 0) {
|
" rssi:${scanResult.rssi}");
|
||||||
scanDevices[knownDeviceIndex] = device;
|
if (((scanResult.advertisementData.serviceUuids.isNotEmpty ? scanResult.advertisementData.serviceUuids[0] : "").toString().contains("758824")) && (scanResult.rssi >= -100)) {
|
||||||
} else {
|
// 查询id相同的元素
|
||||||
scanDevices.add(device);
|
final knownDeviceIndex = scanDevices.indexWhere((d) => d.advertisementData.advName == scanResult.advertisementData.advName);
|
||||||
|
// 不存在的时候返回-1
|
||||||
|
if (knownDeviceIndex >= 0) {
|
||||||
|
scanDevices[knownDeviceIndex] = scanResult;
|
||||||
|
} else {
|
||||||
|
scanDevices.add(scanResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
scanDevicesCallBack(scanDevices);
|
||||||
|
// EventBusManager().eventBusFir(scanDevices);
|
||||||
|
// FlutterBluePlus.stopScan();
|
||||||
|
}, onError: (e) {
|
||||||
|
print("Scan Error:$e", );
|
||||||
|
});
|
||||||
|
|
||||||
|
FlutterBluePlus.cancelWhenScanComplete(subscription);
|
||||||
|
} catch (e) {
|
||||||
|
Get.log("扫描失败");
|
||||||
}
|
}
|
||||||
EventBusManager().eventBusFir(scanDevices);
|
} else {
|
||||||
}
|
try {
|
||||||
}, onError: (Object e) {
|
if (Platform.isAndroid) {
|
||||||
print('Device scan fails with error: $e');
|
await FlutterBluePlus.turnOn();
|
||||||
});
|
}
|
||||||
}else{
|
} catch (e) {
|
||||||
Get.log("开始扫描 蓝牙未开启,不能进行蓝牙操作");
|
Get.log("Error Turning On:");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
Get.log("开始扫描 蓝牙不可用,不能进行蓝牙操作");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 调用发送数据
|
/// 调用发送数据
|
||||||
Future<void> bludSendData(String deviceName, ConnectStateCallBack stateCallBack, {bool isAddEquipment = false}) async {
|
Future<void> bludSendData(String deviceName, ConnectStateCallBack stateCallBack, {bool isAddEquipment = false}) async {
|
||||||
_flutterReactiveBle!.statusStream.listen((status) {
|
FlutterBluePlus.isSupported.then((isAvailable) async {
|
||||||
Get.log("_flutterReactiveBle.status:$status");
|
if (isAvailable) {
|
||||||
if(deviceName.isEmpty) {
|
if (_adapterState == BluetoothAdapterState.on) {
|
||||||
Get.log("deviceName为空");
|
// 蓝牙已开启,可以进行蓝牙操作
|
||||||
return;
|
if(bluetoothConnectionState != BluetoothConnectionState.connected){
|
||||||
}
|
_connect(deviceName, (state){
|
||||||
if (status == BleStatus.ready) {
|
// if(bluetoothConnectionState != BluetoothConnectionState.connected){
|
||||||
// 蓝牙已开启,可以进行蓝牙操作
|
// stateCallBack(bluetoothConnectionState!);
|
||||||
if(deviceConnectionState != DeviceConnectionState.connected){
|
// }else{
|
||||||
if(isAddEquipment == false){
|
// stateCallBack(bluetoothConnectionState!);
|
||||||
// print("666666666");
|
// }
|
||||||
startScan();
|
stateCallBack(bluetoothConnectionState!);
|
||||||
|
}, isAddEquipment: isAddEquipment);
|
||||||
|
}else{
|
||||||
|
stateCallBack(bluetoothConnectionState!);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
_connect(deviceName, (state){
|
try {
|
||||||
stateCallBack(deviceConnectionState!);
|
if (Platform.isAndroid) {
|
||||||
});
|
await FlutterBluePlus.turnOn();
|
||||||
}else{
|
}
|
||||||
// stopScan();
|
} catch (e) {
|
||||||
stateCallBack(deviceConnectionState!);
|
Get.log("Error Turning On:");
|
||||||
}
|
}
|
||||||
}else{
|
};
|
||||||
Get.log("调用发送数据 蓝牙未开启,不能进行蓝牙操作");
|
} else {
|
||||||
|
Get.log("开始扫描 蓝牙不可用,不能进行蓝牙操作");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 连接监听状态
|
/// 连接
|
||||||
Future<void> _connect(String deviceName, ConnectStateCallBack connectStateCallBack) async {
|
Future<void> _connect(String deviceName, ConnectStateCallBack connectStateCallBack, {bool isAddEquipment = false}) async {
|
||||||
connectDeviceName = deviceName;
|
connectDeviceName = deviceName;
|
||||||
|
List<ScanResult> devicesList = scanDevices;
|
||||||
|
if(isAddEquipment == false){
|
||||||
|
startScan(10, (List<ScanResult> scanDevices){
|
||||||
|
print("扫描到的设备:$scanDevices");
|
||||||
|
devicesList = scanDevices;
|
||||||
|
_connectDevice(devicesList, deviceName, connectStateCallBack, isAddEquipment: isAddEquipment);
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
_connectDevice(devicesList, deviceName, connectStateCallBack, isAddEquipment: isAddEquipment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _connectDevice( List<ScanResult> devicesList, String deviceName, ConnectStateCallBack connectStateCallBack, {bool isAddEquipment = false}) async {
|
||||||
// 判断数组列表里面是否有这个设备
|
// 判断数组列表里面是否有这个设备
|
||||||
final knownDeviceIndex = scanDevices.indexWhere((d) => d.name == deviceName);
|
print("devicesList:$devicesList");
|
||||||
|
final knownDeviceIndex = devicesList.indexWhere((d) => d.advertisementData.advName == deviceName);
|
||||||
if (knownDeviceIndex >= 0) {
|
if (knownDeviceIndex >= 0) {
|
||||||
// 存在的时候赋值
|
// 存在的时候赋值
|
||||||
connectDeviceMacAddress = scanDevices[knownDeviceIndex].id;
|
connectDeviceMacAddress = devicesList[knownDeviceIndex].advertisementData.advName;
|
||||||
} else {
|
|
||||||
// 不存在的时候返回-1 然后循环5秒
|
|
||||||
var index = 0;
|
|
||||||
Completer? completer = Completer();
|
|
||||||
Timer.periodic(const Duration(seconds: 1), (timer) async {
|
|
||||||
///定时任务
|
|
||||||
// print("timer index0:$index");
|
|
||||||
if(index >= 9){
|
|
||||||
// 当超过5秒的时候取消定时任务 弹窗显示连接失败
|
|
||||||
connectDeviceMacAddress = "";
|
|
||||||
connectStateCallBack(DeviceConnectionState.disconnected);
|
|
||||||
completer.complete();
|
|
||||||
stopScan();
|
|
||||||
timer.cancel();
|
|
||||||
// deviceConnectionState = DeviceConnectionState.disconnected;
|
|
||||||
// print("timer index1:$index");
|
|
||||||
}else{
|
|
||||||
// 每秒判断数组列表里面是否有这个设备
|
|
||||||
final knownDeviceIndex = scanDevices.indexWhere((d) => d.name == deviceName);
|
|
||||||
|
|
||||||
if (knownDeviceIndex >= 0) {
|
bluetoothConnectDevice = devicesList[knownDeviceIndex].device;
|
||||||
// 存在的时候销毁定时器,赋值
|
print('bluetoothConnectDevice: $bluetoothConnectDevice');
|
||||||
connectDeviceMacAddress = scanDevices[knownDeviceIndex].id;
|
scanResult = devicesList[knownDeviceIndex];
|
||||||
stopScan();
|
|
||||||
completer.complete();
|
|
||||||
timer.cancel();
|
|
||||||
// print("timer index2:$index");
|
|
||||||
|
|
||||||
// var uuidStr = (scanDevices[knownDeviceIndex].serviceUuids.isNotEmpty ? scanDevices[knownDeviceIndex].serviceUuids[0] : "").toString();
|
_initGetMtuSubscription();
|
||||||
// if(uuidStr[31] == "0"){
|
_initListenConnectionState();
|
||||||
// // 未配对 表示这把锁已被强制初始化 处于可添加状态 不再连接
|
|
||||||
// EasyLoading.showToast("当前设备已被清除配对,请删除后重新添加", duration: 2000.milliseconds);
|
|
||||||
// Future.delayed(2100.milliseconds);
|
|
||||||
// connectStateCallBack(DeviceConnectionState.disconnected);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
} else {
|
|
||||||
// 不存在的时候返回-1 然后循环5秒
|
|
||||||
index++;
|
|
||||||
print("index:$index");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// 等待Completer完成
|
|
||||||
await completer.future;
|
|
||||||
}
|
}
|
||||||
print("1 connectDeviceId:$connectDeviceMacAddress connectDeviceName:$connectDeviceName");
|
print("1 connectDeviceId:$connectDeviceMacAddress connectDeviceName:$connectDeviceName");
|
||||||
// stopScan();
|
// stopScan();
|
||||||
if (connectDeviceMacAddress.isEmpty) {
|
if (connectDeviceMacAddress.isEmpty) {
|
||||||
|
// connectStateCallBack(BluetoothConnectionState.disconnected!);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 用来判断是否返回了连接结果 还是放了一段时间后蓝牙主动断开的
|
Get.log("调用了停止扫描的方法");
|
||||||
var isReturnedConnectResults = false;
|
await stopScan();
|
||||||
_currentConnectionStream = _flutterReactiveBle!.connectToDevice(id: connectDeviceMacAddress, connectionTimeout: const Duration(seconds: 5)).listen((connectionStateUpdate) async {
|
|
||||||
// 获取状态
|
|
||||||
deviceConnectionState = connectionStateUpdate.connectionState;
|
|
||||||
stopScan();
|
|
||||||
print('2 deviceConnectionState:$deviceConnectionState connectionStateUpdate.connectionState:${connectionStateUpdate.connectionState}');
|
|
||||||
if (connectionStateUpdate.connectionState == DeviceConnectionState.connected) {
|
|
||||||
isReturnedConnectResults = true;
|
|
||||||
// 如果状态是连接的开始发现服务
|
|
||||||
try {
|
|
||||||
_subScribeToCharacteristic(QualifiedCharacteristic(characteristicId: _characteristicIdSubscription, serviceId: _serviceIdConnect, deviceId: connectDeviceMacAddress));
|
|
||||||
print('Discovering services finished');
|
|
||||||
|
|
||||||
deviceConnectionState = connectionStateUpdate.connectionState;
|
if ((scanResult!.advertisementData.serviceUuids[0].toString()[31] == "0") && isAddEquipment == false) {
|
||||||
connectStateCallBack(deviceConnectionState!);
|
connectStateCallBack(BluetoothConnectionState.disconnected!);
|
||||||
} on Exception catch (e) {
|
EasyLoading.showToast("该锁已被重置", duration: 2000.milliseconds);
|
||||||
deviceConnectionState = DeviceConnectionState.disconnected;
|
return;
|
||||||
connectStateCallBack(deviceConnectionState!);
|
}
|
||||||
print('Error occurred when discovering services: $e');
|
|
||||||
rethrow;
|
// 重连三次
|
||||||
}
|
int maxAttempts = 3;
|
||||||
} else if (connectionStateUpdate.connectionState == DeviceConnectionState.disconnected) {
|
int attempt = 0;
|
||||||
// 如果状态是断开的
|
while (attempt < maxAttempts) {
|
||||||
deviceConnectionState = connectionStateUpdate.connectionState;
|
try {
|
||||||
if(isReturnedConnectResults == false){
|
await bluetoothConnectDevice!.connect(timeout: 5.seconds);
|
||||||
isReturnedConnectResults = true;
|
break; // If the connection is successful, break the loop
|
||||||
// 如果是在连接中断开的
|
} catch (e) {
|
||||||
connectStateCallBack(deviceConnectionState!);
|
Get.log('Failed to connect: $e');
|
||||||
|
attempt++; // Increase the attempt count
|
||||||
|
if (attempt < maxAttempts) {
|
||||||
|
Get.log('Retrying connection...');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print('ConnectionState for device $connectDeviceMacAddress : ${connectionStateUpdate.connectionState}');
|
}
|
||||||
}, onError: (Object e) {
|
|
||||||
deviceConnectionState = DeviceConnectionState.disconnected;
|
if (attempt >= maxAttempts) {
|
||||||
connectStateCallBack(deviceConnectionState!);
|
Get.log('Failed to connect after $maxAttempts attempts.');
|
||||||
print('Connecting to device $connectDeviceMacAddress resulted in error $e');
|
connectStateCallBack(BluetoothConnectionState.disconnected!);
|
||||||
});
|
}
|
||||||
|
|
||||||
|
// await bluetoothConnectDevice!.connect();
|
||||||
|
print("5555555:回调状态:$bluetoothConnectionState");
|
||||||
|
if (bluetoothConnectionState == BluetoothConnectionState.connected) {
|
||||||
|
try {
|
||||||
|
bluetoothConnectDevice!.discoverServices().then((services) {
|
||||||
|
print("333333333");
|
||||||
|
for (BluetoothService service in services) {
|
||||||
|
// print("11111service.remoteId:${service.remoteId}"
|
||||||
|
// " service.uuid:${service.uuid}"
|
||||||
|
// " service.characteristics:${service.characteristics}"
|
||||||
|
// " service.includedServices:${service.includedServices}");
|
||||||
|
if(service.uuid == _serviceIdConnect){
|
||||||
|
for (BluetoothCharacteristic characteristic in service.characteristics) {
|
||||||
|
// print("22222characteristic.remoteId:${characteristic.remoteId}"
|
||||||
|
// " characteristic.uuid:${characteristic.uuid}"
|
||||||
|
// " characteristic.secondaryServiceUuid:${characteristic.secondaryServiceUuid}"
|
||||||
|
// " characteristic.characteristicUuid:${characteristic.characteristicUuid}");
|
||||||
|
if (characteristic.characteristicUuid == _characteristicIdSubscription) {
|
||||||
|
print("44444444");
|
||||||
|
_subScribeToCharacteristic(characteristic);
|
||||||
|
print('Discovering services finished');
|
||||||
|
bluetoothConnectionState = BluetoothConnectionState.connected;
|
||||||
|
connectStateCallBack(bluetoothConnectionState!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} on Exception catch (e) {
|
||||||
|
bluetoothConnectionState = BluetoothConnectionState.disconnected;
|
||||||
|
Get.log("5555 回调状态:$bluetoothConnectionState");
|
||||||
|
connectStateCallBack(bluetoothConnectionState!);
|
||||||
|
print('Error occurred when discovering services: $e');
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 听上报来的数据,参数来自前面扫描到的结果
|
// 听上报来的数据,参数来自前面扫描到的结果
|
||||||
@ -241,9 +361,11 @@ class BlueManage {
|
|||||||
// 保存上一次的数据,用来判断是否收到重复的数据
|
// 保存上一次的数据,用来判断是否收到重复的数据
|
||||||
var lastTimeData = <int>[];
|
var lastTimeData = <int>[];
|
||||||
int? dataLen;
|
int? dataLen;
|
||||||
_subScribeToCharacteristic(QualifiedCharacteristic characteristic) {
|
_subScribeToCharacteristic(BluetoothCharacteristic characteristic) async {
|
||||||
_flutterReactiveBle!.subscribeToCharacteristic(characteristic).listen((data) {
|
final subscription = characteristic.onValueReceived.listen((data) {
|
||||||
if(data == lastTimeData){
|
print("启动对特性的通知。当特性的值发生变化时,设备会发送一个通知");
|
||||||
|
print("订阅获取的数据:$data");
|
||||||
|
if(data == lastTimeData || data.isEmpty){
|
||||||
return;
|
return;
|
||||||
}else{
|
}else{
|
||||||
lastTimeData = data;
|
lastTimeData = data;
|
||||||
@ -279,97 +401,179 @@ class BlueManage {
|
|||||||
allData = <int>[];
|
allData = <int>[];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, onError: (dynamic error) {
|
|
||||||
EasyLoading.dismiss();
|
|
||||||
print("subscribeToCharacteristic error:$error");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// cleanup: cancel subscription when disconnected
|
||||||
|
bluetoothConnectDevice!.cancelWhenDisconnected(subscription);
|
||||||
|
|
||||||
|
// enable notifications
|
||||||
|
await characteristic.setNotifyValue(true);
|
||||||
|
|
||||||
|
// characteristic.setNotifyValue(true).then((_) {
|
||||||
|
// print("启动对特性的通知。当特性的值发生变化时,设备会发送一个通知");
|
||||||
|
// characteristic.lastValueStream.listen((data) {
|
||||||
|
// print("订阅获取的数据:$data");
|
||||||
|
// // do something with new value
|
||||||
|
// if(data == lastTimeData || data.isEmpty){
|
||||||
|
// return;
|
||||||
|
// }else{
|
||||||
|
// lastTimeData = data;
|
||||||
|
// }
|
||||||
|
// // code to handle incoming data
|
||||||
|
// // print("subscribeToCharacteristic: deviceId = ${characteristic.deviceId} characteristicId =${characteristic.characteristicId}---上报来的数据data = $data");
|
||||||
|
// if ((data[0] == 0xEF) && (data[1] == 0x01) && (data[2] == 0xEE) && (data[3] == 0x02)) {
|
||||||
|
// // 当包有头时
|
||||||
|
// // 判断是否需要分包
|
||||||
|
// dataLen = data[8] * 256 + data[9]; // 高16位用来指示后面数据块内容的长度
|
||||||
|
// // print("dataLen1111:$dataLen getDataLength:${data.length}");
|
||||||
|
// if (dataLen! + 12 > data.length) {
|
||||||
|
// // 当前包的长度小于实际的包时 分包添加 不解析
|
||||||
|
// allData.addAll(data);
|
||||||
|
// } else {
|
||||||
|
// // 当前包的长度小于实际的包时 不分包 解析
|
||||||
|
// allData.addAll(data);
|
||||||
|
// // print("dataLen2222:$dataLen getDataLength:${data.length}");
|
||||||
|
// CommandReciverManager.appDataReceive(allData);
|
||||||
|
// // 发送完解析初始化数组
|
||||||
|
// allData = <int>[];
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// // 当包没有头时 是分包的包 直接添加
|
||||||
|
// allData.addAll(data);
|
||||||
|
// // var len = allData[8] * 256 + allData[9];
|
||||||
|
// // print("dataLen3333:$dataLen");
|
||||||
|
// if ((dataLen! + 14) <= allData.length) {
|
||||||
|
// // print("44444数据被解析了");
|
||||||
|
// // 当长度小于等于当前包的数据时 直接解析数据
|
||||||
|
// CommandReciverManager.appDataReceive(allData);
|
||||||
|
// // 发送完解析初始化数组
|
||||||
|
// allData = <int>[];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
// 写入
|
// 写入
|
||||||
Future<void> writeCharacteristicWithResponse(List<int> value) async {
|
Future<void> writeCharacteristicWithResponse(List<int> value) async {
|
||||||
QualifiedCharacteristic characteristic = QualifiedCharacteristic(characteristicId: _characteristicIdWrite, serviceId: _serviceIdWrite, deviceId: connectDeviceMacAddress);
|
bluetoothConnectDevice!.discoverServices().then((services) async {
|
||||||
int mtuLength = await _flutterReactiveBle!.requestMtu(deviceId: characteristic.deviceId, mtu: 512);
|
for (BluetoothService service in services) {
|
||||||
print("mtuLength:$mtuLength");
|
// print("33333 service.remoteId:${service.remoteId}"
|
||||||
try {
|
// " service.uuid:${service.uuid}\n\n"
|
||||||
List<int> valueList = value;
|
// " service.characteristics:${service.characteristics}\n\n"
|
||||||
List subData = splitList(valueList, mtuLength);
|
// " service.includedServices:${service.includedServices}");
|
||||||
print('得到的分割数据:$subData');
|
if (service.uuid == _serviceIdConnect) {
|
||||||
|
for (BluetoothCharacteristic characteristic in service
|
||||||
|
.characteristics) {
|
||||||
|
// print("44444 characteristic.remoteId:${characteristic.remoteId}"
|
||||||
|
// " characteristic.uuid:${characteristic.uuid}\n\n"
|
||||||
|
// " characteristic.secondaryServiceUuid:${characteristic
|
||||||
|
// .secondaryServiceUuid}\n\n"
|
||||||
|
// " characteristic.characteristicUuid:${characteristic
|
||||||
|
// .characteristicUuid}");
|
||||||
|
if (characteristic.characteristicUuid == _characteristicIdWrite) {
|
||||||
|
try {
|
||||||
|
List<int> valueList = value;
|
||||||
|
List subData = splitList(valueList, _mtuSize!);
|
||||||
|
print(
|
||||||
|
'writeCharacteristicWithResponse 得到的分割数据:$subData');
|
||||||
|
|
||||||
for (int i = 0; i < subData.length; i++) {
|
for (int i = 0; i < subData.length; i++) {
|
||||||
await _flutterReactiveBle!
|
await characteristic.write(subData[i]).then((value) async {
|
||||||
.writeCharacteristicWithResponse(characteristic, value: subData[i])
|
await Future.delayed(const Duration(milliseconds: 1)).then((
|
||||||
.then((value) async {
|
value) async {
|
||||||
await Future.delayed(const Duration(milliseconds: 1))
|
print('分包发送成功了');
|
||||||
.then((value) async {
|
});
|
||||||
print('分包发送成功了');
|
});
|
||||||
});
|
}
|
||||||
});
|
} on Exception catch (e, s) {
|
||||||
|
print('Error occurred when writing: $e');
|
||||||
|
print(s);
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} on Exception catch (e, s) {
|
});
|
||||||
print('Error occurred when writing: $e');
|
// List<BluetoothService> services = await bluetoothConnectDevice!.discoverServices();
|
||||||
// ignore: avoid_print
|
// BluetoothCharacteristic characteristic = services
|
||||||
print(s);
|
// .firstWhere((service) => service.uuid == _serviceIdWrite)
|
||||||
rethrow;
|
// .characteristics
|
||||||
}
|
// .firstWhere((char) => char.uuid == _characteristicIdWrite);
|
||||||
|
// try {
|
||||||
|
// List<int> valueList = value;
|
||||||
|
// List subData = splitList(valueList, _mtuSize!);
|
||||||
|
// print('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 {
|
||||||
|
// print('分包发送成功了');
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// } on Exception catch (e, s) {
|
||||||
|
// print('Error occurred when writing: $e');
|
||||||
|
// print(s);
|
||||||
|
// rethrow;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// 读取
|
// 读取
|
||||||
Future<List<int>> _readCharacteristic(QualifiedCharacteristic characteristic) async {
|
// Future<List<int>> _readCharacteristic(QualifiedCharacteristic characteristic) async {
|
||||||
try {
|
// try {
|
||||||
final result =
|
// final result =
|
||||||
await _flutterReactiveBle!.readCharacteristic(characteristic);
|
// await _flutterReactiveBle!.readCharacteristic(characteristic);
|
||||||
print("readListresult$result");
|
// print("readListresult$result");
|
||||||
return result;
|
// return result;
|
||||||
} on Exception catch (e, s) {
|
// } on Exception catch (e, s) {
|
||||||
print(
|
// print(
|
||||||
'Error occurred when reading ${characteristic.characteristicId} : $e',
|
// 'Error occurred when reading ${characteristic.characteristicId} : $e',
|
||||||
);
|
// );
|
||||||
rethrow;
|
// rethrow;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
Future<void> writeCharacteristicWithoutResponse(
|
// Future<void> writeCharacteristicWithoutResponse(
|
||||||
QualifiedCharacteristic characteristic, List<int> value) async {
|
// QualifiedCharacteristic characteristic, List<int> value) async {
|
||||||
try {
|
// try {
|
||||||
await _flutterReactiveBle!
|
// await _flutterReactiveBle!
|
||||||
.writeCharacteristicWithoutResponse(characteristic, value: value);
|
// .writeCharacteristicWithoutResponse(characteristic, value: value);
|
||||||
} on Exception catch (e, s) {
|
// } on Exception catch (e, s) {
|
||||||
// ignore: avoid_print
|
// // ignore: avoid_print
|
||||||
print(s);
|
// print(s);
|
||||||
rethrow;
|
// rethrow;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 停止扫描蓝牙设备
|
// 停止扫描蓝牙设备
|
||||||
void stopScan() {
|
Future<void> stopScan() async {
|
||||||
// print("444444444");
|
try {
|
||||||
if(_scanSubscription != null){
|
await FlutterBluePlus.stopScan();
|
||||||
// print("555555555555");
|
} catch (e) {
|
||||||
_scanSubscription?.cancel();
|
Get.log("停止扫描失败");
|
||||||
_scanSubscription = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 断开连接
|
// 断开连接
|
||||||
Future<void> disconnect(String deviceMAC) async {
|
Future<void> disconnect() async {
|
||||||
try {
|
try {
|
||||||
connectDeviceMacAddress = "";
|
connectDeviceMacAddress = "";
|
||||||
// if(_currentConnectionStream != null){
|
await bluetoothConnectDevice!.disconnect();
|
||||||
_currentConnectionStream?.cancel();
|
Get.log("断开连接成功");
|
||||||
_currentConnectionStream = null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
print('disconnecting to device: $connectDeviceName');
|
|
||||||
} on Exception catch (e, _) {
|
} on Exception catch (e, _) {
|
||||||
print("Error disconnecting from a device: $e");
|
print("Error disconnecting from a device: $e");
|
||||||
} finally {
|
} finally {
|
||||||
deviceConnectionState = DeviceConnectionState.disconnected;
|
bluetoothConnectionState = BluetoothConnectionState.disconnected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
disposed() {
|
disposed() {
|
||||||
_sendStreamSubscription?.cancel();
|
_sendStreamSubscription?.cancel();
|
||||||
_currentConnectionStream?.cancel();
|
_mtuSubscription!.cancel();
|
||||||
_scanSubscription?.cancel();
|
// _scanResultsSubscription!.cancel();
|
||||||
|
_adapterStateStateSubscription!.cancel();
|
||||||
|
_connectionStateSubscription!.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/appRouters.dart';
|
import 'package:star_lock/appRouters.dart';
|
||||||
import 'package:star_lock/blue/io_type.dart';
|
import 'package:star_lock/blue/io_type.dart';
|
||||||
@ -162,8 +163,8 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
|||||||
// 转移权限
|
// 转移权限
|
||||||
Future<void> transferPermissionsAction() async {
|
Future<void> transferPermissionsAction() async {
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||||
(DeviceConnectionState state) async {
|
(BluetoothConnectionState state) async {
|
||||||
if (state == DeviceConnectionState.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!);
|
||||||
|
|
||||||
|
|||||||
@ -119,7 +119,6 @@ class _AddCardPageState extends State<AddCardPage> {
|
|||||||
String titleStr, String rightTitle, TextEditingController controller) {
|
String titleStr, String rightTitle, TextEditingController controller) {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
Container(height: 10.h),
|
|
||||||
CommonItem(
|
CommonItem(
|
||||||
leftTitel: titleStr,
|
leftTitel: titleStr,
|
||||||
rightTitle: "",
|
rightTitle: "",
|
||||||
@ -142,16 +141,12 @@ class _AddCardPageState extends State<AddCardPage> {
|
|||||||
action: () async {
|
action: () async {
|
||||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||||
onConfirm: (p) {
|
onConfirm: (p) {
|
||||||
setState(() {
|
|
||||||
setState(() {
|
|
||||||
state.beginTime.value =
|
state.beginTime.value =
|
||||||
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
||||||
state.beginTimeTimestamp.value =
|
state.beginTimeTimestamp.value =
|
||||||
DateTime.parse(state.beginTime.value)
|
DateTime.parse(state.beginTime.value)
|
||||||
.millisecondsSinceEpoch
|
.millisecondsSinceEpoch
|
||||||
.toString();
|
.toString();
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
})),
|
})),
|
||||||
Obx(() => CommonItem(
|
Obx(() => CommonItem(
|
||||||
@ -161,16 +156,12 @@ class _AddCardPageState extends State<AddCardPage> {
|
|||||||
action: () {
|
action: () {
|
||||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||||
onConfirm: (p) {
|
onConfirm: (p) {
|
||||||
setState(() {
|
|
||||||
setState(() {
|
|
||||||
state.endTime.value =
|
state.endTime.value =
|
||||||
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
||||||
state.endTimeTimestamp.value =
|
state.endTimeTimestamp.value =
|
||||||
DateTime.parse(state.endTime.value)
|
DateTime.parse(state.endTime.value)
|
||||||
.millisecondsSinceEpoch
|
.millisecondsSinceEpoch
|
||||||
.toString();
|
.toString();
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
})),
|
})),
|
||||||
Container(height: 10.h),
|
Container(height: 10.h),
|
||||||
@ -181,21 +172,21 @@ class _AddCardPageState extends State<AddCardPage> {
|
|||||||
Widget keyBottomWidget() {
|
Widget keyBottomWidget() {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
CommonItem(
|
Obx(() => CommonItem(
|
||||||
leftTitel: "是否是管理员",
|
leftTitel: "是否是管理员",
|
||||||
rightTitle: "",
|
rightTitle: "",
|
||||||
isTipsImg: false,
|
isTipsImg: false,
|
||||||
isHaveRightWidget: true,
|
isHaveRightWidget: true,
|
||||||
rightWidget: SizedBox(
|
rightWidget: SizedBox(
|
||||||
width: 60.w, height: 50.h, child: _isAdmin())),
|
width: 60.w, height: 50.h, child: _isAdmin()))),
|
||||||
SizedBox(height: 10.h),
|
SizedBox(height: 10.h),
|
||||||
CommonItem(
|
Obx(() => CommonItem(
|
||||||
leftTitel: TranslationLoader.lanKeys!.stressCard!.tr,
|
leftTitel: TranslationLoader.lanKeys!.stressCard!.tr,
|
||||||
rightTitle: "",
|
rightTitle: "",
|
||||||
isTipsImg: false,
|
isTipsImg: false,
|
||||||
isHaveRightWidget: true,
|
isHaveRightWidget: true,
|
||||||
rightWidget: SizedBox(
|
rightWidget: SizedBox(
|
||||||
width: 60.w, height: 50.h, child: _isStressFingerprint())),
|
width: 60.w, height: 50.h, child: _isStressFingerprint()))),
|
||||||
SizedBox(height: 30.h),
|
SizedBox(height: 30.h),
|
||||||
SubmitBtn(
|
SubmitBtn(
|
||||||
btnName: TranslationLoader.lanKeys!.next!.tr,
|
btnName: TranslationLoader.lanKeys!.next!.tr,
|
||||||
@ -359,9 +350,7 @@ class _AddCardPageState extends State<AddCardPage> {
|
|||||||
thumbColor: CupertinoColors.white,
|
thumbColor: CupertinoColors.white,
|
||||||
value: state.isStressFingerprint.value,
|
value: state.isStressFingerprint.value,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
state.isStressFingerprint.value = value;
|
||||||
state.isStressFingerprint.value = value;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -374,9 +363,7 @@ class _AddCardPageState extends State<AddCardPage> {
|
|||||||
thumbColor: CupertinoColors.white,
|
thumbColor: CupertinoColors.white,
|
||||||
value: state.isAdministrator.value,
|
value: state.isAdministrator.value,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
state.isAdministrator.value = value;
|
||||||
state.isAdministrator.value = value;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/blue/io_type.dart';
|
import 'package:star_lock/blue/io_type.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
@ -221,8 +222,8 @@ class AddICCardLogic extends BaseGetXController{
|
|||||||
print("没有任何响应");
|
print("没有任何响应");
|
||||||
Get.close(1);
|
Get.close(1);
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||||
@ -248,7 +249,7 @@ class AddICCardLogic extends BaseGetXController{
|
|||||||
privateKey:getPrivateKeyList,
|
privateKey:getPrivateKeyList,
|
||||||
token: getTokenList,
|
token: getTokenList,
|
||||||
);
|
);
|
||||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected){
|
} else if (deviceConnectionState == BluetoothConnectionState.disconnected){
|
||||||
if(state.ifCurrentScreen.value == true){
|
if(state.ifCurrentScreen.value == true){
|
||||||
showBlueConnetctToast();
|
showBlueConnetctToast();
|
||||||
}
|
}
|
||||||
@ -260,8 +261,8 @@ class AddICCardLogic extends BaseGetXController{
|
|||||||
|
|
||||||
// 添加胁迫卡片
|
// 添加胁迫卡片
|
||||||
Future<void> senderAddStressICCard() async {
|
Future<void> senderAddStressICCard() async {
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/blue/io_type.dart';
|
import 'package:star_lock/blue/io_type.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
@ -99,8 +100,8 @@ class CardDetailLogic extends BaseGetXController{
|
|||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -124,7 +125,7 @@ class CardDetailLogic extends BaseGetXController{
|
|||||||
privateKey:getPrivateKeyList,
|
privateKey:getPrivateKeyList,
|
||||||
token: getTokenList,
|
token: getTokenList,
|
||||||
);
|
);
|
||||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:star_lock/blue/io_type.dart';
|
import 'package:star_lock/blue/io_type.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
import '../../../../blue/blue_manage.dart';
|
import '../../../../blue/blue_manage.dart';
|
||||||
@ -206,8 +207,8 @@ class CardListLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 查询卡片状态
|
// 查询卡片状态
|
||||||
Future<void> senderCheckingCardStatus() async {
|
Future<void> senderCheckingCardStatus() async {
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async {
|
||||||
if (state == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -234,8 +235,8 @@ class CardListLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
||||||
Future<void> senderCheckingUserInfoCount() async {
|
Future<void> senderCheckingUserInfoCount() async {
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async {
|
||||||
if (state == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -265,8 +266,8 @@ class CardListLogic extends BaseGetXController {
|
|||||||
showBlueConnetctToastTimer(action: (){
|
showBlueConnetctToastTimer(action: (){
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -289,7 +290,7 @@ class CardListLogic extends BaseGetXController {
|
|||||||
privateKey:getPrivateKeyList,
|
privateKey:getPrivateKeyList,
|
||||||
token: getTokenList,
|
token: getTokenList,
|
||||||
);
|
);
|
||||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
if(state.ifCurrentScreen.value == true){
|
if(state.ifCurrentScreen.value == true){
|
||||||
|
|||||||
@ -2,8 +2,9 @@ import 'dart:async';
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart';
|
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart';
|
||||||
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_state.dart';
|
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_state.dart';
|
||||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart';
|
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart';
|
||||||
@ -160,8 +161,8 @@ class DoorLockLogLogic extends BaseGetXController {
|
|||||||
// 查询事件记录(时间查询)
|
// 查询事件记录(时间查询)
|
||||||
Future<void> senderReferEventRecordTime(int time) async {
|
Future<void> senderReferEventRecordTime(int time) async {
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||||
(DeviceConnectionState state) async {
|
(BluetoothConnectionState state) async {
|
||||||
if (state == DeviceConnectionState.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!);
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_addFace.dart';
|
import 'package:star_lock/blue/io_protocol/io_addFace.dart';
|
||||||
import 'package:star_lock/blue/io_type.dart';
|
import 'package:star_lock/blue/io_type.dart';
|
||||||
@ -190,8 +191,8 @@ class AddFaceLogic extends BaseGetXController {
|
|||||||
Get.close(1);
|
Get.close(1);
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||||
(DeviceConnectionState deviceConnectionState) async {
|
(BluetoothConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.connected) {
|
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||||
@ -220,7 +221,7 @@ class AddFaceLogic extends BaseGetXController {
|
|||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
token: getTokenList,
|
token: getTokenList,
|
||||||
);
|
);
|
||||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||||
if (state.ifCurrentScreen.value == true) {
|
if (state.ifCurrentScreen.value == true) {
|
||||||
showBlueConnetctToast();
|
showBlueConnetctToast();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_addFace.dart';
|
import 'package:star_lock/blue/io_protocol/io_addFace.dart';
|
||||||
import 'package:star_lock/blue/io_type.dart';
|
import 'package:star_lock/blue/io_type.dart';
|
||||||
@ -100,8 +101,8 @@ class FaceDetailLogic extends BaseGetXController {
|
|||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||||
(DeviceConnectionState deviceConnectionState) async {
|
(BluetoothConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -125,7 +126,7 @@ class FaceDetailLogic extends BaseGetXController {
|
|||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
token: getTokenList,
|
token: getTokenList,
|
||||||
);
|
);
|
||||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_addFace.dart';
|
import 'package:star_lock/blue/io_protocol/io_addFace.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_queryingFaceStatus.dart';
|
import 'package:star_lock/blue/io_protocol/io_queryingFaceStatus.dart';
|
||||||
import 'package:star_lock/blue/io_type.dart';
|
import 'package:star_lock/blue/io_type.dart';
|
||||||
@ -244,8 +245,8 @@ class FaceListLogic extends BaseGetXController {
|
|||||||
// 获取人脸状态
|
// 获取人脸状态
|
||||||
Future<void> senderQueryingFaceStatus() async {
|
Future<void> senderQueryingFaceStatus() async {
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||||
(DeviceConnectionState state) async {
|
(BluetoothConnectionState state) async {
|
||||||
if (state == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -273,8 +274,8 @@ class FaceListLogic extends BaseGetXController {
|
|||||||
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
||||||
Future<void> senderCheckingUserInfoCount() async {
|
Future<void> senderCheckingUserInfoCount() async {
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||||
(DeviceConnectionState state) async {
|
(BluetoothConnectionState state) async {
|
||||||
if (state == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -305,8 +306,8 @@ class FaceListLogic extends BaseGetXController {
|
|||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||||
(DeviceConnectionState deviceConnectionState) async {
|
(BluetoothConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -328,7 +329,7 @@ class FaceListLogic extends BaseGetXController {
|
|||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
token: getTokenList,
|
token: getTokenList,
|
||||||
);
|
);
|
||||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
if (state.ifCurrentScreen.value == true) {
|
if (state.ifCurrentScreen.value == true) {
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/blue/io_type.dart';
|
import 'package:star_lock/blue/io_type.dart';
|
||||||
|
|
||||||
@ -264,8 +265,8 @@ class AddFingerprintLogic extends BaseGetXController {
|
|||||||
showBlueConnetctToastTimer(action: (){
|
showBlueConnetctToastTimer(action: (){
|
||||||
Get.close(1);
|
Get.close(1);
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||||
@ -291,7 +292,7 @@ class AddFingerprintLogic extends BaseGetXController {
|
|||||||
privateKey:getPrivateKeyList,
|
privateKey:getPrivateKeyList,
|
||||||
token: getTokenList,
|
token: getTokenList,
|
||||||
);
|
);
|
||||||
}else if (deviceConnectionState == DeviceConnectionState.disconnected){
|
}else if (deviceConnectionState == BluetoothConnectionState.disconnected){
|
||||||
if(state.ifCurrentScreen.value == true){
|
if(state.ifCurrentScreen.value == true){
|
||||||
showBlueConnetctToast();
|
showBlueConnetctToast();
|
||||||
}
|
}
|
||||||
@ -303,8 +304,8 @@ class AddFingerprintLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 添加胁迫指纹
|
// 添加胁迫指纹
|
||||||
Future<void> senderAddStressFingerprint() async {
|
Future<void> senderAddStressFingerprint() async {
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
|
|||||||
@ -119,7 +119,6 @@ class _AddFingerprintTypePageState extends State<AddFingerprintTypePage> {
|
|||||||
String titleStr, String rightTitle, TextEditingController controller) {
|
String titleStr, String rightTitle, TextEditingController controller) {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
Container(height: 10.h),
|
|
||||||
CommonItem(
|
CommonItem(
|
||||||
leftTitel: titleStr,
|
leftTitel: titleStr,
|
||||||
rightTitle: "",
|
rightTitle: "",
|
||||||
@ -142,16 +141,12 @@ class _AddFingerprintTypePageState extends State<AddFingerprintTypePage> {
|
|||||||
action: () async {
|
action: () async {
|
||||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||||
onConfirm: (p) {
|
onConfirm: (p) {
|
||||||
setState(() {
|
|
||||||
setState(() {
|
|
||||||
state.beginTime.value =
|
state.beginTime.value =
|
||||||
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
||||||
state.beginTimeTimestamp.value =
|
state.beginTimeTimestamp.value =
|
||||||
DateTime.parse(state.beginTime.value)
|
DateTime.parse(state.beginTime.value)
|
||||||
.millisecondsSinceEpoch
|
.millisecondsSinceEpoch
|
||||||
.toString();
|
.toString();
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
})),
|
})),
|
||||||
Obx(() => CommonItem(
|
Obx(() => CommonItem(
|
||||||
@ -161,16 +156,12 @@ class _AddFingerprintTypePageState extends State<AddFingerprintTypePage> {
|
|||||||
action: () {
|
action: () {
|
||||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||||
onConfirm: (p) {
|
onConfirm: (p) {
|
||||||
setState(() {
|
|
||||||
setState(() {
|
|
||||||
state.endTime.value =
|
state.endTime.value =
|
||||||
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
||||||
state.endTimeTimestamp.value =
|
state.endTimeTimestamp.value =
|
||||||
DateTime.parse(state.endTime.value)
|
DateTime.parse(state.endTime.value)
|
||||||
.millisecondsSinceEpoch
|
.millisecondsSinceEpoch
|
||||||
.toString();
|
.toString();
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
})),
|
})),
|
||||||
Container(height: 10.h),
|
Container(height: 10.h),
|
||||||
@ -181,21 +172,21 @@ class _AddFingerprintTypePageState extends State<AddFingerprintTypePage> {
|
|||||||
Widget keyBottomWidget() {
|
Widget keyBottomWidget() {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
CommonItem(
|
Obx(() => CommonItem(
|
||||||
leftTitel: "是否是管理员",
|
leftTitel: "是否是管理员",
|
||||||
rightTitle: "",
|
rightTitle: "",
|
||||||
isTipsImg: false,
|
isTipsImg: false,
|
||||||
isHaveRightWidget: true,
|
isHaveRightWidget: true,
|
||||||
rightWidget: SizedBox(
|
rightWidget: SizedBox(
|
||||||
width: 60.w, height: 50.h, child: _isAdmin())),
|
width: 60.w, height: 50.h, child: _isAdmin()))),
|
||||||
SizedBox(height: 10.h),
|
SizedBox(height: 10.h),
|
||||||
CommonItem(
|
Obx(() => CommonItem(
|
||||||
leftTitel: TranslationLoader.lanKeys!.stressFingerprint!.tr,
|
leftTitel: TranslationLoader.lanKeys!.stressFingerprint!.tr,
|
||||||
rightTitle: "",
|
rightTitle: "",
|
||||||
isTipsImg: false,
|
isTipsImg: false,
|
||||||
isHaveRightWidget: true,
|
isHaveRightWidget: true,
|
||||||
rightWidget: SizedBox(
|
rightWidget: SizedBox(
|
||||||
width: 60.w, height: 50.h, child: _isStressFingerprint())),
|
width: 60.w, height: 50.h, child: _isStressFingerprint()))),
|
||||||
SizedBox(height: 30.h),
|
SizedBox(height: 30.h),
|
||||||
SubmitBtn(
|
SubmitBtn(
|
||||||
btnName: TranslationLoader.lanKeys!.next!.tr,
|
btnName: TranslationLoader.lanKeys!.next!.tr,
|
||||||
@ -339,9 +330,7 @@ class _AddFingerprintTypePageState extends State<AddFingerprintTypePage> {
|
|||||||
thumbColor: CupertinoColors.white,
|
thumbColor: CupertinoColors.white,
|
||||||
value: state.isStressFingerprint.value,
|
value: state.isStressFingerprint.value,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
state.isStressFingerprint.value = value;
|
||||||
state.isStressFingerprint.value = value;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -354,9 +343,7 @@ class _AddFingerprintTypePageState extends State<AddFingerprintTypePage> {
|
|||||||
thumbColor: CupertinoColors.white,
|
thumbColor: CupertinoColors.white,
|
||||||
value: state.isAdministrator.value,
|
value: state.isAdministrator.value,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
state.isAdministrator.value = value;
|
||||||
state.isAdministrator.value = value;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/blue/io_type.dart';
|
import 'package:star_lock/blue/io_type.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
@ -100,8 +101,8 @@ class FingerprintDetailLogic extends BaseGetXController{
|
|||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -125,7 +126,7 @@ class FingerprintDetailLogic extends BaseGetXController{
|
|||||||
privateKey:getPrivateKeyList,
|
privateKey:getPrivateKeyList,
|
||||||
token: getTokenList,
|
token: getTokenList,
|
||||||
);
|
);
|
||||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:star_lock/blue/io_type.dart';
|
import 'package:star_lock/blue/io_type.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
import '../../../../blue/blue_manage.dart';
|
import '../../../../blue/blue_manage.dart';
|
||||||
@ -239,8 +240,8 @@ class FingerprintListLogic extends BaseGetXController{
|
|||||||
}
|
}
|
||||||
// 获取指纹状态
|
// 获取指纹状态
|
||||||
Future<void> senderQueryingFingerprintStatus() async {
|
Future<void> senderQueryingFingerprintStatus() async {
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName,(DeviceConnectionState state) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName,(BluetoothConnectionState state) async {
|
||||||
if (state == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -267,8 +268,8 @@ class FingerprintListLogic extends BaseGetXController{
|
|||||||
|
|
||||||
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
||||||
Future<void> senderCheckingUserInfoCount() async {
|
Future<void> senderCheckingUserInfoCount() async {
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async {
|
||||||
if (state == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -298,8 +299,8 @@ class FingerprintListLogic extends BaseGetXController{
|
|||||||
showBlueConnetctToastTimer(action: (){
|
showBlueConnetctToastTimer(action: (){
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -321,7 +322,7 @@ class FingerprintListLogic extends BaseGetXController{
|
|||||||
privateKey:getPrivateKeyList,
|
privateKey:getPrivateKeyList,
|
||||||
token: getTokenList,
|
token: getTokenList,
|
||||||
);
|
);
|
||||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
if(state.ifCurrentScreen.value == true){
|
if(state.ifCurrentScreen.value == true){
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
@ -92,6 +93,8 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
getLockRecordLastUploadDataTime();
|
getLockRecordLastUploadDataTime();
|
||||||
state.openLockBtnState.value = 0;
|
state.openLockBtnState.value = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||||
break;
|
break;
|
||||||
case 0x06:
|
case 0x06:
|
||||||
@ -270,6 +273,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
lockRecordUploadData(uploadList);
|
lockRecordUploadData(uploadList);
|
||||||
// print("reply.data:${reply.data} getList:$getList}");
|
// print("reply.data:${reply.data} getList:$getList}");
|
||||||
|
await BlueManage().disconnect();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x06:
|
case 0x06:
|
||||||
@ -375,10 +379,9 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||||
});
|
});
|
||||||
|
|
||||||
BlueManage()
|
BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!,
|
||||||
.bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!,
|
(BluetoothConnectionState deviceConnectionState) async {
|
||||||
(DeviceConnectionState deviceConnectionState) async {
|
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||||
if (deviceConnectionState == DeviceConnectionState.connected) {
|
|
||||||
// 私钥
|
// 私钥
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
@ -408,7 +411,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
publicKey: publicKeyDataList,
|
publicKey: publicKeyDataList,
|
||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
token: getTokenList);
|
token: getTokenList);
|
||||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
if (state.ifCurrentScreen.value == true) {
|
if (state.ifCurrentScreen.value == true) {
|
||||||
showBlueConnetctToast();
|
showBlueConnetctToast();
|
||||||
@ -436,7 +439,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
var token = await Storage.getStringList(saveBlueToken);
|
var token = await Storage.getStringList(saveBlueToken);
|
||||||
List<int> getTokenList = changeStringListToIntList(token!);
|
List<int> getTokenList = changeStringListToIntList(token!);
|
||||||
|
|
||||||
print("调用了开锁事件 openDoorTokenPubToken:$getTokenList getPrivateKeyList:$getPrivateKeyList");
|
// print("调用了开锁事件 openDoorTokenPubToken:$getTokenList getPrivateKeyList:$getPrivateKeyList");
|
||||||
// List<int>listData = await IoSenderManage.senderOpenLock(
|
// List<int>listData = await IoSenderManage.senderOpenLock(
|
||||||
// keyID: BlueManage().connectDeviceName,
|
// keyID: BlueManage().connectDeviceName,
|
||||||
// userID: await Storage.getUid(),
|
// userID: await Storage.getUid(),
|
||||||
@ -450,8 +453,8 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
// );
|
// );
|
||||||
BlueManage()
|
BlueManage()
|
||||||
.bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!,
|
.bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!,
|
||||||
(DeviceConnectionState deviceConnectionState) async {
|
(BluetoothConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.connected) {
|
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||||
IoSenderManage.senderOpenLock(
|
IoSenderManage.senderOpenLock(
|
||||||
keyID: BlueManage().connectDeviceName,
|
keyID: BlueManage().connectDeviceName,
|
||||||
userID: await Storage.getUid(),
|
userID: await Storage.getUid(),
|
||||||
@ -463,7 +466,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
signKey: signKeyDataList,
|
signKey: signKeyDataList,
|
||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
);
|
);
|
||||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
if (state.ifCurrentScreen.value == true) {
|
if (state.ifCurrentScreen.value == true) {
|
||||||
showBlueConnetctToast();
|
showBlueConnetctToast();
|
||||||
@ -564,8 +567,8 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
// 查询事件记录(时间查询)
|
// 查询事件记录(时间查询)
|
||||||
Future<void> senderReferEventRecordTime(int time) async {
|
Future<void> senderReferEventRecordTime(int time) async {
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||||
(DeviceConnectionState state) async {
|
(BluetoothConnectionState state) async {
|
||||||
if (state == DeviceConnectionState.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!);
|
||||||
|
|
||||||
|
|||||||
@ -850,9 +850,9 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
|||||||
}
|
}
|
||||||
|
|
||||||
startOpenLock() {
|
startOpenLock() {
|
||||||
print("11111111");
|
// print("11111111");
|
||||||
// checkBlueIsOpen((){
|
// checkBlueIsOpen((){
|
||||||
print("33333333");
|
// print("33333333");
|
||||||
if (state.openLockBtnState.value == 1) {
|
if (state.openLockBtnState.value == 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -911,9 +911,10 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
|||||||
AppRouteObserver().routeObserver.unsubscribe(this);
|
AppRouteObserver().routeObserver.unsubscribe(this);
|
||||||
state.closedUnlockSuccessfulTimer?.cancel();
|
state.closedUnlockSuccessfulTimer?.cancel();
|
||||||
_lockRefreshLockDetailInfoDataEvent?.cancel();
|
_lockRefreshLockDetailInfoDataEvent?.cancel();
|
||||||
|
|
||||||
if (state.animationController != null) {
|
if (state.animationController != null) {
|
||||||
state.animationController!.dispose();
|
state.animationController!.dispose();
|
||||||
// state.animationController = null;
|
state.animationController = null;
|
||||||
}
|
}
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
@ -934,7 +935,7 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
|||||||
state.ifCurrentScreen.value = false;
|
state.ifCurrentScreen.value = false;
|
||||||
logic.cancelBlueConnetctToastTimer();
|
logic.cancelBlueConnetctToastTimer();
|
||||||
BlueManage().stopScan();
|
BlueManage().stopScan();
|
||||||
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
BlueManage().disconnect();
|
||||||
state.openLockBtnState.value = 0;
|
state.openLockBtnState.value = 0;
|
||||||
|
|
||||||
// if(state.animationController != null){
|
// if(state.animationController != null){
|
||||||
@ -962,9 +963,9 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
|||||||
BlueManage().stopScan();
|
BlueManage().stopScan();
|
||||||
state.openLockBtnState.value = 0;
|
state.openLockBtnState.value = 0;
|
||||||
|
|
||||||
if (state.animationController!.isAnimating) {
|
// if (state.animationController!.isAnimating) {
|
||||||
state.animationController!.stop();
|
// state.animationController!.stop();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart';
|
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart';
|
||||||
|
|
||||||
import '../../../blue/blue_manage.dart';
|
import '../../../blue/blue_manage.dart';
|
||||||
@ -156,8 +157,8 @@ class LockOperatingRecordLogic extends BaseGetXController {
|
|||||||
// 查询事件记录(时间查询)
|
// 查询事件记录(时间查询)
|
||||||
Future<void> senderReferEventRecordTime(int time) async {
|
Future<void> senderReferEventRecordTime(int time) async {
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||||
(DeviceConnectionState state) async {
|
(BluetoothConnectionState state) async {
|
||||||
if (state == DeviceConnectionState.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!);
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_setSupportFunctionsWithParameters.dart';
|
import 'package:star_lock/blue/io_protocol/io_setSupportFunctionsWithParameters.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
@ -133,32 +134,6 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 读取支持功能-带参数
|
|
||||||
// Future<void> _readSupportFunctionsWithParameters() async {
|
|
||||||
// BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
|
||||||
// if (connectionState == DeviceConnectionState.connected) {
|
|
||||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
|
||||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
|
||||||
//
|
|
||||||
// var token = await Storage.getStringList(saveBlueToken);
|
|
||||||
// List<int> getTokenList = changeStringListToIntList(token!);
|
|
||||||
//
|
|
||||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
|
||||||
// List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
|
||||||
//
|
|
||||||
// IoSenderManage.readSupportFunctionsWithParametersCommand(
|
|
||||||
// keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
|
||||||
// userID: await Storage.getUid(),
|
|
||||||
// featureBit: 29,
|
|
||||||
// token: getTokenList,
|
|
||||||
// needAuthor: 1,
|
|
||||||
// publicKey: getPublicKeyList,
|
|
||||||
// privateKey: getPrivateKeyList
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 设置支持功能(带参数)
|
// 设置支持功能(带参数)
|
||||||
Future<void> sendAutoLock() async {
|
Future<void> sendAutoLock() async {
|
||||||
if(state.sureBtnState.value == 1){
|
if(state.sureBtnState.value == 1){
|
||||||
@ -171,8 +146,8 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
|||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -203,7 +178,7 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
|||||||
needAuthor: 1,
|
needAuthor: 1,
|
||||||
publicKey: getPublicKeyList,
|
publicKey: getPublicKeyList,
|
||||||
privateKey: getPrivateKeyList);
|
privateKey: getPrivateKeyList);
|
||||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:star_lock/blue/io_type.dart';
|
import 'package:star_lock/blue/io_type.dart';
|
||||||
|
|
||||||
import '../../../../../blue/blue_manage.dart';
|
import '../../../../../blue/blue_manage.dart';
|
||||||
@ -180,8 +181,8 @@ class AdminOpenLockPasswordLogic extends BaseGetXController{
|
|||||||
showBlueConnetctToastTimer(action: (){
|
showBlueConnetctToastTimer(action: (){
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -202,7 +203,7 @@ class AdminOpenLockPasswordLogic extends BaseGetXController{
|
|||||||
publicKey: getPublicKeyList,
|
publicKey: getPublicKeyList,
|
||||||
privateKey: getPrivateKeyList
|
privateKey: getPrivateKeyList
|
||||||
);
|
);
|
||||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
if(state.ifCurrentScreen.value == true){
|
if(state.ifCurrentScreen.value == true){
|
||||||
@ -224,8 +225,8 @@ class AdminOpenLockPasswordLogic extends BaseGetXController{
|
|||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -248,7 +249,7 @@ class AdminOpenLockPasswordLogic extends BaseGetXController{
|
|||||||
signKey: signKeyDataList,
|
signKey: signKeyDataList,
|
||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
token: getTokenList);
|
token: getTokenList);
|
||||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
|
|||||||
@ -9,34 +9,6 @@ import 'basicInformation_state.dart';
|
|||||||
class BasicInformationLogic extends BaseGetXController{
|
class BasicInformationLogic extends BaseGetXController{
|
||||||
final BasicInformationState state = BasicInformationState();
|
final BasicInformationState state = BasicInformationState();
|
||||||
|
|
||||||
// 读取支持功能-带参数
|
|
||||||
// Future<void> _readAdminPassword() async {
|
|
||||||
// BlueManage().bludSendData(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
|
||||||
// if (connectionState == DeviceConnectionState.connected) {
|
|
||||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
|
||||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
|
||||||
//
|
|
||||||
// var token = await Storage.getStringList(saveBlueToken);
|
|
||||||
// List<int> getTokenList = changeStringListToIntList(token!);
|
|
||||||
//
|
|
||||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
|
||||||
// List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
|
||||||
//
|
|
||||||
// IoSenderManage.senderReadAdminPasswordCommand(
|
|
||||||
// keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
|
||||||
// userID: await Storage.getUid(),
|
|
||||||
// role:0xff,
|
|
||||||
// pwdNum:5,
|
|
||||||
// pwdNo: 0,
|
|
||||||
// token: getTokenList,
|
|
||||||
// needAuthor: 1,
|
|
||||||
// publicKey: getPublicKeyList,
|
|
||||||
// privateKey: getPrivateKeyList
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// }, isShowLoading: true);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 下级界面修改成功后传递数据
|
// 下级界面修改成功后传递数据
|
||||||
StreamSubscription? _passCurrentLockInformationEvent;
|
StreamSubscription? _passCurrentLockInformationEvent;
|
||||||
void initLoadDataAction(BlockSetStateCallback blockSetStateCallback) {
|
void initLoadDataAction(BlockSetStateCallback blockSetStateCallback) {
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart';
|
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart';
|
||||||
|
|
||||||
import '../../../../../blue/blue_manage.dart';
|
import '../../../../../blue/blue_manage.dart';
|
||||||
@ -47,8 +48,8 @@ class UploadElectricQuantityLogic extends BaseGetXController {
|
|||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||||
(DeviceConnectionState deviceConnectionState) async {
|
(BluetoothConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.connected) {
|
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
@ -57,7 +58,7 @@ class UploadElectricQuantityLogic extends BaseGetXController {
|
|||||||
userID: await Storage.getUid(),
|
userID: await Storage.getUid(),
|
||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
);
|
);
|
||||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_setSupportFunctionsNoParameters.dart';
|
import 'package:star_lock/blue/io_protocol/io_setSupportFunctionsNoParameters.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
@ -114,32 +115,6 @@ class BurglarAlarmLogic extends BaseGetXController{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 读取支持功能-带参数
|
|
||||||
// Future<void> _readSupportFunctionsNoParameters() async {
|
|
||||||
// BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
|
||||||
// if (connectionState == DeviceConnectionState.connected) {
|
|
||||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
|
||||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
|
||||||
//
|
|
||||||
// var token = await Storage.getStringList(saveBlueToken);
|
|
||||||
// List<int> getTokenList = changeStringListToIntList(token!);
|
|
||||||
//
|
|
||||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
|
||||||
// List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
|
||||||
//
|
|
||||||
// IoSenderManage.readSupportFunctionsNoParametersCommand(
|
|
||||||
// keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
|
||||||
// userID: await Storage.getUid(),
|
|
||||||
// featureBit: 30,
|
|
||||||
// token: getTokenList,
|
|
||||||
// needAuthor: 1,
|
|
||||||
// publicKey: getPublicKeyList,
|
|
||||||
// privateKey: getPrivateKeyList
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 设置支持功能(带参数)
|
// 设置支持功能(带参数)
|
||||||
Future<void> sendBurglarAlarm() async {
|
Future<void> sendBurglarAlarm() async {
|
||||||
if(state.sureBtnState.value == 1){
|
if(state.sureBtnState.value == 1){
|
||||||
@ -152,8 +127,8 @@ class BurglarAlarmLogic extends BaseGetXController{
|
|||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -172,7 +147,7 @@ class BurglarAlarmLogic extends BaseGetXController{
|
|||||||
needAuthor: 1,
|
needAuthor: 1,
|
||||||
publicKey: getPublicKeyList,
|
publicKey: getPublicKeyList,
|
||||||
privateKey: getPrivateKeyList);
|
privateKey: getPrivateKeyList);
|
||||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
@ -183,31 +158,31 @@ class BurglarAlarmLogic extends BaseGetXController{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer? _timer;
|
// Timer? _timer;
|
||||||
// CancelableOperation? _operation;
|
// // CancelableOperation? _operation;
|
||||||
void showBlueConnetctToastTimer({bool isShowBlueConnetctToast = true, Function? action}) {
|
// void showBlueConnetctToastTimer({bool isShowBlueConnetctToast = true, Function? action}) {
|
||||||
if (_timer != null && _timer!.isActive) {
|
// if (_timer != null && _timer!.isActive) {
|
||||||
_timer!.cancel();
|
// _timer!.cancel();
|
||||||
_timer = null;
|
// _timer = null;
|
||||||
}
|
// }
|
||||||
_timer = Timer.periodic(15.seconds, (timer) {
|
// _timer = Timer.periodic(15.seconds, (timer) {
|
||||||
if (action != null) {
|
// if (action != null) {
|
||||||
action();
|
// action();
|
||||||
}
|
// }
|
||||||
cancelBlueConnetctToastTimer();
|
// cancelBlueConnetctToastTimer();
|
||||||
if (isShowBlueConnetctToast == true) {
|
// if (isShowBlueConnetctToast == true) {
|
||||||
showBlueConnetctToast();
|
// showBlueConnetctToast();
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
void cancelBlueConnetctToastTimer() {
|
// void cancelBlueConnetctToastTimer() {
|
||||||
Get.log('cancelBlueConnetctToastTimer');
|
// Get.log('cancelBlueConnetctToastTimer');
|
||||||
if (_timer != null && _timer!.isActive) {
|
// if (_timer != null && _timer!.isActive) {
|
||||||
_timer!.cancel();
|
// _timer!.cancel();
|
||||||
_timer = null;
|
// _timer = null;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onReady() {
|
void onReady() {
|
||||||
|
|||||||
@ -2,7 +2,8 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:network_info_plus/network_info_plus.dart';
|
import 'package:network_info_plus/network_info_plus.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
@ -150,8 +151,8 @@ class ConfiguringWifiLogic extends BaseGetXController{
|
|||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -204,7 +205,7 @@ class ConfiguringWifiLogic extends BaseGetXController{
|
|||||||
publicKey: publicKeyDataList,
|
publicKey: publicKeyDataList,
|
||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
);
|
);
|
||||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_getWifiList.dart';
|
import 'package:star_lock/blue/io_protocol/io_getWifiList.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
@ -97,8 +98,8 @@ class WifiListLogic extends BaseGetXController {
|
|||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.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!);
|
||||||
print("openDoorTokenPubToken:$getTokenList");
|
print("openDoorTokenPubToken:$getTokenList");
|
||||||
@ -117,7 +118,7 @@ class WifiListLogic extends BaseGetXController {
|
|||||||
publicKey: publicKeyDataList,
|
publicKey: publicKeyDataList,
|
||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
);
|
);
|
||||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
|
|||||||
@ -3,7 +3,9 @@ import 'dart:async';
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_deletUser.dart';
|
import 'package:star_lock/blue/io_protocol/io_deletUser.dart';
|
||||||
@ -317,8 +319,8 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
print("333333");
|
print("333333");
|
||||||
showDeletAlertTipDialog();
|
showDeletAlertTipDialog();
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -336,7 +338,7 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
publicKey: publicKeyDataList,
|
publicKey: publicKeyDataList,
|
||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
token: getTokenList);
|
token: getTokenList);
|
||||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
print("444444");
|
print("444444");
|
||||||
@ -379,8 +381,8 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
showBlueConnetctToastTimer(action: (){
|
showBlueConnetctToastTimer(action: (){
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -415,7 +417,7 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
needAuthor: 1,
|
needAuthor: 1,
|
||||||
publicKey: getPublicKeyList,
|
publicKey: getPublicKeyList,
|
||||||
privateKey: getPrivateKeyList);
|
privateKey: getPrivateKeyList);
|
||||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
if(state.ifCurrentScreen.value == true){
|
if(state.ifCurrentScreen.value == true){
|
||||||
@ -522,16 +524,16 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
late StreamSubscription<List<DiscoveredDevice>>_scanListDiscoveredDeviceSubscription;
|
// late StreamSubscription<List<DiscoveredDevice>>_scanListDiscoveredDeviceSubscription;
|
||||||
void _scanListDiscoveredDeviceSubscriptionAction() {
|
// void _scanListDiscoveredDeviceSubscriptionAction() {
|
||||||
_scanListDiscoveredDeviceSubscription = EventBusManager().eventBus!.on<List<DiscoveredDevice>>().listen((List<DiscoveredDevice> list) {
|
// _scanListDiscoveredDeviceSubscription = EventBusManager().eventBus!.on<List<DiscoveredDevice>>().listen((List<DiscoveredDevice> list) {
|
||||||
final knownDeviceIndex = list.indexWhere((d) => d.name == BlueManage().connectDeviceName);
|
// final knownDeviceIndex = list.indexWhere((d) => d.name == BlueManage().connectDeviceName);
|
||||||
if (knownDeviceIndex >= 0) {
|
// if (knownDeviceIndex >= 0) {
|
||||||
// 存在的时候赋值
|
// // 存在的时候赋值
|
||||||
state.currentDeviceUUid.value = (list[knownDeviceIndex].serviceUuids.isNotEmpty ? list[knownDeviceIndex].serviceUuids[0] : "").toString();
|
// state.currentDeviceUUid.value = (list[knownDeviceIndex].serviceUuids.isNotEmpty ? list[knownDeviceIndex].serviceUuids[0] : "").toString();
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
void showDeletAlertTipDialog({String? showContent = ""}) {
|
void showDeletAlertTipDialog({String? showContent = ""}) {
|
||||||
// bool isContains = BlueManage().connectDeviceName!.contains("T9A");
|
// bool isContains = BlueManage().connectDeviceName!.contains("T9A");
|
||||||
@ -643,7 +645,14 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
|
|
||||||
void showDeletPasswordAlertDialog(BuildContext context) {
|
void showDeletPasswordAlertDialog(BuildContext context) {
|
||||||
// 点击删除 开始扫描
|
// 点击删除 开始扫描
|
||||||
BlueManage().startScan();
|
// BlueManage().startScan(20, (List<ScanResult> list) async {
|
||||||
|
// final knownDeviceIndex = list.indexWhere((d) => d.advertisementData.advName == BlueManage().connectDeviceName);
|
||||||
|
// if (knownDeviceIndex >= 0) {
|
||||||
|
// // 存在的时候赋值
|
||||||
|
// state.currentDeviceUUid.value = (list[knownDeviceIndex].advertisementData.serviceUuids.isNotEmpty ? list[knownDeviceIndex].advertisementData.serviceUuids[0] : "").toString();
|
||||||
|
// await BlueManage().stopScan();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
@ -661,7 +670,7 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
},
|
},
|
||||||
cancelClick: () {
|
cancelClick: () {
|
||||||
// 取消的时候停止扫描
|
// 取消的时候停止扫描
|
||||||
BlueManage().stopScan();
|
// BlueManage().stopScan();
|
||||||
Get.back();
|
Get.back();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -724,7 +733,9 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
Get.back();
|
Get.back();
|
||||||
|
|
||||||
if(BlueManage().deviceConnectionState == DeviceConnectionState.connected){
|
factoryDataResetAction();
|
||||||
|
|
||||||
|
// if(BlueManage().bluetoothConnectionState == BluetoothConnectionState.connected){
|
||||||
// 如果是已连接状态 直接调用协议
|
// 如果是已连接状态 直接调用协议
|
||||||
// 已配对 表示这把锁未被初始化,还处于被添加状态
|
// 已配对 表示这把锁未被初始化,还处于被添加状态
|
||||||
// if (state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1) {
|
// if (state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1) {
|
||||||
@ -740,86 +751,86 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
// deletKeyData();
|
// deletKeyData();
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
// print("state.currentDeviceUUid.value:${state.currentDeviceUUid.value}");
|
||||||
if (state.currentDeviceUUid.value.isNotEmpty) {
|
// if (state.currentDeviceUUid.value.isNotEmpty) {
|
||||||
// 已经扫描到了当前设备 停止扫描,直接删除锁
|
// // 已经扫描到了当前设备 停止扫描,直接删除锁
|
||||||
BlueManage().stopScan();
|
// // BlueManage().stopScan();
|
||||||
deletLockLogic();
|
// deletLockLogic();
|
||||||
} else {
|
// } else {
|
||||||
// 未扫描到 然后循环5秒扫秒
|
// // 未扫描到 然后循环5秒扫秒
|
||||||
var index = 0;
|
// var index = 0;
|
||||||
showEasyLoading();
|
// showEasyLoading();
|
||||||
state.deletWaitScanCompleter = Completer();
|
// state.deletWaitScanCompleter = Completer();
|
||||||
state.deletWaitScanTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
// state.deletWaitScanTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||||
//定时任务
|
// //定时任务
|
||||||
if(index >= 7){
|
// if(index >= 7){
|
||||||
// 当超过10秒的时候还是没有搜索到,完成任务,关闭扫描,取消定时器,弹窗提示
|
// // 当超过10秒的时候还是没有搜索到,完成任务,关闭扫描,取消定时器,弹窗提示
|
||||||
if (state.deletWaitScanTimer != null && state.deletWaitScanTimer!.isActive) {
|
// if (state.deletWaitScanTimer != null && state.deletWaitScanTimer!.isActive) {
|
||||||
state.deletWaitScanTimer!.cancel();
|
// state.deletWaitScanTimer!.cancel();
|
||||||
state.deletWaitScanTimer = null;
|
// state.deletWaitScanTimer = null;
|
||||||
}
|
// }
|
||||||
if(state.deletWaitScanCompleter != null){
|
// if(state.deletWaitScanCompleter != null){
|
||||||
state.deletWaitScanCompleter!.complete();
|
// state.deletWaitScanCompleter!.complete();
|
||||||
}
|
// }
|
||||||
BlueManage().stopScan();
|
// // BlueManage().stopScan();
|
||||||
dismissEasyLoading();
|
// dismissEasyLoading();
|
||||||
print("555555");
|
// print("555555");
|
||||||
showDeletAlertTipDialog();
|
// showDeletAlertTipDialog();
|
||||||
}else{
|
// }else{
|
||||||
// 每秒判断获取是否搜到了当前设备
|
// // 每秒判断获取是否搜到了当前设备
|
||||||
if (state.currentDeviceUUid.isNotEmpty) {
|
// if (state.currentDeviceUUid.isNotEmpty) {
|
||||||
BlueManage().stopScan();
|
// // BlueManage().stopScan();
|
||||||
// 存在的时候销毁定时器,赋值
|
// // 存在的时候销毁定时器,赋值
|
||||||
if (state.deletWaitScanTimer != null && state.deletWaitScanTimer!.isActive) {
|
// if (state.deletWaitScanTimer != null && state.deletWaitScanTimer!.isActive) {
|
||||||
state.deletWaitScanTimer!.cancel();
|
// state.deletWaitScanTimer!.cancel();
|
||||||
state.deletWaitScanTimer = null;
|
// state.deletWaitScanTimer = null;
|
||||||
}
|
// }
|
||||||
if(state.deletWaitScanCompleter != null){
|
// if(state.deletWaitScanCompleter != null){
|
||||||
state.deletWaitScanCompleter!.complete();
|
// state.deletWaitScanCompleter!.complete();
|
||||||
}
|
// }
|
||||||
dismissEasyLoading();
|
// dismissEasyLoading();
|
||||||
|
//
|
||||||
deletLockLogic();
|
// deletLockLogic();
|
||||||
} else {
|
// } else {
|
||||||
// 不存在的时候返回-1 然后循环5秒
|
// // 不存在的时候返回-1 然后循环5秒
|
||||||
index++;
|
// index++;
|
||||||
// print("index:$index");
|
// // print("index:$index");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
// 等待Completer完成
|
// // 等待Completer完成
|
||||||
await state.deletWaitScanCompleter!.future;
|
// await state.deletWaitScanCompleter!.future;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 已经扫描到了当前设备 停止扫描,直接调用删除锁逻辑
|
// 已经扫描到了当前设备 停止扫描,直接调用删除锁逻辑
|
||||||
void deletLockLogic() {
|
// void deletLockLogic() {
|
||||||
// 当扫描的数组里面是否有当前设备
|
// // 当扫描的数组里面是否有当前设备
|
||||||
if(state.currentDeviceUUid.value[31] == "1"){
|
// if(state.currentDeviceUUid.value[31] == "1"){
|
||||||
// 已配对 表示这把锁未被初始化,还处于被添加状态
|
// // 已配对 表示这把锁未被初始化,还处于被添加状态
|
||||||
// if (state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1) {
|
// // if (state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1) {
|
||||||
// 如果是锁拥有者直接删除锁,调用初始化协议
|
// // 如果是锁拥有者直接删除锁,调用初始化协议
|
||||||
factoryDataResetAction();
|
// factoryDataResetAction();
|
||||||
// } else {
|
// // } else {
|
||||||
// // 不是锁拥有者
|
// // // 不是锁拥有者
|
||||||
// if(state.lockSetInfoData.value.lockBasicInfo!.lockUserNo != 0){
|
// // if(state.lockSetInfoData.value.lockBasicInfo!.lockUserNo != 0){
|
||||||
// // 如果已经创建了用户调用协议删除
|
// // // 如果已经创建了用户调用协议删除
|
||||||
// deletUserAction();
|
// // deletUserAction();
|
||||||
// }else{
|
// // }else{
|
||||||
// // 如果没有创建用户 调用接口删除
|
// // // 如果没有创建用户 调用接口删除
|
||||||
// deletKeyData();
|
// // deletKeyData();
|
||||||
// }
|
// // }
|
||||||
// }
|
// // }
|
||||||
}else if(state.currentDeviceUUid.value[31] == "0"){
|
// }else if(state.currentDeviceUUid.value[31] == "0"){
|
||||||
// 未配对 表示这把锁已被强制初始化 处于可添加状态 直接弹窗删除即可
|
// // 未配对 表示这把锁已被强制初始化 处于可添加状态 直接弹窗删除即可
|
||||||
print("666666");
|
// print("666666");
|
||||||
// showDeletAlertTipDialog(showContent:"当前锁已被强制初始化,可直接添加。");
|
// // showDeletAlertTipDialog(showContent:"当前锁已被强制初始化,可直接添加。");
|
||||||
deletLockInfoData();
|
// deletLockInfoData();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 当是锁拥有者的时候,删除锁
|
// 当是锁拥有者的时候,删除锁
|
||||||
void deletLockInfoData() async {
|
void deletLockInfoData() async {
|
||||||
@ -837,7 +848,7 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
Future.delayed(const Duration(milliseconds: 200)).then((e) {
|
Future.delayed(const Duration(milliseconds: 200)).then((e) {
|
||||||
Get.close(2);
|
Get.back();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -874,7 +885,7 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
super.onReady();
|
super.onReady();
|
||||||
|
|
||||||
_initReplySubscription();
|
_initReplySubscription();
|
||||||
_scanListDiscoveredDeviceSubscriptionAction();
|
// _scanListDiscoveredDeviceSubscriptionAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -889,6 +900,6 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
|
|
||||||
_replySubscription.cancel();
|
_replySubscription.cancel();
|
||||||
_passCurrentLockInformationEvent!.cancel();
|
_passCurrentLockInformationEvent!.cancel();
|
||||||
_scanListDiscoveredDeviceSubscription.cancel();
|
// _scanListDiscoveredDeviceSubscription.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -778,7 +778,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
|||||||
!state.deletWaitScanCompleter!.isCompleted) {
|
!state.deletWaitScanCompleter!.isCompleted) {
|
||||||
state.deletWaitScanCompleter!.complete();
|
state.deletWaitScanCompleter!.complete();
|
||||||
}
|
}
|
||||||
BlueManage().stopScan();
|
// BlueManage().stopScan();
|
||||||
state.ifCurrentScreen.value = false;
|
state.ifCurrentScreen.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -805,7 +805,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
|||||||
!state.deletWaitScanCompleter!.isCompleted) {
|
!state.deletWaitScanCompleter!.isCompleted) {
|
||||||
state.deletWaitScanCompleter!.complete();
|
state.deletWaitScanCompleter!.complete();
|
||||||
}
|
}
|
||||||
BlueManage().stopScan();
|
// BlueManage().stopScan();
|
||||||
state.ifCurrentScreen.value = false;
|
state.ifCurrentScreen.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,7 @@ class LockSetState {
|
|||||||
|
|
||||||
var isOnlyOneData = false.obs;
|
var isOnlyOneData = false.obs;
|
||||||
var isAttendance = 0.obs;// 是否开启考勤
|
var isAttendance = 0.obs;// 是否开启考勤
|
||||||
var currentDeviceUUid = "".obs;// 当前设备的uuid
|
// var currentDeviceUUid = "".obs;// 当前设备的uuid
|
||||||
var isOpenLockNeedOnline = 0.obs;// APP开锁时是否需联网
|
var isOpenLockNeedOnline = 0.obs;// APP开锁时是否需联网
|
||||||
|
|
||||||
var isLockPickingReminder = 0.obs;// 是否开启开锁提醒
|
var isLockPickingReminder = 0.obs;// 是否开启开锁提醒
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
|
|
||||||
import '../../../../blue/blue_manage.dart';
|
import '../../../../blue/blue_manage.dart';
|
||||||
@ -120,32 +121,6 @@ class LockSoundSetLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 读取支持功能-带参数
|
|
||||||
// Future<void> _readSupportFunctionsWithParameters() async {
|
|
||||||
// BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
|
||||||
// if (connectionState == DeviceConnectionState.connected) {
|
|
||||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
|
||||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
|
||||||
//
|
|
||||||
// var token = await Storage.getStringList(saveBlueToken);
|
|
||||||
// List<int> getTokenList = changeStringListToIntList(token!);
|
|
||||||
//
|
|
||||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
|
||||||
// List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
|
||||||
//
|
|
||||||
// IoSenderManage.readSupportFunctionsWithParametersCommand(
|
|
||||||
// keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
|
||||||
// userID: await Storage.getUid(),
|
|
||||||
// featureBit: 33,
|
|
||||||
// token: getTokenList,
|
|
||||||
// needAuthor: 1,
|
|
||||||
// publicKey: getPublicKeyList,
|
|
||||||
// privateKey: getPrivateKeyList
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 设置支持功能(带参数)
|
// 设置支持功能(带参数)
|
||||||
Future<void> sendLockSound() async {
|
Future<void> sendLockSound() async {
|
||||||
if(state.sureBtnState.value == 1){
|
if(state.sureBtnState.value == 1){
|
||||||
@ -158,8 +133,8 @@ class LockSoundSetLogic extends BaseGetXController {
|
|||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -187,7 +162,7 @@ class LockSoundSetLogic extends BaseGetXController {
|
|||||||
needAuthor: 1,
|
needAuthor: 1,
|
||||||
publicKey: getPublicKeyList,
|
publicKey: getPublicKeyList,
|
||||||
privateKey: getPrivateKeyList);
|
privateKey: getPrivateKeyList);
|
||||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
|
|
||||||
import '../../../../blue/blue_manage.dart';
|
import '../../../../blue/blue_manage.dart';
|
||||||
import '../../../../blue/io_protocol/io_timing.dart';
|
import '../../../../blue/io_protocol/io_timing.dart';
|
||||||
@ -126,22 +127,6 @@ class LockTimeLogic extends BaseGetXController{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取锁状态
|
|
||||||
// Future<void> _getLockStatus() async {
|
|
||||||
// // 进来之后首先连接
|
|
||||||
// BlueManage().bludSendData(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
|
||||||
// if (state == DeviceConnectionState.connected) {
|
|
||||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
|
||||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
|
||||||
// IoSenderManage.senderGetLockStatu(
|
|
||||||
// lockID:BlueManage().connectDeviceName,
|
|
||||||
// userID:await Storage.getUid(),
|
|
||||||
// privateKey:getPrivateKeyList,
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// }, isShowLoading: false);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 校验时间
|
// 校验时间
|
||||||
Future<void> sendTiming() async {
|
Future<void> sendTiming() async {
|
||||||
if(state.sureBtnState.value == 1){
|
if(state.sureBtnState.value == 1){
|
||||||
@ -154,8 +139,8 @@ class LockTimeLogic extends BaseGetXController{
|
|||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -174,7 +159,7 @@ class LockTimeLogic extends BaseGetXController{
|
|||||||
signKey:getSignKeyList,
|
signKey:getSignKeyList,
|
||||||
privateKey:getPrivateKeyList,
|
privateKey:getPrivateKeyList,
|
||||||
);
|
);
|
||||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
|
|
||||||
import '../../../../blue/blue_manage.dart';
|
import '../../../../blue/blue_manage.dart';
|
||||||
import '../../../../blue/io_protocol/io_setSupportFunctionsNoParameters.dart';
|
import '../../../../blue/io_protocol/io_setSupportFunctionsNoParameters.dart';
|
||||||
@ -109,8 +111,8 @@ class MotorPowerLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 读取支持功能-带参数
|
// 读取支持功能-带参数
|
||||||
Future<void> _readSupportFunctionsNoParameters() async {
|
Future<void> _readSupportFunctionsNoParameters() async {
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -135,8 +137,8 @@ class MotorPowerLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 设置支持功能(带参数)
|
// 设置支持功能(带参数)
|
||||||
Future<void> sendOpenDoorDirection() async {
|
Future<void> sendOpenDoorDirection() async {
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
|
|
||||||
import '../../../../blue/blue_manage.dart';
|
import '../../../../blue/blue_manage.dart';
|
||||||
@ -139,32 +139,6 @@ class NormallyOpenModeLogic extends BaseGetXController{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 读取支持功能-带参数
|
|
||||||
// Future<void> _readSupportFunctionsWithParameters() async {
|
|
||||||
// BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
|
||||||
// if (connectionState == DeviceConnectionState.connected) {
|
|
||||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
|
||||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
|
||||||
//
|
|
||||||
// var token = await Storage.getStringList(saveBlueToken);
|
|
||||||
// List<int> getTokenList = changeStringListToIntList(token!);
|
|
||||||
//
|
|
||||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
|
||||||
// List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
|
||||||
//
|
|
||||||
// IoSenderManage.readSupportFunctionsWithParametersCommand(
|
|
||||||
// keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
|
||||||
// userID: await Storage.getUid(),
|
|
||||||
// featureBit: 50,
|
|
||||||
// token: getTokenList,
|
|
||||||
// needAuthor: 1,
|
|
||||||
// publicKey: getPublicKeyList,
|
|
||||||
// privateKey: getPrivateKeyList
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 设置支持功能(带参数)
|
// 设置支持功能(带参数)
|
||||||
Future<void> sendAutoLock() async {
|
Future<void> sendAutoLock() async {
|
||||||
if(state.sureBtnState.value == 1){
|
if(state.sureBtnState.value == 1){
|
||||||
@ -177,8 +151,8 @@ class NormallyOpenModeLogic extends BaseGetXController{
|
|||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -230,7 +204,7 @@ class NormallyOpenModeLogic extends BaseGetXController{
|
|||||||
needAuthor: 1,
|
needAuthor: 1,
|
||||||
publicKey: getPublicKeyList,
|
publicKey: getPublicKeyList,
|
||||||
privateKey: getPrivateKeyList);
|
privateKey: getPrivateKeyList);
|
||||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
|
|
||||||
import '../../../../blue/blue_manage.dart';
|
import '../../../../blue/blue_manage.dart';
|
||||||
import '../../../../blue/io_protocol/io_setSupportFunctionsNoParameters.dart';
|
import '../../../../blue/io_protocol/io_setSupportFunctionsNoParameters.dart';
|
||||||
@ -109,38 +111,12 @@ class OpenDoorDirectionLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 读取支持功能-带参数
|
|
||||||
// Future<void> _readSupportFunctionsNoParameters() async {
|
|
||||||
// BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
|
||||||
// if (connectionState == DeviceConnectionState.connected) {
|
|
||||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
|
||||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
|
||||||
//
|
|
||||||
// var token = await Storage.getStringList(saveBlueToken);
|
|
||||||
// List<int> getTokenList = changeStringListToIntList(token!);
|
|
||||||
//
|
|
||||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
|
||||||
// List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
|
||||||
//
|
|
||||||
// IoSenderManage.readSupportFunctionsNoParametersCommand(
|
|
||||||
// keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
|
||||||
// userID: await Storage.getUid(),
|
|
||||||
// featureBit: 41,
|
|
||||||
// token: getTokenList,
|
|
||||||
// needAuthor: 1,
|
|
||||||
// publicKey: getPublicKeyList,
|
|
||||||
// privateKey: getPrivateKeyList
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 设置支持功能(带参数)
|
// 设置支持功能(带参数)
|
||||||
Future<void> sendOpenDoorDirection() async {
|
Future<void> sendOpenDoorDirection() async {
|
||||||
showEasyLoading();
|
showEasyLoading();
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
if (connectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -159,7 +135,7 @@ class OpenDoorDirectionLogic extends BaseGetXController {
|
|||||||
needAuthor: 1,
|
needAuthor: 1,
|
||||||
publicKey: getPublicKeyList,
|
publicKey: getPublicKeyList,
|
||||||
privateKey: getPrivateKeyList);
|
privateKey: getPrivateKeyList);
|
||||||
}else if (connectionState == DeviceConnectionState.disconnected) {
|
}else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
showBlueConnetctToast();
|
showBlueConnetctToast();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
|
|
||||||
import '../../../../blue/blue_manage.dart';
|
import '../../../../blue/blue_manage.dart';
|
||||||
@ -111,32 +112,6 @@ class RemoteUnlockingLogic extends BaseGetXController{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 读取支持功能-带参数
|
|
||||||
// Future<void> _readSupportFunctionsNoParameters() async {
|
|
||||||
// BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
|
||||||
// if (connectionState == DeviceConnectionState.connected) {
|
|
||||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
|
||||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
|
||||||
//
|
|
||||||
// var token = await Storage.getStringList(saveBlueToken);
|
|
||||||
// List<int> getTokenList = changeStringListToIntList(token!);
|
|
||||||
//
|
|
||||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
|
||||||
// List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
|
||||||
//
|
|
||||||
// IoSenderManage.readSupportFunctionsNoParametersCommand(
|
|
||||||
// keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
|
||||||
// userID: await Storage.getUid(),
|
|
||||||
// featureBit: 28,
|
|
||||||
// token: getTokenList,
|
|
||||||
// needAuthor: 1,
|
|
||||||
// publicKey: getPublicKeyList,
|
|
||||||
// privateKey: getPrivateKeyList
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 设置支持功能(带参数) 远程开锁
|
// 设置支持功能(带参数) 远程开锁
|
||||||
Future<void> sendBurglarAlarm() async {
|
Future<void> sendBurglarAlarm() async {
|
||||||
if(state.sureBtnState.value == 1){
|
if(state.sureBtnState.value == 1){
|
||||||
@ -149,8 +124,8 @@ class RemoteUnlockingLogic extends BaseGetXController{
|
|||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -169,7 +144,7 @@ class RemoteUnlockingLogic extends BaseGetXController{
|
|||||||
needAuthor: 1,
|
needAuthor: 1,
|
||||||
publicKey: getPublicKeyList,
|
publicKey: getPublicKeyList,
|
||||||
privateKey: getPrivateKeyList);
|
privateKey: getPrivateKeyList);
|
||||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:star_lock/main/lockDetail/lockSet/resetButton/resetButton_state.dart';
|
import 'package:star_lock/main/lockDetail/lockSet/resetButton/resetButton_state.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
|
|
||||||
@ -112,32 +113,6 @@ class ResetButtonLogic extends BaseGetXController{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 读取支持功能-带参数
|
|
||||||
// Future<void> _readSupportFunctionsNoParameters() async {
|
|
||||||
// BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
|
||||||
// if (connectionState == DeviceConnectionState.connected) {
|
|
||||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
|
||||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
|
||||||
//
|
|
||||||
// var token = await Storage.getStringList(saveBlueToken);
|
|
||||||
// List<int> getTokenList = changeStringListToIntList(token!);
|
|
||||||
//
|
|
||||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
|
||||||
// List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
|
||||||
//
|
|
||||||
// IoSenderManage.readSupportFunctionsNoParametersCommand(
|
|
||||||
// keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
|
||||||
// userID: await Storage.getUid(),
|
|
||||||
// featureBit: 31,
|
|
||||||
// token: getTokenList,
|
|
||||||
// needAuthor: 1,
|
|
||||||
// publicKey: getPublicKeyList,
|
|
||||||
// privateKey: getPrivateKeyList
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 设置支持功能(带参数)
|
// 设置支持功能(带参数)
|
||||||
Future<void> sendBurglarAlarm() async {
|
Future<void> sendBurglarAlarm() async {
|
||||||
if(state.sureBtnState.value == 1){
|
if(state.sureBtnState.value == 1){
|
||||||
@ -150,8 +125,8 @@ class ResetButtonLogic extends BaseGetXController{
|
|||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -170,7 +145,7 @@ class ResetButtonLogic extends BaseGetXController{
|
|||||||
needAuthor: 1,
|
needAuthor: 1,
|
||||||
publicKey: getPublicKeyList,
|
publicKey: getPublicKeyList,
|
||||||
privateKey: getPrivateKeyList);
|
privateKey: getPrivateKeyList);
|
||||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:star_lock/blue/io_type.dart';
|
import 'package:star_lock/blue/io_type.dart';
|
||||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart';
|
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart';
|
||||||
import 'package:star_lock/network/api_repository.dart';
|
import 'package:star_lock/network/api_repository.dart';
|
||||||
@ -246,8 +247,8 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
|
|||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -261,8 +262,8 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
|
|||||||
IoSenderManage.senderCustomPasswordsCommand(
|
IoSenderManage.senderCustomPasswordsCommand(
|
||||||
keyID: "1",
|
keyID: "1",
|
||||||
userID: await Storage.getUid(),
|
userID: await Storage.getUid(),
|
||||||
pwdNo: 1,
|
pwdNo: state.isAdministrator.value == true ? 254 : 1,
|
||||||
pwd:state.pwdController.text,
|
pwd: state.pwdController.text,
|
||||||
useCountLimit: 0xff,
|
useCountLimit: 0xff,
|
||||||
startTime: 0x11223344,
|
startTime: 0x11223344,
|
||||||
endTime: 0x11223344,
|
endTime: 0x11223344,
|
||||||
@ -270,7 +271,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
|
|||||||
signKey: signKeyDataList,
|
signKey: signKeyDataList,
|
||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
token: getTokenList);
|
token: getTokenList);
|
||||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
|
|||||||
@ -76,6 +76,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
|||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
perpetualKeyWidget(
|
perpetualKeyWidget(
|
||||||
|
false,
|
||||||
TranslationLoader.lanKeys!.name!.tr,
|
TranslationLoader.lanKeys!.name!.tr,
|
||||||
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
||||||
state.nameController),
|
state.nameController),
|
||||||
@ -90,6 +91,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
|||||||
children: [
|
children: [
|
||||||
keyTimeLimitWidget(),
|
keyTimeLimitWidget(),
|
||||||
perpetualKeyWidget(
|
perpetualKeyWidget(
|
||||||
|
false,
|
||||||
TranslationLoader.lanKeys!.name!.tr,
|
TranslationLoader.lanKeys!.name!.tr,
|
||||||
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
||||||
state.nameController),
|
state.nameController),
|
||||||
@ -103,6 +105,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
|||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
perpetualKeyWidget(
|
perpetualKeyWidget(
|
||||||
|
false,
|
||||||
TranslationLoader.lanKeys!.name!.tr,
|
TranslationLoader.lanKeys!.name!.tr,
|
||||||
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
||||||
state.nameController),
|
state.nameController),
|
||||||
@ -120,11 +123,16 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
|||||||
? keyTimeLimitWidget()
|
? keyTimeLimitWidget()
|
||||||
: Container(),
|
: Container(),
|
||||||
perpetualKeyWidget(
|
perpetualKeyWidget(
|
||||||
|
false,
|
||||||
TranslationLoader.lanKeys!.name!.tr,
|
TranslationLoader.lanKeys!.name!.tr,
|
||||||
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
||||||
state.nameController),
|
state.nameController),
|
||||||
perpetualKeyWidget(TranslationLoader.lanKeys!.password!.tr,
|
perpetualKeyWidget(
|
||||||
"请输入6-9位数字", state.pwdController),
|
false,
|
||||||
|
TranslationLoader.lanKeys!.password!.tr,
|
||||||
|
"请输入6-9位数字", state.pwdController
|
||||||
|
),
|
||||||
|
keyIfAdministratorWidget(),
|
||||||
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip4!.tr)
|
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip4!.tr)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -136,6 +144,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
|||||||
children: [
|
children: [
|
||||||
keyCirculationWidget(),
|
keyCirculationWidget(),
|
||||||
perpetualKeyWidget(
|
perpetualKeyWidget(
|
||||||
|
true,
|
||||||
TranslationLoader.lanKeys!.name!.tr,
|
TranslationLoader.lanKeys!.name!.tr,
|
||||||
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
||||||
state.nameController),
|
state.nameController),
|
||||||
@ -149,6 +158,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
|||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
perpetualKeyWidget(
|
perpetualKeyWidget(
|
||||||
|
false,
|
||||||
TranslationLoader.lanKeys!.name!.tr,
|
TranslationLoader.lanKeys!.name!.tr,
|
||||||
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
||||||
state.nameController),
|
state.nameController),
|
||||||
@ -164,10 +174,10 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
|||||||
|
|
||||||
// 密码命名输入框
|
// 密码命名输入框
|
||||||
Widget perpetualKeyWidget(
|
Widget perpetualKeyWidget(
|
||||||
String titleStr, String rightTitle, TextEditingController controller) {
|
bool isTopHeight, String titleStr, String rightTitle, TextEditingController controller) {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(height: 10.h),
|
isTopHeight ? SizedBox(height: 10.h) : Container(),
|
||||||
CommonItem(
|
CommonItem(
|
||||||
leftTitel: titleStr,
|
leftTitel: titleStr,
|
||||||
rightTitle: "",
|
rightTitle: "",
|
||||||
@ -243,8 +253,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
|||||||
leftTitel: TranslationLoader.lanKeys!.permanent!.tr,
|
leftTitel: TranslationLoader.lanKeys!.permanent!.tr,
|
||||||
rightTitle: "",
|
rightTitle: "",
|
||||||
isHaveRightWidget: true,
|
isHaveRightWidget: true,
|
||||||
rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch()),
|
rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch())),
|
||||||
action: () {}),
|
|
||||||
state.isPermanent.value == true
|
state.isPermanent.value == true
|
||||||
? Container(height: 10.h)
|
? Container(height: 10.h)
|
||||||
: Container(height: 1.h),
|
: Container(height: 1.h),
|
||||||
@ -252,6 +261,23 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 自定义是否永久
|
||||||
|
Widget keyIfAdministratorWidget() {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
// SizedBox(height: 10.h),
|
||||||
|
Obx(() => CommonItem(
|
||||||
|
leftTitel: "是否是管理员",
|
||||||
|
rightTitle: "",
|
||||||
|
isTipsImg: false,
|
||||||
|
isHaveRightWidget: true,
|
||||||
|
rightWidget: SizedBox(
|
||||||
|
width: 60.w, height: 50.h, child: _isAdministrator()))),
|
||||||
|
SizedBox(height: 10.h),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// 循环
|
// 循环
|
||||||
Widget keyCirculationWidget() {
|
Widget keyCirculationWidget() {
|
||||||
return Column(
|
return Column(
|
||||||
@ -591,6 +617,19 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 是否是管理员
|
||||||
|
CupertinoSwitch _isAdministrator() {
|
||||||
|
return CupertinoSwitch(
|
||||||
|
activeColor: CupertinoColors.activeBlue,
|
||||||
|
trackColor: CupertinoColors.systemGrey5,
|
||||||
|
thumbColor: CupertinoColors.white,
|
||||||
|
value: state.isAdministrator.value,
|
||||||
|
onChanged: (value) {
|
||||||
|
state.isAdministrator.value = value;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
String intToStr(int v) {
|
String intToStr(int v) {
|
||||||
return (v < 10) ? "0$v" : "$v";
|
return (v < 10) ? "0$v" : "$v";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ class PasswordKeyPerpetualState {
|
|||||||
final isPermanent = true.obs; //是否永久
|
final isPermanent = true.obs; //是否永久
|
||||||
var getPwdStr = ''.obs;
|
var getPwdStr = ''.obs;
|
||||||
var pwdNameStr = '';
|
var pwdNameStr = '';
|
||||||
|
final isAdministrator = false.obs;// 是否是管理员
|
||||||
|
|
||||||
final effectiveDateTime = DateTime.now().obs;
|
final effectiveDateTime = DateTime.now().obs;
|
||||||
final failureDateTime = DateTime.now().obs;
|
final failureDateTime = DateTime.now().obs;
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||||
|
|
||||||
|
import '../../../blue/blue_manage.dart';
|
||||||
import '../../../network/api_repository.dart';
|
import '../../../network/api_repository.dart';
|
||||||
import '../../../talk/udp/udp_help.dart';
|
import '../../../talk/udp/udp_help.dart';
|
||||||
import '../../../tools/baseGetXController.dart';
|
import '../../../tools/baseGetXController.dart';
|
||||||
@ -85,6 +86,8 @@ class LockMainLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 开启UDP
|
// 开启UDP
|
||||||
UdpHelp().openUDP();
|
UdpHelp().openUDP();
|
||||||
|
|
||||||
|
BlueManage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@ -386,7 +386,7 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage> with RouteA
|
|||||||
AppRouteObserver().routeObserver.unsubscribe(this);
|
AppRouteObserver().routeObserver.unsubscribe(this);
|
||||||
super.dispose();
|
super.dispose();
|
||||||
|
|
||||||
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
BlueManage().disconnect();
|
||||||
|
|
||||||
location.stopLocation();
|
location.stopLocation();
|
||||||
location.destroy();
|
location.destroy();
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_getPrivateKey.dart';
|
import 'package:star_lock/blue/io_protocol/io_getPrivateKey.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_getPublicKey.dart';
|
import 'package:star_lock/blue/io_protocol/io_getPublicKey.dart';
|
||||||
@ -22,10 +23,10 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
// 点击连接设备
|
// 点击连接设备
|
||||||
void connect(String deviceName){
|
void connect(String deviceName){
|
||||||
showEasyLoading();
|
showEasyLoading();
|
||||||
BlueManage().bludSendData(deviceName, (DeviceConnectionState state) async {
|
BlueManage().bludSendData(deviceName, (BluetoothConnectionState state) async {
|
||||||
if (state == DeviceConnectionState.connected) {
|
if (state == BluetoothConnectionState.connected) {
|
||||||
IoSenderManage.getPublicKey(lockId: deviceName);
|
IoSenderManage.getPublicKey(lockId: deviceName);
|
||||||
}else if (state == DeviceConnectionState.disconnected) {
|
}else if (state == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
// showBlueConnetctToast();
|
// showBlueConnetctToast();
|
||||||
}
|
}
|
||||||
@ -175,9 +176,9 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
// 厂商序列号
|
// 厂商序列号
|
||||||
var serialNum0 = reply.data.sublist(84, 100);
|
var serialNum0 = reply.data.sublist(84, 100);
|
||||||
var serialNum0Str = utf8String(serialNum0);
|
var serialNum0Str = utf8String(serialNum0);
|
||||||
// state.lockInfo["serialNum0"] = serialNum0Str;
|
state.lockInfo["serialNum0"] = serialNum0Str;
|
||||||
state.lockInfo["serialNum0"] = "${DateTime.now().millisecondsSinceEpoch ~/ 10}";
|
// state.lockInfo["serialNum0"] = "${DateTime.now().millisecondsSinceEpoch ~/ 10}";
|
||||||
// print("serialNum0Str:$serialNum0Str serialNum0Str:${serialNum0Str.length}");
|
print("serialNum0Str:$serialNum0Str serialNum0Str:${serialNum0Str.length}");
|
||||||
|
|
||||||
// 成品商序列号
|
// 成品商序列号
|
||||||
var serialNum1 = reply.data.sublist(100, 116);
|
var serialNum1 = reply.data.sublist(100, 116);
|
||||||
@ -239,6 +240,11 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
var featureValueLength = reply.data[173];
|
var featureValueLength = reply.data[173];
|
||||||
// 锁特征值说明(本机能支持的功能)
|
// 锁特征值说明(本机能支持的功能)
|
||||||
// 获取到锁给的字符数组
|
// 获取到锁给的字符数组
|
||||||
|
var featureNetxLength = index + featureValueLength + 1;
|
||||||
|
if(reply.data.length < featureNetxLength){
|
||||||
|
showToast("锁特征值数据获取失败,请重新点击获取");
|
||||||
|
return;
|
||||||
|
}
|
||||||
var featureValue = reply.data.sublist(index + 1, index + featureValueLength + 1);
|
var featureValue = reply.data.sublist(index + 1, index + featureValueLength + 1);
|
||||||
String featureValueStr = asciiString(featureValue);
|
String featureValueStr = asciiString(featureValue);
|
||||||
state.featureValue = featureValueStr;
|
state.featureValue = featureValueStr;
|
||||||
@ -249,6 +255,11 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
// 使能特征值字符串长度
|
// 使能特征值字符串长度
|
||||||
var featureEnValLength = reply.data[index];
|
var featureEnValLength = reply.data[index];
|
||||||
// 使能锁特征值说明(本机启用的功能)
|
// 使能锁特征值说明(本机启用的功能)
|
||||||
|
var featureEnNextLength = index + featureEnValLength + 1;
|
||||||
|
if(reply.data.length < featureEnNextLength){
|
||||||
|
showToast("锁使能特征值数据获取失败,请重新点击获取");
|
||||||
|
return;
|
||||||
|
}
|
||||||
var featureEnVal = reply.data.sublist(index + 1, index + featureEnValLength + 1);
|
var featureEnVal = reply.data.sublist(index + 1, index + featureEnValLength + 1);
|
||||||
String featureEnValStr = asciiString(featureEnVal);
|
String featureEnValStr = asciiString(featureEnVal);
|
||||||
state.featureSettingValue = featureEnValStr;
|
state.featureSettingValue = featureEnValStr;
|
||||||
@ -315,8 +326,8 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
Future<void> _getStarLockStatus() async {
|
Future<void> _getStarLockStatus() async {
|
||||||
// print("connectDeviceMacAddress:${BlueManage().connectDeviceMacAddress} connectDeviceName:${BlueManage().connectDeviceName}");
|
// print("connectDeviceMacAddress:${BlueManage().connectDeviceMacAddress} connectDeviceName:${BlueManage().connectDeviceName}");
|
||||||
// 进来之后首先连接
|
// 进来之后首先连接
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async {
|
||||||
if (state == DeviceConnectionState.connected) {
|
if (state == BluetoothConnectionState.connected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
@ -330,31 +341,39 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
userID: await Storage.getUid(),
|
userID: await Storage.getUid(),
|
||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
);
|
);
|
||||||
} else if (state == DeviceConnectionState.disconnected) {
|
} else if (state == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
}
|
}
|
||||||
}, isAddEquipment: true);
|
}, isAddEquipment: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
late StreamSubscription<List<DiscoveredDevice>>_scanListDiscoveredDeviceSubscription;
|
// late StreamSubscription<List<ScanResult>>_scanListDiscoveredDeviceSubscription;
|
||||||
void _scanListDiscoveredDeviceSubscriptionAction() {
|
// void _scanListDiscoveredDeviceSubscriptionAction() {
|
||||||
_scanListDiscoveredDeviceSubscription = EventBusManager().eventBus!.on<List<DiscoveredDevice>>().listen((List<DiscoveredDevice> list) {
|
// _scanListDiscoveredDeviceSubscription = EventBusManager().eventBus!.on<List<ScanResult>>().listen((List<ScanResult> list) {
|
||||||
|
// state.devices.clear();
|
||||||
|
// for (int i = 0; i < list.length; i++) {
|
||||||
|
// ScanResult device = list[i];
|
||||||
|
// if (((device.advertisementData.serviceUuids.isNotEmpty ? device.advertisementData.serviceUuids[0] : "").toString()[31] != "1")) {
|
||||||
|
// state.devices.add(list[i]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
void startScanBlueList(){
|
||||||
|
BlueManage().startScan(2000, (List<ScanResult> list){
|
||||||
state.devices.clear();
|
state.devices.clear();
|
||||||
for (int i = 0; i < list.length; i++) {
|
for (int i = 0; i < list.length; i++) {
|
||||||
DiscoveredDevice device = list[i];
|
ScanResult device = list[i];
|
||||||
if (((device.serviceUuids.isNotEmpty ? device.serviceUuids[0] : "").toString()[31] != "1")) {
|
if (((device.advertisementData.serviceUuids.isNotEmpty ? device.advertisementData.serviceUuids[0] : "").toString()[31] != "1")) {
|
||||||
state.devices.add(list[i]);
|
state.devices.add(list[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void startScanBlueList(){
|
|
||||||
BlueManage().startScan();
|
|
||||||
}
|
|
||||||
|
|
||||||
void stopScanBlueList(){
|
void stopScanBlueList(){
|
||||||
BlueManage().disconnect("state.selectLockName.value");
|
BlueManage().disconnect();
|
||||||
BlueManage().stopScan();
|
BlueManage().stopScan();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,9 +384,10 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
print("NearbyLockLogic onReady()");
|
print("NearbyLockLogic onReady()");
|
||||||
|
|
||||||
_initReplySubscription();
|
_initReplySubscription();
|
||||||
_scanListDiscoveredDeviceSubscriptionAction();
|
// _scanListDiscoveredDeviceSubscriptionAction();
|
||||||
|
|
||||||
state.ifCurrentScreen.value = true;
|
state.ifCurrentScreen.value = true;
|
||||||
|
|
||||||
startScanBlueList();
|
startScanBlueList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,6 +403,6 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
// TODO: implement onClose
|
// TODO: implement onClose
|
||||||
super.onClose();
|
super.onClose();
|
||||||
_replySubscription.cancel();
|
_replySubscription.cancel();
|
||||||
_scanListDiscoveredDeviceSubscription.cancel();
|
// _scanListDiscoveredDeviceSubscription.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,12 +4,14 @@ import 'dart:typed_data';
|
|||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import '../../../appRouters.dart';
|
import '../../../appRouters.dart';
|
||||||
import '../../../app_settings/app_colors.dart';
|
import '../../../app_settings/app_colors.dart';
|
||||||
|
import '../../../blue/blue_manage.dart';
|
||||||
import '../../../tools/appRouteObserver.dart';
|
import '../../../tools/appRouteObserver.dart';
|
||||||
import '../../../tools/titleAppBar.dart';
|
import '../../../tools/titleAppBar.dart';
|
||||||
import '../../../translations/trans_lib.dart';
|
import '../../../translations/trans_lib.dart';
|
||||||
@ -55,9 +57,9 @@ class _NearbyLockPageState extends State<NearbyLockPage> with RouteAware {
|
|||||||
return nearbyLockItem('images/icon_lockGroup_item.png', state.devices[index], () {
|
return nearbyLockItem('images/icon_lockGroup_item.png', state.devices[index], () {
|
||||||
// Navigator.pushNamed(context, Routers.lockAddressPage);
|
// Navigator.pushNamed(context, Routers.lockAddressPage);
|
||||||
// logic.getPublicKey(state.devices[index].serviceUuids[0].toString());
|
// logic.getPublicKey(state.devices[index].serviceUuids[0].toString());
|
||||||
state.selectLockName.value = state.devices[index].name;
|
state.selectLockName.value = state.devices[index].advertisementData.advName;
|
||||||
// print("connect-lockId:${state.devices[index].id} deviceName:${state.devices[index].name}");
|
// print("connect-lockId:${state.devices[index].id} deviceName:${state.devices[index].name}");
|
||||||
logic.connect(state.devices[index].name);
|
logic.connect(state.devices[index].advertisementData.advName);
|
||||||
// Get.toNamed(Routers.lockAddressGaoDePage);
|
// Get.toNamed(Routers.lockAddressGaoDePage);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -74,9 +76,9 @@ class _NearbyLockPageState extends State<NearbyLockPage> with RouteAware {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget nearbyLockItem(String lockTypeIcon, DiscoveredDevice discoveredDevice, Function() action ) {
|
Widget nearbyLockItem(String lockTypeIcon, ScanResult scanResult, Function() action ) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: ((discoveredDevice.serviceUuids.isNotEmpty ? discoveredDevice.serviceUuids[0] : "").toString()[33] == "1") ? action : null,
|
onTap: ((scanResult.advertisementData.serviceUuids.isNotEmpty ? scanResult.advertisementData.serviceUuids[0] : "").toString()[33] == "1") ? action : null,
|
||||||
child: Column(
|
child: Column(
|
||||||
// mainAxisAlignment: MainAxisAlignment.center,
|
// mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
@ -98,7 +100,7 @@ class _NearbyLockPageState extends State<NearbyLockPage> with RouteAware {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
// 第32、33两位00 表示休眠, 01表示唤醒
|
// 第32、33两位00 表示休眠, 01表示唤醒
|
||||||
Text(discoveredDevice.name, style: TextStyle(fontSize: 20.sp, color: ((discoveredDevice.serviceUuids.isNotEmpty ? discoveredDevice.serviceUuids[0] : "").toString()[33] == "1") ? AppColors.blackColor : Colors.grey)),
|
Text(scanResult.advertisementData.advName, style: TextStyle(fontSize: 20.sp, color: ((scanResult.advertisementData.serviceUuids.isNotEmpty ? scanResult.advertisementData.serviceUuids[0] : "").toString()[33] == "1") ? AppColors.blackColor : Colors.grey)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@ -163,6 +165,7 @@ class _NearbyLockPageState extends State<NearbyLockPage> with RouteAware {
|
|||||||
state.ifCurrentScreen.value = false;
|
state.ifCurrentScreen.value = false;
|
||||||
logic.cancelBlueConnetctToastTimer();
|
logic.cancelBlueConnetctToastTimer();
|
||||||
logic.stopScanBlueList();
|
logic.stopScanBlueList();
|
||||||
|
BlueManage().disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 从下级返回 当前界面即将出现
|
/// 从下级返回 当前界面即将出现
|
||||||
@ -184,6 +187,7 @@ class _NearbyLockPageState extends State<NearbyLockPage> with RouteAware {
|
|||||||
state.ifCurrentScreen.value = false;
|
state.ifCurrentScreen.value = false;
|
||||||
logic.cancelBlueConnetctToastTimer();
|
logic.cancelBlueConnetctToastTimer();
|
||||||
logic.stopScanBlueList();
|
logic.stopScanBlueList();
|
||||||
|
BlueManage().disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
|
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
class NearbyLockState {
|
class NearbyLockState {
|
||||||
|
|
||||||
RxList<DiscoveredDevice> devices = <DiscoveredDevice>[].obs;
|
RxList<ScanResult> devices = <ScanResult>[].obs;
|
||||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||||
var selectLockName = "".obs;
|
var selectLockName = "".obs;
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,8 @@ import 'dart:math';
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
|
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_changeAdministratorPassword.dart';
|
import 'package:star_lock/blue/io_protocol/io_changeAdministratorPassword.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_senderCustomPasswords.dart';
|
import 'package:star_lock/blue/io_protocol/io_senderCustomPasswords.dart';
|
||||||
@ -234,9 +235,9 @@ class SaveLockLogic extends BaseGetXController {
|
|||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
state.saveBtnIsUsable.value = true;
|
state.saveBtnIsUsable.value = true;
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||||
// print("222222");
|
// print("222222");
|
||||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||||
// print("333333");
|
// print("333333");
|
||||||
// 私钥
|
// 私钥
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
@ -267,7 +268,7 @@ class SaveLockLogic extends BaseGetXController {
|
|||||||
privateKey:getPrivateKeyList,
|
privateKey:getPrivateKeyList,
|
||||||
token: getTokenList
|
token: getTokenList
|
||||||
);
|
);
|
||||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||||
print("444444");
|
print("444444");
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
@ -285,8 +286,8 @@ class SaveLockLogic extends BaseGetXController {
|
|||||||
var number = rng.nextInt(900000) + 100000; // 生成 100000 到 999999 之间的随机整数
|
var number = rng.nextInt(900000) + 100000; // 生成 100000 到 999999 之间的随机整数
|
||||||
state.adminPassword = number.toString();
|
state.adminPassword = number.toString();
|
||||||
state.adminPasswordTF.text = number.toString();
|
state.adminPasswordTF.text = number.toString();
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -319,8 +320,8 @@ class SaveLockLogic extends BaseGetXController {
|
|||||||
showBlueConnetctToastTimer(action: (){
|
showBlueConnetctToastTimer(action: (){
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
});
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.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!);
|
||||||
|
|
||||||
@ -343,7 +344,7 @@ class SaveLockLogic extends BaseGetXController {
|
|||||||
signKey: signKeyDataList,
|
signKey: signKeyDataList,
|
||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
token: getTokenList);
|
token: getTokenList);
|
||||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||||
print("444444");
|
print("444444");
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
@ -459,7 +460,7 @@ class SaveLockLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void backAction(){
|
void backAction(){
|
||||||
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
BlueManage().disconnect();
|
||||||
Get.close(state.isFromMap == 1 ? 6 : 7);
|
Get.close(state.isFromMap == 1 ? 6 : 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -54,7 +54,7 @@ class MineSetLogic extends BaseGetXController {
|
|||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
UdpHelp().closeUDP();
|
UdpHelp().closeUDP();
|
||||||
logOut();
|
logOut();
|
||||||
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
BlueManage().disconnect();
|
||||||
Get.offNamedUntil(Routers.starLockLoginPage, (route) => false);
|
Get.offNamedUntil(Routers.starLockLoginPage, (route) => false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import 'package:star_lock/login/login/starLock_login_page.dart';
|
|||||||
import 'package:star_lock/tools/appFirstEnterHandle.dart';
|
import 'package:star_lock/tools/appFirstEnterHandle.dart';
|
||||||
import 'package:star_lock/tools/storage.dart';
|
import 'package:star_lock/tools/storage.dart';
|
||||||
|
|
||||||
|
import '../blue/blue_manage.dart';
|
||||||
import '../main/lockMian/lockMain/lockMain_page.dart';
|
import '../main/lockMian/lockMain/lockMain_page.dart';
|
||||||
|
|
||||||
class StarLockApplication extends StatefulWidget {
|
class StarLockApplication extends StatefulWidget {
|
||||||
|
|||||||
@ -76,7 +76,8 @@ dependencies:
|
|||||||
#跳转到外部
|
#跳转到外部
|
||||||
url_launcher: ^6.1.10
|
url_launcher: ^6.1.10
|
||||||
#蓝牙
|
#蓝牙
|
||||||
flutter_reactive_ble: ^5.1.1
|
# flutter_reactive_ble: ^5.1.1
|
||||||
|
flutter_blue_plus: ^1.31.16
|
||||||
#
|
#
|
||||||
event_bus: ^2.0.0
|
event_bus: ^2.0.0
|
||||||
#菊花
|
#菊花
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user