优化蓝牙通信,蓝牙发送数据无反应
This commit is contained in:
parent
db5ab63e55
commit
2076278df5
@ -16,13 +16,13 @@ class BlueManage {
|
|||||||
final List<DiscoveredDevice> scanDevices = [];
|
final List<DiscoveredDevice> scanDevices = [];
|
||||||
|
|
||||||
// 用来写入的服务id
|
// 用来写入的服务id
|
||||||
Uuid serviceIdConnect = Uuid.parse("fff0");
|
final Uuid _serviceIdConnect = Uuid.parse("fff0");
|
||||||
// 用来写入的服务id
|
// 用来写入的服务id
|
||||||
Uuid serviceIdWrite = Uuid.parse('0000FFF0-0000-1000-8000-00805F9B34FB');
|
final Uuid _serviceIdWrite = Uuid.parse('0000FFF0-0000-1000-8000-00805F9B34FB');
|
||||||
// 用来订阅的特征id
|
// 用来订阅的特征id
|
||||||
Uuid characteristicIdSubscription = Uuid.parse("fff1");
|
final Uuid _characteristicIdSubscription = Uuid.parse("fff1");
|
||||||
// 用来写入的特征id
|
// 用来写入的特征id
|
||||||
Uuid characteristicIdWrite = Uuid.parse("fff2");
|
final Uuid _characteristicIdWrite = Uuid.parse("fff2");
|
||||||
|
|
||||||
// 监听发送事件
|
// 监听发送事件
|
||||||
StreamSubscription<EventSendModel>? _sendStreamSubscription;
|
StreamSubscription<EventSendModel>? _sendStreamSubscription;
|
||||||
@ -36,8 +36,7 @@ class BlueManage {
|
|||||||
// 当前连接设备的mac地址
|
// 当前连接设备的mac地址
|
||||||
String connectDeviceMacAddress = "";
|
String connectDeviceMacAddress = "";
|
||||||
// 监听蓝牙连接状态
|
// 监听蓝牙连接状态
|
||||||
DeviceConnectionState? deviceConnectionState =
|
DeviceConnectionState? deviceConnectionState = DeviceConnectionState.disconnected;
|
||||||
DeviceConnectionState.disconnected;
|
|
||||||
|
|
||||||
static BlueManage? _manager;
|
static BlueManage? _manager;
|
||||||
BlueManage._init();
|
BlueManage._init();
|
||||||
@ -92,7 +91,7 @@ class BlueManage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 调用连接
|
/// 调用连接
|
||||||
Future<void> judgeReconnect(String deviceName, ConnectStateCallBack stateCallBack) async {
|
Future<void> bludSendData(String deviceName, ConnectStateCallBack stateCallBack) async {
|
||||||
if(deviceConnectionState != DeviceConnectionState.connected){
|
if(deviceConnectionState != DeviceConnectionState.connected){
|
||||||
_connect(deviceName, (state){
|
_connect(deviceName, (state){
|
||||||
stateCallBack(deviceConnectionState!);
|
stateCallBack(deviceConnectionState!);
|
||||||
@ -117,7 +116,7 @@ class BlueManage {
|
|||||||
Timer.periodic(const Duration(milliseconds: 1000), (timer) {
|
Timer.periodic(const Duration(milliseconds: 1000), (timer) {
|
||||||
///定时任务
|
///定时任务
|
||||||
// print("timer index0:$index");
|
// print("timer index0:$index");
|
||||||
if(index >= 5){
|
if(index >= 4){
|
||||||
// 当超过5秒的时候取消定时任务 弹窗显示连接失败
|
// 当超过5秒的时候取消定时任务 弹窗显示连接失败
|
||||||
completer.complete();
|
completer.complete();
|
||||||
timer.cancel();
|
timer.cancel();
|
||||||
@ -127,8 +126,7 @@ class BlueManage {
|
|||||||
connectStateCallBack(DeviceConnectionState.disconnected);
|
connectStateCallBack(DeviceConnectionState.disconnected);
|
||||||
}else{
|
}else{
|
||||||
// 每秒判断数组列表里面是否有这个设备
|
// 每秒判断数组列表里面是否有这个设备
|
||||||
final knownDeviceIndex =
|
final knownDeviceIndex = scanDevices.indexWhere((d) => d.name == deviceName);
|
||||||
scanDevices.indexWhere((d) => d.name == deviceName);
|
|
||||||
if (knownDeviceIndex >= 0) {
|
if (knownDeviceIndex >= 0) {
|
||||||
// 存在的时候销毁定时器,赋值
|
// 存在的时候销毁定时器,赋值
|
||||||
completer.complete();
|
completer.complete();
|
||||||
@ -138,7 +136,7 @@ class BlueManage {
|
|||||||
} else {
|
} else {
|
||||||
// 不存在的时候返回-1 然后循环5秒
|
// 不存在的时候返回-1 然后循环5秒
|
||||||
index++;
|
index++;
|
||||||
print("index:$index 没有找到设备");
|
print("index:$index");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -158,7 +156,7 @@ class BlueManage {
|
|||||||
if (connectionStateUpdate.connectionState == DeviceConnectionState.connected) {
|
if (connectionStateUpdate.connectionState == DeviceConnectionState.connected) {
|
||||||
// 如果状态是连接的开始发现服务
|
// 如果状态是连接的开始发现服务
|
||||||
try {
|
try {
|
||||||
_subScribeToCharacteristic(QualifiedCharacteristic(characteristicId: characteristicIdSubscription, serviceId: serviceIdConnect, deviceId: connectDeviceMacAddress));
|
_subScribeToCharacteristic(QualifiedCharacteristic(characteristicId: _characteristicIdSubscription, serviceId: _serviceIdConnect, deviceId: connectDeviceMacAddress));
|
||||||
print('Discovering services finished');
|
print('Discovering services finished');
|
||||||
|
|
||||||
deviceConnectionState = connectionStateUpdate.connectionState;
|
deviceConnectionState = connectionStateUpdate.connectionState;
|
||||||
@ -225,7 +223,7 @@ class BlueManage {
|
|||||||
|
|
||||||
// 写入
|
// 写入
|
||||||
Future<void> writeCharacteristicWithResponse(List<int> value) async {
|
Future<void> writeCharacteristicWithResponse(List<int> value) async {
|
||||||
QualifiedCharacteristic characteristic = QualifiedCharacteristic(characteristicId: characteristicIdWrite, serviceId: serviceIdWrite, deviceId: connectDeviceMacAddress);
|
QualifiedCharacteristic characteristic = QualifiedCharacteristic(characteristicId: _characteristicIdWrite, serviceId: _serviceIdWrite, deviceId: connectDeviceMacAddress);
|
||||||
int mtuLength = await _flutterReactiveBle!.requestMtu(deviceId: characteristic.deviceId, mtu: 250);
|
int mtuLength = await _flutterReactiveBle!.requestMtu(deviceId: characteristic.deviceId, mtu: 250);
|
||||||
print("mtuLength:$mtuLength");
|
print("mtuLength:$mtuLength");
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -50,7 +50,7 @@ class MyApp extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 注册 RouteObserver 作为 navigation observer.
|
// 注册 RouteObserver 作为 navigation observer.
|
||||||
final RouteObserver<PageRoute> routeObserver = RouteObserver<PageRoute>();
|
// final RouteObserver<PageRoute> routeObserver = RouteObserver<PageRoute>();
|
||||||
|
|
||||||
class _MyAppState extends State<MyApp> with WidgetsBindingObserver, BaseWidget {
|
class _MyAppState extends State<MyApp> with WidgetsBindingObserver, BaseWidget {
|
||||||
final _aliyunPush = AliyunPush();
|
final _aliyunPush = AliyunPush();
|
||||||
@ -68,7 +68,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver, BaseWidget {
|
|||||||
|
|
||||||
GetMaterialApp _initMaterialApp() => GetMaterialApp(
|
GetMaterialApp _initMaterialApp() => GetMaterialApp(
|
||||||
title: 'Star Lock',
|
title: 'Star Lock',
|
||||||
navigatorObservers: [routeObserver, AppRouteObserver().routeObserver],
|
navigatorObservers: [AppRouteObserver().routeObserver],
|
||||||
translations: TranslationMessage(),
|
translations: TranslationMessage(),
|
||||||
supportedLocales: appDept.deptSupportedLocales,
|
supportedLocales: appDept.deptSupportedLocales,
|
||||||
localizationsDelegates: const [
|
localizationsDelegates: const [
|
||||||
@ -233,3 +233,4 @@ Future<bool> getMicrophonePermission() async {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -163,7 +163,7 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 转移权限
|
// 转移权限
|
||||||
Future<void> transferPermissionsAction() async {
|
Future<void> transferPermissionsAction() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||||
if (state == DeviceConnectionState.connected) {
|
if (state == DeviceConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
@ -192,7 +192,7 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
|||||||
// 添加用户
|
// 添加用户
|
||||||
Future<void> addUserConnectBlue(String receiveId) async {
|
Future<void> addUserConnectBlue(String receiveId) async {
|
||||||
// 进来之后首先连接
|
// 进来之后首先连接
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connecteState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connecteState) async {
|
||||||
if (connecteState == DeviceConnectionState.connected) {
|
if (connecteState == DeviceConnectionState.connected) {
|
||||||
// 私钥
|
// 私钥
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
|
|||||||
@ -214,7 +214,7 @@ class AddICCardLogic extends BaseGetXController{
|
|||||||
|
|
||||||
// 添加卡片
|
// 添加卡片
|
||||||
Future<void> senderAddICCard() async {
|
Future<void> senderAddICCard() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||||
@ -241,7 +241,7 @@ class AddICCardLogic extends BaseGetXController{
|
|||||||
token: getTokenList,
|
token: getTokenList,
|
||||||
);
|
);
|
||||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected){
|
} else if (deviceConnectionState == DeviceConnectionState.disconnected){
|
||||||
Toast.show(msg: "连接设备失败,请确保在设备附近,设备未被连接,设备已打开");
|
showBlueConnetctToast();
|
||||||
Get.close(2);
|
Get.close(2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -249,7 +249,7 @@ class AddICCardLogic extends BaseGetXController{
|
|||||||
|
|
||||||
// 添加胁迫卡片
|
// 添加胁迫卡片
|
||||||
Future<void> senderAddStressICCard() async {
|
Future<void> senderAddStressICCard() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||||
|
|||||||
@ -88,7 +88,7 @@ class CardDetailLogic extends BaseGetXController{
|
|||||||
|
|
||||||
// 删除卡片
|
// 删除卡片
|
||||||
Future<void> senderAddICCard() async {
|
Future<void> senderAddICCard() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||||
|
|||||||
@ -205,7 +205,7 @@ class CardListLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 查询卡片状态
|
// 查询卡片状态
|
||||||
Future<void> senderCheckingCardStatus() async {
|
Future<void> senderCheckingCardStatus() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||||
if (state == DeviceConnectionState.connected) {
|
if (state == DeviceConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
@ -233,7 +233,7 @@ class CardListLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
||||||
Future<void> senderCheckingUserInfoCount() async {
|
Future<void> senderCheckingUserInfoCount() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||||
if (state == DeviceConnectionState.connected) {
|
if (state == DeviceConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
@ -260,7 +260,7 @@ class CardListLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 删除卡片
|
// 删除卡片
|
||||||
Future<void> senderAddICCard() async {
|
Future<void> senderAddICCard() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||||
|
|||||||
@ -252,7 +252,7 @@ class AddFingerprintLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 添加指纹开始
|
// 添加指纹开始
|
||||||
Future<void> senderAddFingerprint() async {
|
Future<void> senderAddFingerprint() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||||
// print("66666666:$deviceConnectionState");
|
// print("66666666:$deviceConnectionState");
|
||||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||||
@ -280,7 +280,7 @@ class AddFingerprintLogic extends BaseGetXController {
|
|||||||
token: getTokenList,
|
token: getTokenList,
|
||||||
);
|
);
|
||||||
}else if (deviceConnectionState == DeviceConnectionState.disconnected){
|
}else if (deviceConnectionState == DeviceConnectionState.disconnected){
|
||||||
Toast.show(msg: "连接设备失败,请确保在设备附近,设备未被连接,设备已打开");
|
showBlueConnetctToast();
|
||||||
Get.close(2);
|
Get.close(2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -288,7 +288,7 @@ class AddFingerprintLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 添加胁迫指纹
|
// 添加胁迫指纹
|
||||||
Future<void> senderAddStressFingerprint() async {
|
Future<void> senderAddStressFingerprint() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||||
|
|||||||
@ -89,7 +89,7 @@ class FingerprintDetailLogic extends BaseGetXController{
|
|||||||
|
|
||||||
// 删除指纹
|
// 删除指纹
|
||||||
Future<void> senderAddFingerprint() async {
|
Future<void> senderAddFingerprint() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||||
|
|||||||
@ -238,7 +238,7 @@ class FingerprintListLogic extends BaseGetXController{
|
|||||||
}
|
}
|
||||||
// 获取指纹状态
|
// 获取指纹状态
|
||||||
Future<void> senderQueryingFingerprintStatus() async {
|
Future<void> senderQueryingFingerprintStatus() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName,(DeviceConnectionState state) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName,(DeviceConnectionState state) async {
|
||||||
if (state == DeviceConnectionState.connected) {
|
if (state == DeviceConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
@ -266,7 +266,7 @@ class FingerprintListLogic extends BaseGetXController{
|
|||||||
|
|
||||||
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
||||||
Future<void> senderCheckingUserInfoCount() async {
|
Future<void> senderCheckingUserInfoCount() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||||
if (state == DeviceConnectionState.connected) {
|
if (state == DeviceConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
@ -293,7 +293,7 @@ class FingerprintListLogic extends BaseGetXController{
|
|||||||
|
|
||||||
// 删除指纹
|
// 删除指纹
|
||||||
Future<void> senderAddFingerprint() async {
|
Future<void> senderAddFingerprint() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||||
|
|||||||
@ -128,7 +128,7 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
|||||||
|
|
||||||
// 读取支持功能-带参数
|
// 读取支持功能-带参数
|
||||||
Future<void> _readSupportFunctionsWithParameters() async {
|
Future<void> _readSupportFunctionsWithParameters() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
@ -155,7 +155,7 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
|||||||
// 设置支持功能(带参数)
|
// 设置支持功能(带参数)
|
||||||
Future<void> sendAutoLock() async {
|
Future<void> sendAutoLock() async {
|
||||||
showEasyLoading();
|
showEasyLoading();
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
|
|||||||
@ -13,7 +13,7 @@ class AdminOpenLockPasswordLogic extends BaseGetXController{
|
|||||||
|
|
||||||
// 读取支持功能-带参数
|
// 读取支持功能-带参数
|
||||||
Future<void> _readAdminPassword() async {
|
Future<void> _readAdminPassword() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
|
|||||||
@ -7,7 +7,7 @@ class BasicInformationLogic extends BaseGetXController{
|
|||||||
|
|
||||||
// 读取支持功能-带参数
|
// 读取支持功能-带参数
|
||||||
// Future<void> _readAdminPassword() async {
|
// Future<void> _readAdminPassword() async {
|
||||||
// BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
// BlueManage().bludSendData(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
// if (connectionState == DeviceConnectionState.connected) {
|
// if (connectionState == DeviceConnectionState.connected) {
|
||||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
|
|||||||
@ -112,7 +112,7 @@ class BurglarAlarmLogic extends BaseGetXController{
|
|||||||
|
|
||||||
// 读取支持功能-带参数
|
// 读取支持功能-带参数
|
||||||
Future<void> _readSupportFunctionsNoParameters() async {
|
Future<void> _readSupportFunctionsNoParameters() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
@ -139,7 +139,7 @@ class BurglarAlarmLogic extends BaseGetXController{
|
|||||||
// 设置支持功能(带参数)
|
// 设置支持功能(带参数)
|
||||||
Future<void> sendBurglarAlarm() async {
|
Future<void> sendBurglarAlarm() async {
|
||||||
showEasyLoading();
|
showEasyLoading();
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
|
|||||||
@ -144,7 +144,7 @@ class ConfiguringWifiLogic extends BaseGetXController{
|
|||||||
// 点击配置wifi
|
// 点击配置wifi
|
||||||
Future<void> senderConfiguringWifiAction() async {
|
Future<void> senderConfiguringWifiAction() async {
|
||||||
showEasyLoading();
|
showEasyLoading();
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.connected){
|
if (connectionState == DeviceConnectionState.connected){
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
|
|||||||
@ -257,7 +257,9 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
// 删除用户
|
// 删除用户
|
||||||
Future<void> deletUserAction() async {
|
Future<void> deletUserAction() async {
|
||||||
showEasyLoading();
|
showEasyLoading();
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
showBlueConnetctToastTimer();
|
||||||
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
|
cancelBlueConnetctToastTimer();
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
@ -291,7 +293,9 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
// 恢复出厂设置
|
// 恢复出厂设置
|
||||||
Future<void> factoryDataResetAction() async {
|
Future<void> factoryDataResetAction() async {
|
||||||
showEasyLoading();
|
showEasyLoading();
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
showBlueConnetctToastTimer();
|
||||||
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
|
cancelBlueConnetctToastTimer();
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
@ -320,7 +324,7 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 读取支持功能-带参数
|
// 读取支持功能-带参数
|
||||||
// Future<void> _readSupportFunctionsNoParameters(int type) async {
|
// Future<void> _readSupportFunctionsNoParameters(int type) async {
|
||||||
// BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
// BlueManage().bludSendData(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
// if (connectionState == DeviceConnectionState.connected) {
|
// if (connectionState == DeviceConnectionState.connected) {
|
||||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
@ -347,7 +351,9 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
// 设置支持功能(带参数)
|
// 设置支持功能(带参数)
|
||||||
Future<void> sendBurglarAlarm(int type) async {
|
Future<void> sendBurglarAlarm(int type) async {
|
||||||
showEasyLoading();
|
showEasyLoading();
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
showBlueConnetctToastTimer();
|
||||||
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
|
cancelBlueConnetctToastTimer();
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
@ -614,7 +620,6 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
void onReady() {
|
void onReady() {
|
||||||
// TODO: implement onReady
|
// TODO: implement onReady
|
||||||
super.onReady();
|
super.onReady();
|
||||||
print("onReady()");
|
|
||||||
|
|
||||||
getLockSettingInfoData();
|
getLockSettingInfoData();
|
||||||
|
|
||||||
@ -626,12 +631,12 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
void onInit() {
|
void onInit() {
|
||||||
// TODO: implement onInit
|
// TODO: implement onInit
|
||||||
super.onInit();
|
super.onInit();
|
||||||
print("onInit()");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onClose() {
|
void onClose() {
|
||||||
// TODO: implement onClose
|
// TODO: implement onClose
|
||||||
|
|
||||||
_replySubscription.cancel();
|
_replySubscription.cancel();
|
||||||
_passCurrentLockInformationEvent!.cancel();
|
_passCurrentLockInformationEvent!.cancel();
|
||||||
_scanListDiscoveredDeviceSubscription.cancel();
|
_scanListDiscoveredDeviceSubscription.cancel();
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import 'package:get/get.dart';
|
|||||||
|
|
||||||
import '../../../../appRouters.dart';
|
import '../../../../appRouters.dart';
|
||||||
import '../../../../app_settings/app_colors.dart';
|
import '../../../../app_settings/app_colors.dart';
|
||||||
|
import '../../../../main.dart';
|
||||||
import '../../../../tools/appRouteObserver.dart';
|
import '../../../../tools/appRouteObserver.dart';
|
||||||
import '../../../../tools/commonItem.dart';
|
import '../../../../tools/commonItem.dart';
|
||||||
|
|
||||||
@ -15,6 +16,7 @@ import '../../../../tools/toast.dart';
|
|||||||
import '../../../../translations/trans_lib.dart';
|
import '../../../../translations/trans_lib.dart';
|
||||||
import 'lockSet_logic.dart';
|
import 'lockSet_logic.dart';
|
||||||
|
|
||||||
|
// final RouteObserver<PageRoute> routeObserver = RouteObserver<PageRoute>();
|
||||||
class LockSetPage extends StatefulWidget {
|
class LockSetPage extends StatefulWidget {
|
||||||
const LockSetPage({Key? key}) : super(key: key);
|
const LockSetPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@ -782,7 +784,6 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
|||||||
// },
|
// },
|
||||||
// );
|
// );
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didChangeDependencies() {
|
void didChangeDependencies() {
|
||||||
// TODO: implement didChangeDependencies
|
// TODO: implement didChangeDependencies
|
||||||
@ -800,27 +801,33 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 界面从上一个界面进入 当前界面即将出现
|
/// 从上级界面进入 当前界面即将出现
|
||||||
@override
|
@override
|
||||||
void didPush() {
|
void didPush() {
|
||||||
|
super.didPush();
|
||||||
print("lockSet===didPush");
|
print("lockSet===didPush");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 界面返回上一个界面 当前界面即将消失
|
/// 返回上一个界面 当前界面即将消失
|
||||||
@override
|
@override
|
||||||
void didPop() {
|
void didPop() {
|
||||||
|
super.didPop();
|
||||||
print("lockSet===didPop");
|
print("lockSet===didPop");
|
||||||
|
logic.cancelBlueConnetctToastTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 当前界面从下一级返回 当前界面即将出现
|
/// 从下级返回 当前界面即将出现
|
||||||
@override
|
@override
|
||||||
void didPopNext() {
|
void didPopNext() {
|
||||||
|
super.didPopNext();
|
||||||
print("lockSet===didPopNext");
|
print("lockSet===didPopNext");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 当前界面进入下一个界面 当前界面即将消失
|
/// 进入下级界面 当前界面即将消失
|
||||||
@override
|
@override
|
||||||
void didPushNext() {
|
void didPushNext() {
|
||||||
|
super.didPushNext();
|
||||||
print("lockSet===didPushNext");
|
print("lockSet===didPushNext");
|
||||||
|
logic.cancelBlueConnetctToastTimer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -120,7 +120,7 @@ class LockSoundSetLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 读取支持功能-带参数
|
// 读取支持功能-带参数
|
||||||
Future<void> _readSupportFunctionsWithParameters() async {
|
Future<void> _readSupportFunctionsWithParameters() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
@ -147,7 +147,7 @@ class LockSoundSetLogic extends BaseGetXController {
|
|||||||
// 设置支持功能(带参数)
|
// 设置支持功能(带参数)
|
||||||
Future<void> sendLockSound() async {
|
Future<void> sendLockSound() async {
|
||||||
showEasyLoading();
|
showEasyLoading();
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
|
|||||||
@ -131,7 +131,7 @@ class LockTimeLogic extends BaseGetXController{
|
|||||||
// 获取锁状态
|
// 获取锁状态
|
||||||
// Future<void> _getLockStatus() async {
|
// Future<void> _getLockStatus() async {
|
||||||
// // 进来之后首先连接
|
// // 进来之后首先连接
|
||||||
// BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
// BlueManage().bludSendData(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||||
// if (state == DeviceConnectionState.connected) {
|
// if (state == DeviceConnectionState.connected) {
|
||||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
@ -147,7 +147,7 @@ class LockTimeLogic extends BaseGetXController{
|
|||||||
// 校验时间
|
// 校验时间
|
||||||
Future<void> sendTiming() async {
|
Future<void> sendTiming() async {
|
||||||
showEasyLoading();
|
showEasyLoading();
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
|
|||||||
@ -111,7 +111,7 @@ class MotorPowerLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 读取支持功能-带参数
|
// 读取支持功能-带参数
|
||||||
Future<void> _readSupportFunctionsNoParameters() async {
|
Future<void> _readSupportFunctionsNoParameters() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
@ -137,7 +137,7 @@ class MotorPowerLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 设置支持功能(带参数)
|
// 设置支持功能(带参数)
|
||||||
Future<void> sendOpenDoorDirection() async {
|
Future<void> sendOpenDoorDirection() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
|
|||||||
@ -139,7 +139,7 @@ class NormallyOpenModeLogic extends BaseGetXController{
|
|||||||
|
|
||||||
// 读取支持功能-带参数
|
// 读取支持功能-带参数
|
||||||
Future<void> _readSupportFunctionsWithParameters() async {
|
Future<void> _readSupportFunctionsWithParameters() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
@ -166,7 +166,7 @@ class NormallyOpenModeLogic extends BaseGetXController{
|
|||||||
// 设置支持功能(带参数)
|
// 设置支持功能(带参数)
|
||||||
Future<void> sendAutoLock() async {
|
Future<void> sendAutoLock() async {
|
||||||
showEasyLoading();
|
showEasyLoading();
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
|
|||||||
@ -113,7 +113,7 @@ class OpenDoorDirectionLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 读取支持功能-带参数
|
// 读取支持功能-带参数
|
||||||
Future<void> _readSupportFunctionsNoParameters() async {
|
Future<void> _readSupportFunctionsNoParameters() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
@ -140,7 +140,7 @@ class OpenDoorDirectionLogic extends BaseGetXController {
|
|||||||
// 设置支持功能(带参数)
|
// 设置支持功能(带参数)
|
||||||
Future<void> sendOpenDoorDirection() async {
|
Future<void> sendOpenDoorDirection() async {
|
||||||
showEasyLoading();
|
showEasyLoading();
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
|
|||||||
@ -112,7 +112,7 @@ class RemoteUnlockingLogic extends BaseGetXController{
|
|||||||
|
|
||||||
// 读取支持功能-带参数
|
// 读取支持功能-带参数
|
||||||
Future<void> _readSupportFunctionsNoParameters() async {
|
Future<void> _readSupportFunctionsNoParameters() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
@ -139,7 +139,7 @@ class RemoteUnlockingLogic extends BaseGetXController{
|
|||||||
// 设置支持功能(带参数) 远程开锁
|
// 设置支持功能(带参数) 远程开锁
|
||||||
Future<void> sendBurglarAlarm() async {
|
Future<void> sendBurglarAlarm() async {
|
||||||
showEasyLoading();
|
showEasyLoading();
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
|
|||||||
@ -114,7 +114,7 @@ class ResetButtonLogic extends BaseGetXController{
|
|||||||
|
|
||||||
// 读取支持功能-带参数
|
// 读取支持功能-带参数
|
||||||
Future<void> _readSupportFunctionsNoParameters() async {
|
Future<void> _readSupportFunctionsNoParameters() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
@ -141,7 +141,7 @@ class ResetButtonLogic extends BaseGetXController{
|
|||||||
// 设置支持功能(带参数)
|
// 设置支持功能(带参数)
|
||||||
Future<void> sendBurglarAlarm() async {
|
Future<void> sendBurglarAlarm() async {
|
||||||
showEasyLoading();
|
showEasyLoading();
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
|
|||||||
@ -78,7 +78,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
state.electricQuantity.value = power;
|
state.electricQuantity.value = power;
|
||||||
|
|
||||||
getLockRecordLastUploadDataTime();
|
getLockRecordLastUploadDataTime();
|
||||||
state.lockState.value = 2;
|
state.openLockBtnState.value = 0;
|
||||||
state.animationController.reset();
|
state.animationController.reset();
|
||||||
state.animationController.forward();
|
state.animationController.forward();
|
||||||
// state.animationController.isCompleted;
|
// state.animationController.isCompleted;
|
||||||
@ -345,8 +345,13 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 点击开门事件
|
// 点击开门事件
|
||||||
Future<void> openDoorAction() async {
|
Future<void> openDoorAction() async {
|
||||||
BlueManage().judgeReconnect(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (DeviceConnectionState deviceConnectionState) async {
|
showBlueConnetctToastTimer();
|
||||||
|
BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (DeviceConnectionState deviceConnectionState) async {
|
||||||
|
cancelBlueConnetctToastTimer();
|
||||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||||
|
state.connectState.value = 1;
|
||||||
|
state.openLockBtnState.value = 0;
|
||||||
|
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
|
|
||||||
@ -369,11 +374,12 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
);
|
);
|
||||||
}else if (deviceConnectionState == DeviceConnectionState.disconnected){
|
}else if (deviceConnectionState == DeviceConnectionState.disconnected){
|
||||||
if(state.lockState.value != 2){
|
// if(state.lockState.value != 2){
|
||||||
// 2的状态是从已经连接上了 然后没有进行任何操作 锁板主动断开了 所以只需要改变开锁按钮状态不需要弹出toast
|
// // 2的状态是从已经连接上了 然后没有进行任何操作 锁板主动断开了 所以只需要改变开锁按钮状态不需要弹出toast
|
||||||
Toast.show(msg: "连接设备失败,请确保在设备附近,设备未被连接,设备已打开");
|
showBlueConnetctToast();
|
||||||
}
|
// }
|
||||||
state.lockState.value = 4;
|
state.connectState.value = 0;
|
||||||
|
state.openLockBtnState.value = 0;
|
||||||
state.animationController.reset();
|
state.animationController.reset();
|
||||||
state.animationController.forward();
|
state.animationController.forward();
|
||||||
}
|
}
|
||||||
@ -382,7 +388,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 编辑用户事件
|
// 编辑用户事件
|
||||||
// Future<void> editLockUserAction() async {
|
// Future<void> editLockUserAction() async {
|
||||||
// BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
// BlueManage().bludSendData(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||||
// if (state == DeviceConnectionState.connected){
|
// if (state == DeviceConnectionState.connected){
|
||||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||||
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||||
@ -442,7 +448,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 查询事件记录(时间查询)
|
// 查询事件记录(时间查询)
|
||||||
Future<void> senderReferEventRecordTime(int time) async {
|
Future<void> senderReferEventRecordTime(int time) async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName,
|
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||||
(DeviceConnectionState state) async {
|
(DeviceConnectionState state) async {
|
||||||
if (state == DeviceConnectionState.connected) {
|
if (state == DeviceConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
@ -472,7 +478,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
// 添加用户(普通用户接收电子钥匙)
|
// 添加用户(普通用户接收电子钥匙)
|
||||||
Future<void> addUserConnectBlue() async {
|
Future<void> addUserConnectBlue() async {
|
||||||
// 进来之后首先连接
|
// 进来之后首先连接
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName,
|
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||||
(DeviceConnectionState deviceConnectionState) async {
|
(DeviceConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == DeviceConnectionState.connected) {
|
if (deviceConnectionState == DeviceConnectionState.connected) {
|
||||||
// 私钥
|
// 私钥
|
||||||
@ -508,15 +514,15 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//开始连接
|
// 点击开锁
|
||||||
startConnect() {
|
startOpenLock() {
|
||||||
if(state.lockState.value == 4){
|
// if(state.lockState.value == 4){
|
||||||
// 当状态为4的时候,代表是已经连接过一次了,但是连接失败了,所以要重新连接
|
// // 当状态为4的时候,代表是已经连接过一次了,但是连接失败了,所以要重新连接
|
||||||
state.lockState.value = 3;
|
// state.lockState.value = 3;
|
||||||
}else{
|
// }else{
|
||||||
// 其他代表是第一次连接
|
// 其他代表是第一次连接
|
||||||
state.lockState.value = 1;
|
state.openLockBtnState.value = 1;
|
||||||
}
|
// }
|
||||||
state.animationController.forward();
|
state.animationController.forward();
|
||||||
|
|
||||||
if (state.lockUserNo == 0) {
|
if (state.lockUserNo == 0) {
|
||||||
@ -533,6 +539,10 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
longPressCloseDoor(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// 获取手机联网token,根据锁设置里面获取的开锁时是否联网来判断是否调用这个接口
|
// 获取手机联网token,根据锁设置里面获取的开锁时是否联网来判断是否调用这个接口
|
||||||
void getLockNetToken() async {
|
void getLockNetToken() async {
|
||||||
LockNetTokenEntity entity = await ApiRepository.to
|
LockNetTokenEntity entity = await ApiRepository.to
|
||||||
@ -581,11 +591,11 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
// connectBlueAndAnimationController(){
|
// connectBlueAndAnimationController(){
|
||||||
// state.lockState.value = 1;
|
// state.lockState.value = 1;
|
||||||
// state.animationController.forward();
|
// state.animationController.forward();
|
||||||
// BlueManage().judgeReconnect(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (DeviceConnectionState deviceConnectionState) async {
|
// BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (DeviceConnectionState deviceConnectionState) async {
|
||||||
// if (deviceConnectionState == DeviceConnectionState.connected){
|
// if (deviceConnectionState == DeviceConnectionState.connected){
|
||||||
// state.lockState.value = 2;
|
// state.lockState.value = 2;
|
||||||
// }else if (deviceConnectionState == DeviceConnectionState.disconnected){
|
// }else if (deviceConnectionState == DeviceConnectionState.disconnected){
|
||||||
// Toast.show(msg: "连接设备失败,请确保在设备附近,设备未被连接,设备已打开");
|
// showBlueConnetctToast();
|
||||||
//
|
//
|
||||||
// state.lockState.value = 4;
|
// state.lockState.value = 4;
|
||||||
// state.animationController.reset();
|
// state.animationController.reset();
|
||||||
@ -597,7 +607,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
/// 锁设置里面开启关闭考勤刷新锁详情
|
/// 锁设置里面开启关闭考勤刷新锁详情
|
||||||
StreamSubscription?
|
StreamSubscription?
|
||||||
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent;
|
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent;
|
||||||
void initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction() {
|
void _initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction() {
|
||||||
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
||||||
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent = eventBus
|
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent = eventBus
|
||||||
.on<LockSetChangeSetRefreshLockDetailWithType>()
|
.on<LockSetChangeSetRefreshLockDetailWithType>()
|
||||||
@ -621,8 +631,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
print("onReady()");
|
print("onReady()");
|
||||||
|
|
||||||
_initReplySubscription();
|
_initReplySubscription();
|
||||||
initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction();
|
_initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
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_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
@ -8,8 +7,8 @@ import '../../../appRouters.dart';
|
|||||||
import '../../../app_settings/app_colors.dart';
|
import '../../../app_settings/app_colors.dart';
|
||||||
import '../../../blue/blue_manage.dart';
|
import '../../../blue/blue_manage.dart';
|
||||||
import '../../../blue/io_tool/io_tool.dart';
|
import '../../../blue/io_tool/io_tool.dart';
|
||||||
|
import '../../../tools/appRouteObserver.dart';
|
||||||
import '../../../tools/storage.dart';
|
import '../../../tools/storage.dart';
|
||||||
import '../../../tools/toast.dart';
|
|
||||||
import '../../../translations/trans_lib.dart';
|
import '../../../translations/trans_lib.dart';
|
||||||
import '../../lockMian/entity/lockListInfo_entity.dart';
|
import '../../lockMian/entity/lockListInfo_entity.dart';
|
||||||
import 'lockDetail_logic.dart';
|
import 'lockDetail_logic.dart';
|
||||||
@ -44,25 +43,19 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
|||||||
state.isOpenLockNeedOnline.value = state.keyInfos.value.lockSetting!.appUnlockOnline!;
|
state.isOpenLockNeedOnline.value = state.keyInfos.value.lockSetting!.appUnlockOnline!;
|
||||||
state.electricQuantity.value = state.keyInfos.value.electricQuantity!;
|
state.electricQuantity.value = state.keyInfos.value.electricQuantity!;
|
||||||
|
|
||||||
BlueManage().connectDeviceName =
|
BlueManage().connectDeviceName = state.keyInfos.value.bluetooth!.bluetoothDeviceName!;
|
||||||
state.keyInfos.value.bluetooth!.bluetoothDeviceName!;
|
|
||||||
// BlueManage().connectDeviceMacAddress =
|
|
||||||
// state.keyInfos.value.bluetooth!.bluetoothDeviceId!;
|
|
||||||
|
|
||||||
List<int> publicKeyData =
|
List<int> publicKeyData = state.keyInfos.value.bluetooth!.publicKey!.cast<int>();
|
||||||
state.keyInfos.value.bluetooth!.publicKey!.cast<int>();
|
|
||||||
var saveStrList = changeIntListToStringList(publicKeyData);
|
var saveStrList = changeIntListToStringList(publicKeyData);
|
||||||
Storage.setStringList(saveBluePublicKey, saveStrList);
|
Storage.setStringList(saveBluePublicKey, saveStrList);
|
||||||
|
|
||||||
// 私钥
|
// 私钥
|
||||||
List<int> privateKeyData =
|
List<int> privateKeyData = state.keyInfos.value.bluetooth!.privateKey!.cast<int>();
|
||||||
state.keyInfos.value.bluetooth!.privateKey!.cast<int>();
|
|
||||||
var savePrivateKeyList = changeIntListToStringList(privateKeyData);
|
var savePrivateKeyList = changeIntListToStringList(privateKeyData);
|
||||||
Storage.setStringList(saveBluePrivateKey, savePrivateKeyList);
|
Storage.setStringList(saveBluePrivateKey, savePrivateKeyList);
|
||||||
|
|
||||||
// signKey
|
// signKey
|
||||||
List<int> signKeyData =
|
List<int> signKeyData = state.keyInfos.value.bluetooth!.signKey!.cast<int>();
|
||||||
state.keyInfos.value.bluetooth!.signKey!.cast<int>();
|
|
||||||
var saveSignKeyList = changeIntListToStringList(signKeyData);
|
var saveSignKeyList = changeIntListToStringList(signKeyData);
|
||||||
Storage.setStringList(saveBlueSignKey, saveSignKeyList);
|
Storage.setStringList(saveBlueSignKey, saveSignKeyList);
|
||||||
|
|
||||||
@ -124,14 +117,14 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
|||||||
children: [
|
children: [
|
||||||
Center(
|
Center(
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
child: Obx(() => Stack(
|
child: Obx(() => Stack(
|
||||||
children: [
|
children: [
|
||||||
Image.asset(
|
Image.asset(
|
||||||
(state.lockState.value == 4 || state.lockState.value == 3) ? 'images/main/icon_main_openLockBtn_grey.png' : 'images/main/icon_main_openLockBtn_center.png',
|
state.connectState.value == 0 ? 'images/main/icon_main_openLockBtn_grey.png' : 'images/main/icon_main_openLockBtn_center.png',
|
||||||
width: 330.w,
|
width: 330.w,
|
||||||
height: 330.w,
|
height: 330.w,
|
||||||
),
|
),
|
||||||
(state.lockState.value == 1 || state.lockState.value == 3)
|
state.openLockBtnState.value == 1
|
||||||
? buildRotationTransition()
|
? buildRotationTransition()
|
||||||
: Positioned(
|
: Positioned(
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
@ -141,9 +134,14 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
|||||||
)),
|
)),
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
logic.startConnect();
|
Get.log("点击开锁");
|
||||||
},
|
logic.startOpenLock();
|
||||||
|
},
|
||||||
|
onLongPressStart: (details) {
|
||||||
|
Get.log("长按开锁");
|
||||||
|
// logic.startConnect();
|
||||||
|
},
|
||||||
)),
|
)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -503,33 +501,41 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
|||||||
void dispose() {
|
void dispose() {
|
||||||
// TODO: implement dispose
|
// TODO: implement dispose
|
||||||
/// 取消路由订阅
|
/// 取消路由订阅
|
||||||
// AppRouteObserver().routeObserver.unsubscribe(this);
|
AppRouteObserver().routeObserver.unsubscribe(this);
|
||||||
state.animationController.dispose();
|
state.animationController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
/// 从上级界面进入 当前界面即将出现
|
||||||
@override
|
@override
|
||||||
void didPush() {
|
void didPush() {
|
||||||
print("LockDetailPage didPush");
|
super.didPush();
|
||||||
|
print("LockDetailPage===didPush");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called when the current route has been popped off.
|
/// 返回上一个界面 当前界面即将消失
|
||||||
@override
|
@override
|
||||||
void didPop() {
|
void didPop() {
|
||||||
print("LockDetailPage didPop");
|
super.didPop();
|
||||||
|
print("LockDetailPage===didPop");
|
||||||
|
logic.cancelBlueConnetctToastTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called when the current route has been popped off.
|
/// 从下级返回 当前界面即将出现
|
||||||
@override
|
@override
|
||||||
void didPopNext() {
|
void didPopNext() {
|
||||||
print("LockDetailPage didPopNext");
|
super.didPopNext();
|
||||||
|
print("LockDetailPage===didPopNext");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called when the current route has been popped off.
|
/// 进入下级界面 当前界面即将消失
|
||||||
@override
|
@override
|
||||||
void didPushNext() {
|
void didPushNext() {
|
||||||
print("LockDetailPage didPushNext");
|
super.didPushNext();
|
||||||
|
print("LockDetailPage===didPushNext");
|
||||||
|
logic.cancelBlueConnetctToastTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,11 @@ class LockDetailState {
|
|||||||
var isOpenLockNeedOnline = 0.obs; // APP开锁时是否需联网
|
var isOpenLockNeedOnline = 0.obs; // APP开锁时是否需联网
|
||||||
var electricQuantity = 0.obs; // 电量
|
var electricQuantity = 0.obs; // 电量
|
||||||
|
|
||||||
|
var currentDeviceUUid = "".obs;// 当前设备的uuid
|
||||||
|
|
||||||
//过渡动画控制器
|
//过渡动画控制器
|
||||||
late AnimationController animationController;
|
late AnimationController animationController;
|
||||||
var lockState = 0.obs;// 0未连接普通状态 1连接开锁中(展示动画) 2已连接开锁成功 3检测可用性 4连接失败 5连接失败重连中
|
// var lockState = 0.obs;// 0未连接普通状态 1连接开锁中(展示动画) 2已连接开锁成功 3检测可用性 4连接失败 5连接失败重连中
|
||||||
|
var openLockBtnState = 0.obs;// 0普通状态(未转动) 1连接中(转动状态)
|
||||||
|
var connectState = 0.obs;// 0未连接 1连接
|
||||||
}
|
}
|
||||||
@ -132,7 +132,7 @@ class LockOperatingRecordLogic extends BaseGetXController{
|
|||||||
|
|
||||||
// 查询事件记录(页数查询)
|
// 查询事件记录(页数查询)
|
||||||
// Future<void> senderReferEventRecordNumber() async {
|
// Future<void> senderReferEventRecordNumber() async {
|
||||||
// BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
// BlueManage().bludSendData(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||||
// if (state == DeviceConnectionState.connected) {
|
// if (state == DeviceConnectionState.connected) {
|
||||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
@ -159,7 +159,7 @@ class LockOperatingRecordLogic extends BaseGetXController{
|
|||||||
|
|
||||||
// 查询事件记录(时间查询)
|
// 查询事件记录(时间查询)
|
||||||
Future<void> senderReferEventRecordTime(int time) async {
|
Future<void> senderReferEventRecordTime(int time) async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||||
if (state == DeviceConnectionState.connected) {
|
if (state == DeviceConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
|
|||||||
@ -149,11 +149,9 @@ class LockMonitoringLogic extends BaseGetXController {
|
|||||||
|
|
||||||
Future<void> startProcessing() async {
|
Future<void> startProcessing() async {
|
||||||
frameListener(List<int> frame) async {
|
frameListener(List<int> frame) async {
|
||||||
// Get.log('Get data.length:${frame.length} Received data:$frame');
|
|
||||||
for (int i = 0; i < frame.length; i++) {
|
for (int i = 0; i < frame.length; i++) {
|
||||||
frame[i] = linearToULaw(frame[i]);
|
frame[i] = linearToULaw(frame[i]);
|
||||||
}
|
}
|
||||||
// Get.log('change Get data.length:${frame.length} change Received data:$frame');
|
|
||||||
await Future.delayed(const Duration(milliseconds: 50));
|
await Future.delayed(const Duration(milliseconds: 50));
|
||||||
sendRecordData({
|
sendRecordData({
|
||||||
"bytes": frame,
|
"bytes": frame,
|
||||||
|
|||||||
@ -223,7 +223,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 设置自定义密码
|
// 设置自定义密码
|
||||||
Future<void> senderCustomPasswords() async {
|
Future<void> senderCustomPasswords() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||||
if (state == DeviceConnectionState.connected) {
|
if (state == DeviceConnectionState.connected) {
|
||||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||||
|
|||||||
@ -67,7 +67,7 @@ class _LockAddressPageState extends State<LockAddressPage> with RouteAware{
|
|||||||
void didChangeDependencies() {
|
void didChangeDependencies() {
|
||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
// 订阅 routeObserver,之后就会尝试调用抽象类 RouteAware 的方法
|
// 订阅 routeObserver,之后就会尝试调用抽象类 RouteAware 的方法
|
||||||
routeObserver.subscribe(this, ModalRoute.of(context) as PageRoute);
|
// routeObserver.subscribe(this, ModalRoute.of(context) as PageRoute);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@ -28,7 +28,7 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
// 点击连接设备
|
// 点击连接设备
|
||||||
void connect(String deviceName){
|
void connect(String deviceName){
|
||||||
showEasyLoading();
|
showEasyLoading();
|
||||||
BlueManage().judgeReconnect(deviceName, (DeviceConnectionState state) async {
|
BlueManage().bludSendData(deviceName, (DeviceConnectionState state) async {
|
||||||
if (state == DeviceConnectionState.connected) {
|
if (state == DeviceConnectionState.connected) {
|
||||||
IoSenderManage.getPublicKey(lockId: deviceName);
|
IoSenderManage.getPublicKey(lockId: deviceName);
|
||||||
}else if (state == DeviceConnectionState.disconnected) {
|
}else if (state == DeviceConnectionState.disconnected) {
|
||||||
@ -322,7 +322,7 @@ 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().judgeReconnect(BlueManage().connectDeviceName,
|
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||||
(DeviceConnectionState state) async {
|
(DeviceConnectionState state) async {
|
||||||
if (state == DeviceConnectionState.connected) {
|
if (state == DeviceConnectionState.connected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
|
|||||||
@ -106,7 +106,7 @@ class SaveLockLogic extends BaseGetXController {
|
|||||||
// print("111111");
|
// print("111111");
|
||||||
// 进来之后首先连接
|
// 进来之后首先连接
|
||||||
showEasyLoading();
|
showEasyLoading();
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||||
// print("222222");
|
// print("222222");
|
||||||
if (state == DeviceConnectionState.connected){
|
if (state == DeviceConnectionState.connected){
|
||||||
// print("333333");
|
// print("333333");
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
abstract class Api {
|
abstract class Api {
|
||||||
// static String baseAddress = "https://pre.lock.star-lock.cn:8093"; //预发布环境
|
static String baseAddress = "https://pre.lock.star-lock.cn:8093"; //预发布环境
|
||||||
static String baseAddress = "http://192.168.56.101:8099"; //联调环境
|
// static String baseAddress = "http://192.168.56.101:8099"; //联调环境
|
||||||
// static String baseAddress = "http://192.168.1.15:8022"; //谢总本地
|
// static String baseAddress = "http://192.168.1.15:8022"; //谢总本地
|
||||||
|
|
||||||
final String baseUrl = "$baseAddress/api";
|
final String baseUrl = "$baseAddress/api";
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:async/async.dart';
|
||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/appRouters.dart';
|
import 'package:star_lock/appRouters.dart';
|
||||||
@ -44,9 +45,9 @@ class BaseGetXController extends GetxController{
|
|||||||
Get.log('onClose -----> $runtimeType');
|
Get.log('onClose -----> $runtimeType');
|
||||||
}
|
}
|
||||||
|
|
||||||
operationFailedCallBack(e){
|
// operationFailedCallBack(e){
|
||||||
showOperationFailed();
|
// showOperationFailed();
|
||||||
}
|
// }
|
||||||
|
|
||||||
Future delay({Duration? duration,Function? something}) => Future.delayed(duration ?? 500. milliseconds,something as FutureOr Function()?);
|
Future delay({Duration? duration,Function? something}) => Future.delayed(duration ?? 500. milliseconds,something as FutureOr Function()?);
|
||||||
|
|
||||||
@ -54,8 +55,31 @@ class BaseGetXController extends GetxController{
|
|||||||
|
|
||||||
void dismissEasyLoading() => EasyLoading.dismiss();
|
void dismissEasyLoading() => EasyLoading.dismiss();
|
||||||
|
|
||||||
|
Timer? _timer;
|
||||||
|
// CancelableOperation? _operation;
|
||||||
|
void showBlueConnetctToastTimer() {
|
||||||
|
if(_timer != null && _timer!.isActive){
|
||||||
|
_timer!.cancel();
|
||||||
|
}
|
||||||
|
_timer = Timer.periodic(15.seconds, (timer) {
|
||||||
|
showBlueConnetctToast();
|
||||||
|
});
|
||||||
|
// _operation = CancelableOperation.fromFuture(
|
||||||
|
// Future.delayed(const Duration(seconds: 15), () {
|
||||||
|
// print('Operation completed');
|
||||||
|
// showBlueConnetctToast();
|
||||||
|
// }),
|
||||||
|
// );
|
||||||
|
}
|
||||||
|
|
||||||
|
void cancelBlueConnetctToastTimer() {
|
||||||
|
Get.log('cancelBlueConnetctToastTimer');
|
||||||
|
if(_timer != null && _timer!.isActive) _timer!.cancel();
|
||||||
|
// _operation?.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
void showBlueConnetctToast() {
|
void showBlueConnetctToast() {
|
||||||
showToast("未扫描到要连接的设备,请确保在设备附近,设备未被连接,设备已打开");
|
showToast("连接设备失败,请确保在设备附近,设备未被连接,设备已打开");
|
||||||
}
|
}
|
||||||
|
|
||||||
void showToast(String status,{Function? something}) {
|
void showToast(String status,{Function? something}) {
|
||||||
|
|||||||
@ -38,6 +38,7 @@ dependencies:
|
|||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
cupertino_icons: ^1.0.2
|
cupertino_icons: ^1.0.2
|
||||||
|
|
||||||
|
async: ^2.8.2
|
||||||
# 常用工具类
|
# 常用工具类
|
||||||
flustars: ^2.0.1
|
flustars: ^2.0.1
|
||||||
# 提示
|
# 提示
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user