远程开锁优化
第三方平台
This commit is contained in:
parent
07fb7a6542
commit
3224fd342a
@ -225,7 +225,6 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
StartChartManage().lockPeerId.isNotEmpty) {
|
StartChartManage().lockPeerId.isNotEmpty) {
|
||||||
sendStarChartOpenLockMessage(reply);
|
sendStarChartOpenLockMessage(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 0x16:
|
case 0x16:
|
||||||
// 正在开锁中...
|
// 正在开锁中...
|
||||||
@ -277,6 +276,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
//失败
|
//失败
|
||||||
// AppLog.log('开锁失败');
|
// AppLog.log('开锁失败');
|
||||||
openDoorError();
|
openDoorError();
|
||||||
|
showToast('开锁失败'.tr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -514,22 +514,39 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
);
|
);
|
||||||
|
|
||||||
BlueManage().blueSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!,
|
BlueManage().blueSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!,
|
||||||
(BluetoothConnectionState deviceConnectionState) async {
|
(BluetoothConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||||
BuglyTool.uploadException(message: '蓝牙连接成功', detail: '蓝牙连接成功,发送开锁指令--OpenLockCommand:$command', upload: false);
|
BuglyTool.uploadException(message: '蓝牙连接成功', detail: '蓝牙连接成功,发送开锁指令--OpenLockCommand:$command', upload: false);
|
||||||
// FlutterBuglyPlugin.reportException(exceptionName: '蓝牙连接成功', reason: '蓝牙连接成功,发送开锁指令');
|
// FlutterBuglyPlugin.reportException(exceptionName: '蓝牙连接成功', reason: '蓝牙连接成功,发送开锁指令');
|
||||||
IoSenderManage.senderOpenLock(
|
IoSenderManage.senderOpenLock(
|
||||||
lockID: BlueManage().connectDeviceName,
|
lockID: BlueManage().connectDeviceName,
|
||||||
userID: await Storage.getUid(),
|
userID: await Storage.getUid(),
|
||||||
openMode: state.openDoorModel,
|
openMode: state.openDoorModel,
|
||||||
openTime: getUTCNetTime(),
|
openTime: getUTCNetTime(),
|
||||||
onlineToken: state.lockNetToken,
|
onlineToken: state.lockNetToken,
|
||||||
token: getTokenList,
|
token: getTokenList,
|
||||||
needAuthor: 1,
|
needAuthor: 1,
|
||||||
signKey: signKeyDataList,
|
signKey: signKeyDataList,
|
||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
);
|
);
|
||||||
});
|
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||||
|
cancelBlueConnetctToastTimer();
|
||||||
|
BuglyTool.uploadException(
|
||||||
|
message: '蓝牙连接失败-开锁失败', detail: '蓝牙连接失败,断开连接, 开锁失败--OpenLockCommand:$command', upload: true);
|
||||||
|
final String getMobile = (await Storage.getMobile())!;
|
||||||
|
ApmHelper.instance.trackEvent('open_lock', {
|
||||||
|
'lock_name': state.keyInfos.value.lockName!,
|
||||||
|
'account': getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!,
|
||||||
|
'date': DateTool().getNowDateWithType(1),
|
||||||
|
'open_lock_result': '断开连接',
|
||||||
|
});
|
||||||
|
|
||||||
|
// if (state.ifCurrentScreen.value == true) {
|
||||||
|
// showBlueConnetctToast();
|
||||||
|
// }
|
||||||
|
resetOpenDoorState();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//蓝牙关闭
|
//蓝牙关闭
|
||||||
@ -683,14 +700,12 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
var lockId = currentKeyInfo.lockId ?? 0;
|
var lockId = currentKeyInfo.lockId ?? 0;
|
||||||
var remoteUnlock = currentKeyInfo.lockSetting?.remoteUnlock ?? 0;
|
var remoteUnlock = currentKeyInfo.lockSetting?.remoteUnlock ?? 0;
|
||||||
|
|
||||||
var lockPeerId = StartChartManage().lockPeerId;
|
// 每次远程开锁都使用当前锁的peerId,确保使用正确的锁
|
||||||
|
final network = currentKeyInfo.network;
|
||||||
if (lockPeerId.isEmpty) {
|
var lockPeerId = '';
|
||||||
final network = currentKeyInfo.network;
|
if (network != null && network.peerId != null && network.peerId!.isNotEmpty) {
|
||||||
if (network != null && network.peerId != null && network.peerId!.isNotEmpty) {
|
lockPeerId = network.peerId!;
|
||||||
lockPeerId = network.peerId!;
|
StartChartManage().lockPeerId = lockPeerId;
|
||||||
StartChartManage().lockPeerId = lockPeerId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remoteUnlock == 1) {
|
if (remoteUnlock == 1) {
|
||||||
@ -762,7 +777,6 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
if (userID == null || userID.isEmpty) {
|
if (userID == null || userID.isEmpty) {
|
||||||
throw Exception('未找到用户ID');
|
throw Exception('未找到用户ID');
|
||||||
}
|
}
|
||||||
AppLog.log('用户ID: $userID');
|
|
||||||
|
|
||||||
// 构建开锁命令
|
// 构建开锁命令
|
||||||
final OpenLockCommand openLockCommand = OpenLockCommand(
|
final OpenLockCommand openLockCommand = OpenLockCommand(
|
||||||
@ -776,11 +790,9 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
signKey: signKeyList,
|
signKey: signKeyList,
|
||||||
privateKey: privateKeyList,
|
privateKey: privateKeyList,
|
||||||
);
|
);
|
||||||
AppLog.log('构建开锁命令成功');
|
|
||||||
|
|
||||||
// 包装命令数据
|
// 包装命令数据
|
||||||
final List<int> messageDetail = openLockCommand.packageData();
|
final messageDetail = openLockCommand.packageData();
|
||||||
|
|
||||||
// 发送蓝牙透传开锁命令
|
// 发送蓝牙透传开锁命令
|
||||||
StartChartManage().sendRemoteUnLockMessage(
|
StartChartManage().sendRemoteUnLockMessage(
|
||||||
bluetoothDeviceName: bluetoothDeviceName,
|
bluetoothDeviceName: bluetoothDeviceName,
|
||||||
@ -894,8 +906,6 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加网络质量评估变量
|
|
||||||
int _networkQualityScore = 5; // 1-5分,5为最佳
|
|
||||||
/// 发送监控消息
|
/// 发送监控消息
|
||||||
void sendMonitorMessage() async {
|
void sendMonitorMessage() async {
|
||||||
final catEyeConfig = state.keyInfos.value.lockSetting?.catEyeConfig ?? [];
|
final catEyeConfig = state.keyInfos.value.lockSetting?.catEyeConfig ?? [];
|
||||||
@ -909,30 +919,6 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 根据网络质量设置提示信息
|
|
||||||
switch (_networkQualityScore) {
|
|
||||||
case 1:
|
|
||||||
state.networkQualityMessage.value = '很差';
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
state.networkQualityMessage.value = '较差';
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
state.networkQualityMessage.value = '一般';
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
state.networkQualityMessage.value = '良好';
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
state.networkQualityMessage.value = '优秀';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
state.networkQualityMessage.value = '';
|
|
||||||
}
|
|
||||||
// 根据网络质量设置提示信息
|
|
||||||
if (_networkQualityScore < 4) {
|
|
||||||
showToast('网络质量'.tr + ':${state.networkQualityMessage.value}');
|
|
||||||
}
|
|
||||||
if (catEyeConfig.isNotEmpty && catEyeConfig.length > 0 && catEyeConfig[0].catEyeMode != 0) {
|
if (catEyeConfig.isNotEmpty && catEyeConfig.length > 0 && catEyeConfig[0].catEyeMode != 0) {
|
||||||
if (network == null || network?.peerId == null || network?.peerId == '') {
|
if (network == null || network?.peerId == null || network?.peerId == '') {
|
||||||
showToast('设备未配网'.tr);
|
showToast('设备未配网'.tr);
|
||||||
|
|||||||
@ -29,10 +29,10 @@ class ThirdPartyPlatformLogic extends BaseGetXController {
|
|||||||
super.onReady();
|
super.onReady();
|
||||||
await getActivateInfo();
|
await getActivateInfo();
|
||||||
// 恢复之前保存的选中状态
|
// 恢复之前保存的选中状态
|
||||||
final savedIndex = await state.getSavedSelectedPlatformIndex();
|
// final savedIndex = await state.getSavedSelectedPlatformIndex();
|
||||||
if (savedIndex != null && savedIndex < state.platFormSet.length) {
|
// if (savedIndex != null && savedIndex < state.platFormSet.length) {
|
||||||
state.selectPlatFormIndex.value = savedIndex;
|
// state.selectPlatFormIndex.value = savedIndex;
|
||||||
}
|
// }
|
||||||
_initReplySubscription();
|
_initReplySubscription();
|
||||||
await getServerDatetime();
|
await getServerDatetime();
|
||||||
showEasyLoading();
|
showEasyLoading();
|
||||||
@ -215,8 +215,8 @@ class ThirdPartyPlatformLogic extends BaseGetXController {
|
|||||||
if (state.selectPlatFormIndex.value == 1 || state.selectPlatFormIndex.value == 0) {
|
if (state.selectPlatFormIndex.value == 1 || state.selectPlatFormIndex.value == 0) {
|
||||||
if (state.registerKey.isNotEmpty) {
|
if (state.registerKey.isNotEmpty) {
|
||||||
// 持久化保存选项
|
// 持久化保存选项
|
||||||
state.saveSelectedPlatformIndex(state.selectPlatFormIndex.value);
|
// state.saveSelectedPlatformIndex(state.selectPlatFormIndex.value);
|
||||||
_requestAuthorizationCode();
|
// _requestAuthorizationCode();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showToast('目前只支持切换至涂鸦智能、锁通通协议'.tr);
|
showToast('目前只支持切换至涂鸦智能、锁通通协议'.tr);
|
||||||
|
|||||||
@ -35,14 +35,14 @@ class ThirdPartyPlatformState {
|
|||||||
int serverTime = 0; // 服务器时间即UTC+0时间
|
int serverTime = 0; // 服务器时间即UTC+0时间
|
||||||
|
|
||||||
// 存储选中的平台索引
|
// 存储选中的平台索引
|
||||||
static const String _SELECTED_PLATFORM_INDEX_KEY = 'selected_platform_index';
|
// static const String _SELECTED_PLATFORM_INDEX_KEY = 'selected_platform_index';
|
||||||
Future<void> saveSelectedPlatformIndex(int index) async {
|
// Future<void> saveSelectedPlatformIndex(int index) async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
// final prefs = await SharedPreferences.getInstance();
|
||||||
await prefs.setInt(_SELECTED_PLATFORM_INDEX_KEY, index);
|
// await prefs.setInt(_SELECTED_PLATFORM_INDEX_KEY, index);
|
||||||
}
|
// }
|
||||||
// 从本地存储读取选中的平台索引
|
// // 从本地存储读取选中的平台索引
|
||||||
Future<int?> getSavedSelectedPlatformIndex() async {
|
// Future<int?> getSavedSelectedPlatformIndex() async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
// final prefs = await SharedPreferences.getInstance();
|
||||||
return prefs.getInt(_SELECTED_PLATFORM_INDEX_KEY);
|
// return prefs.getInt(_SELECTED_PLATFORM_INDEX_KEY);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user