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