style:将对讲时的开门调整为使用http
This commit is contained in:
parent
cea20dff00
commit
d2b3ce2a3b
@ -10,6 +10,7 @@ class LockListInfoEntity {
|
|||||||
? LockListInfoGroupEntity.fromJson(json['data'])
|
? LockListInfoGroupEntity.fromJson(json['data'])
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int? errorCode;
|
int? errorCode;
|
||||||
String? description;
|
String? description;
|
||||||
String? errorMsg;
|
String? errorMsg;
|
||||||
@ -43,6 +44,7 @@ class LockListInfoGroupEntity {
|
|||||||
pages = json['pages'];
|
pages = json['pages'];
|
||||||
total = json['total'];
|
total = json['total'];
|
||||||
}
|
}
|
||||||
|
|
||||||
List<GroupList>? groupList;
|
List<GroupList>? groupList;
|
||||||
int? pageNo;
|
int? pageNo;
|
||||||
int? pageSize;
|
int? pageSize;
|
||||||
@ -75,6 +77,7 @@ class GroupList {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String? groupName;
|
String? groupName;
|
||||||
int? groupId;
|
int? groupId;
|
||||||
List<LockListInfoItemEntity>? lockList;
|
List<LockListInfoItemEntity>? lockList;
|
||||||
@ -143,6 +146,7 @@ class LockListInfoItemEntity {
|
|||||||
this.mac,
|
this.mac,
|
||||||
this.initUserNo,
|
this.initUserNo,
|
||||||
this.updateDate,
|
this.updateDate,
|
||||||
|
this.network,
|
||||||
});
|
});
|
||||||
|
|
||||||
LockListInfoItemEntity.fromJson(Map<String, dynamic> json) {
|
LockListInfoItemEntity.fromJson(Map<String, dynamic> json) {
|
||||||
@ -189,7 +193,11 @@ class LockListInfoItemEntity {
|
|||||||
mac = json['mac'];
|
mac = json['mac'];
|
||||||
initUserNo = json['initUserNo'];
|
initUserNo = json['initUserNo'];
|
||||||
updateDate = json['updateDate'];
|
updateDate = json['updateDate'];
|
||||||
|
network = json['network'] != null
|
||||||
|
? NetworkInfo.fromJson(json['network'])
|
||||||
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int? keyId;
|
int? keyId;
|
||||||
int? lockId;
|
int? lockId;
|
||||||
String? lockName;
|
String? lockName;
|
||||||
@ -227,6 +235,7 @@ class LockListInfoItemEntity {
|
|||||||
String? mac;
|
String? mac;
|
||||||
int? initUserNo;
|
int? initUserNo;
|
||||||
int? updateDate;
|
int? updateDate;
|
||||||
|
NetworkInfo? network;
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
final Map<String, dynamic> data = <String, dynamic>{};
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
@ -273,6 +282,9 @@ class LockListInfoItemEntity {
|
|||||||
data['mac'] = mac;
|
data['mac'] = mac;
|
||||||
data['initUserNo'] = initUserNo;
|
data['initUserNo'] = initUserNo;
|
||||||
data['updateDate'] = updateDate;
|
data['updateDate'] = updateDate;
|
||||||
|
if (network != null) {
|
||||||
|
data['network'] = network!.toJson();
|
||||||
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,6 +313,7 @@ class Bluetooth {
|
|||||||
privateKey = json['privateKey'].cast<int>();
|
privateKey = json['privateKey'].cast<int>();
|
||||||
signKey = json['signKey'].cast<int>();
|
signKey = json['signKey'].cast<int>();
|
||||||
}
|
}
|
||||||
|
|
||||||
String? bluetoothDeviceId;
|
String? bluetoothDeviceId;
|
||||||
String? bluetoothDeviceName;
|
String? bluetoothDeviceName;
|
||||||
List<int>? publicKey;
|
List<int>? publicKey;
|
||||||
@ -348,6 +361,7 @@ class LockFeature {
|
|||||||
isSupportBackupBattery = json['isSupportBackupBattery'];
|
isSupportBackupBattery = json['isSupportBackupBattery'];
|
||||||
isNoSupportedBlueBroadcast = json['isNoSupportedBlueBroadcast'];
|
isNoSupportedBlueBroadcast = json['isNoSupportedBlueBroadcast'];
|
||||||
}
|
}
|
||||||
|
|
||||||
int? password;
|
int? password;
|
||||||
int? icCard;
|
int? icCard;
|
||||||
int? fingerprint;
|
int? fingerprint;
|
||||||
@ -391,6 +405,7 @@ class LockSetting {
|
|||||||
appUnlockOnline = json['appUnlockOnline'];
|
appUnlockOnline = json['appUnlockOnline'];
|
||||||
remoteUnlock = json['remoteUnlock'];
|
remoteUnlock = json['remoteUnlock'];
|
||||||
}
|
}
|
||||||
|
|
||||||
int? attendance;
|
int? attendance;
|
||||||
int? appUnlockOnline;
|
int? appUnlockOnline;
|
||||||
int? remoteUnlock;
|
int? remoteUnlock;
|
||||||
@ -403,3 +418,21 @@ class LockSetting {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class NetworkInfo {
|
||||||
|
NetworkInfo({
|
||||||
|
this.peerId,
|
||||||
|
});
|
||||||
|
|
||||||
|
NetworkInfo.fromJson(Map<String, dynamic> json) {
|
||||||
|
peerId = json['peerId'];
|
||||||
|
}
|
||||||
|
|
||||||
|
String? peerId;
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
data['peerId'] = peerId;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
@ -6,6 +5,7 @@ import 'package:flutter/scheduler.dart';
|
|||||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/app_settings/app_settings.dart';
|
import 'package:star_lock/app_settings/app_settings.dart';
|
||||||
|
import 'package:star_lock/talk/starChart/star_chart_manage.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
|
|
||||||
import '../../../blue/blue_manage.dart';
|
import '../../../blue/blue_manage.dart';
|
||||||
@ -32,7 +32,6 @@ class LockListLogic extends BaseGetXController {
|
|||||||
final ShowTipView showTipView = ShowTipView();
|
final ShowTipView showTipView = ShowTipView();
|
||||||
|
|
||||||
List<GroupList> get groupDataList {
|
List<GroupList> get groupDataList {
|
||||||
|
|
||||||
final List<GroupList> list =
|
final List<GroupList> list =
|
||||||
_groupDataList.map((GroupList e) => e.copy()).toList();
|
_groupDataList.map((GroupList e) => e.copy()).toList();
|
||||||
if (state.searchStr.value != '' && state.showSearch.value) {
|
if (state.searchStr.value != '' && state.showSearch.value) {
|
||||||
@ -41,6 +40,20 @@ class LockListLogic extends BaseGetXController {
|
|||||||
!(element.lockAlias?.contains(state.searchStr.value) ?? true));
|
!(element.lockAlias?.contains(state.searchStr.value) ?? true));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (list.length > 0) {
|
||||||
|
StartChartManage().lockListPeerId.clear();
|
||||||
|
list.forEach((element) {
|
||||||
|
final lockList = element.lockList;
|
||||||
|
if (lockList != null && lockList.length > 0) {
|
||||||
|
lockList.forEach((element) {
|
||||||
|
if (element.network?.peerId != null &&
|
||||||
|
element.network?.peerId != '') {
|
||||||
|
StartChartManage().lockListPeerId.add(element);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +155,7 @@ class LockListLogic extends BaseGetXController {
|
|||||||
} else {
|
} else {
|
||||||
return XSConstantMacro.getKeyStatusStr(keyInfo.keyStatus!);
|
return XSConstantMacro.getKeyStatusStr(keyInfo.keyStatus!);
|
||||||
}
|
}
|
||||||
}else if (keyInfo.keyType == XSConstantMacro.keyTypeOnce){
|
} else if (keyInfo.keyType == XSConstantMacro.keyTypeOnce) {
|
||||||
return XSConstantMacro.getKeyStatusStr(keyInfo.keyStatus!);
|
return XSConstantMacro.getKeyStatusStr(keyInfo.keyStatus!);
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
@ -185,11 +198,13 @@ class LockListLogic extends BaseGetXController {
|
|||||||
// 删除锁
|
// 删除锁
|
||||||
AppLog.log('调用了删除锁');
|
AppLog.log('调用了删除锁');
|
||||||
showTipView.resetGetController();
|
showTipView.resetGetController();
|
||||||
showTipView.showTFViewAlertDialog(state.passwordTF, '请输入登录密码'.tr, '请输入登录密码'.tr, checkLoginPassword);
|
showTipView.showTFViewAlertDialog(
|
||||||
|
state.passwordTF, '请输入登录密码'.tr, '请输入登录密码'.tr, checkLoginPassword);
|
||||||
});
|
});
|
||||||
} else if (state.lockListInfoItemEntity.keyRight == 1) {
|
} else if (state.lockListInfoItemEntity.keyRight == 1) {
|
||||||
// 授权管理员弹框提示
|
// 授权管理员弹框提示
|
||||||
showTipView.showDeleteAdministratorIsHaveAllDataDialog('同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (bool a) {
|
showTipView.showDeleteAdministratorIsHaveAllDataDialog(
|
||||||
|
'同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (bool a) {
|
||||||
// 授权管理员删除
|
// 授权管理员删除
|
||||||
state.deleteAdministratorIsHaveAllData.value = a;
|
state.deleteAdministratorIsHaveAllData.value = a;
|
||||||
deletKeyData();
|
deletKeyData();
|
||||||
|
|||||||
@ -22,7 +22,7 @@ class UdpGoOnlineHandler extends ScpMessageBaseHandle
|
|||||||
final responseType = loginResponse.responseType;
|
final responseType = loginResponse.responseType;
|
||||||
if (responseType != null &&
|
if (responseType != null &&
|
||||||
responseType == PayloadTypeConstant.loginSuccessResponse) {
|
responseType == PayloadTypeConstant.loginSuccessResponse) {
|
||||||
startChartManage.isOnlineStartChartServer = true;
|
startChartManage.isOnlineStarChartServer = true;
|
||||||
// 上线成功,停止重发
|
// 上线成功,停止重发
|
||||||
startChartManage.stopReStartOnlineStartChartServer();
|
startChartManage.stopReStartOnlineStartChartServer();
|
||||||
log(text: '星图登录成功,PeerID:${scpMessage.ToPeerId}');
|
log(text: '星图登录成功,PeerID:${scpMessage.ToPeerId}');
|
||||||
|
|||||||
@ -25,7 +25,7 @@ class UdpHeartBeatHandler extends ScpMessageBaseHandle
|
|||||||
// 心跳回复失败,停止发送心跳
|
// 心跳回复失败,停止发送心跳
|
||||||
startChartManage.stopHeartbeat();
|
startChartManage.stopHeartbeat();
|
||||||
// 心跳响应失败,重新上线
|
// 心跳响应失败,重新上线
|
||||||
startChartManage.isOnlineStartChartServer = false;
|
startChartManage.isOnlineStarChartServer = false;
|
||||||
startChartManage.reStartOnlineStartChartServer();
|
startChartManage.reStartOnlineStartChartServer();
|
||||||
} else {
|
} else {
|
||||||
// 修改间隔为返回的心跳间隔
|
// 修改间隔为返回的心跳间隔
|
||||||
|
|||||||
@ -30,6 +30,7 @@ class UdpTalkRequestHandler extends ScpMessageBaseHandle
|
|||||||
final TalkReq talkReq = scpMessage.Payload;
|
final TalkReq talkReq = scpMessage.Payload;
|
||||||
startChartManage.FromPeerId = scpMessage.ToPeerId!;
|
startChartManage.FromPeerId = scpMessage.ToPeerId!;
|
||||||
startChartManage.ToPeerId = scpMessage.FromPeerId!;
|
startChartManage.ToPeerId = scpMessage.FromPeerId!;
|
||||||
|
startChartManage.lockPeerId = scpMessage.FromPeerId!;
|
||||||
// 处理收到接听请求后的事件
|
// 处理收到接听请求后的事件
|
||||||
_talkRequestEvent(talkObjectName: talkReq.callerName);
|
_talkRequestEvent(talkObjectName: talkReq.callerName);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import 'package:star_lock/app_settings/app_settings.dart';
|
|||||||
import 'package:star_lock/flavors.dart';
|
import 'package:star_lock/flavors.dart';
|
||||||
import 'package:star_lock/login/login/entity/LoginData.dart';
|
import 'package:star_lock/login/login/entity/LoginData.dart';
|
||||||
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
||||||
|
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
|
||||||
import 'package:star_lock/network/api_repository.dart';
|
import 'package:star_lock/network/api_repository.dart';
|
||||||
import 'package:star_lock/network/start_chart_api.dart';
|
import 'package:star_lock/network/start_chart_api.dart';
|
||||||
import 'package:star_lock/talk/other/audio_player_manager.dart';
|
import 'package:star_lock/talk/other/audio_player_manager.dart';
|
||||||
@ -79,12 +80,13 @@ class StartChartManage {
|
|||||||
|
|
||||||
String ToPeerId = ''; // 对端ID
|
String ToPeerId = ''; // 对端ID
|
||||||
String FromPeerId = ''; // 我的ID
|
String FromPeerId = ''; // 我的ID
|
||||||
String lockPeerId = '';
|
String lockPeerId = ''; // 锁peerId
|
||||||
|
List<LockListInfoItemEntity> lockListPeerId = []; // 锁列表peerId
|
||||||
|
|
||||||
// echo测试peer对端
|
// echo测试peer对端
|
||||||
final String echoPeerId = '3phX8Ng2cZHz5NtP8xAf6nYy2z1BYytoejgjoHrWMGhH';
|
final String echoPeerId = '3phX8Ng2cZHz5NtP8xAf6nYy2z1BYytoejgjoHrWMGhH';
|
||||||
|
|
||||||
bool isOnlineStartChartServer = false; // 星图是否上线成功
|
bool isOnlineStarChartServer = false; // 星图是否上线成功
|
||||||
Timer? reStartOnlineStartChartServerTimer; // 重新上线定时器
|
Timer? reStartOnlineStartChartServerTimer; // 重新上线定时器
|
||||||
Timer? talkPingTimer; // 发送通话保持消息定时器
|
Timer? talkPingTimer; // 发送通话保持消息定时器
|
||||||
Timer? talkExpectTimer; // 发送通话预期消息定时器
|
Timer? talkExpectTimer; // 发送通话预期消息定时器
|
||||||
@ -119,7 +121,7 @@ class StartChartManage {
|
|||||||
// 判断是否登录账户
|
// 判断是否登录账户
|
||||||
final loginData = await Storage.getLoginData();
|
final loginData = await Storage.getLoginData();
|
||||||
|
|
||||||
if ((isOnlineStartChartServer && _udpSocket != null) || loginData == null) {
|
if ((isOnlineStarChartServer && _udpSocket != null) || loginData == null) {
|
||||||
// 如果已经上线就不进行初始化
|
// 如果已经上线就不进行初始化
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -391,7 +393,7 @@ class StartChartManage {
|
|||||||
|
|
||||||
// 发送上线消息
|
// 发送上线消息
|
||||||
Future<void> _sendOnlineMessage() async {
|
Future<void> _sendOnlineMessage() async {
|
||||||
if (isOnlineStartChartServer) {
|
if (isOnlineStarChartServer) {
|
||||||
_log(text: '星图已上线,请勿重复发送上线消息');
|
_log(text: '星图已上线,请勿重复发送上线消息');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -670,7 +672,7 @@ class StartChartManage {
|
|||||||
|
|
||||||
// 重新上线
|
// 重新上线
|
||||||
Future<void> reStartOnlineStartChartServer() async {
|
Future<void> reStartOnlineStartChartServer() async {
|
||||||
if (isOnlineStartChartServer) {
|
if (isOnlineStarChartServer) {
|
||||||
_log(text: '星图已上线,请勿重复发送上线消息');
|
_log(text: '星图已上线,请勿重复发送上线消息');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -714,17 +716,16 @@ class StartChartManage {
|
|||||||
// _udpSocket = null;
|
// _udpSocket = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// print('发送消息');
|
|
||||||
//ToDo: 增加对讲调试、正式可删除
|
//ToDo: 增加对讲调试、正式可删除
|
||||||
UdpTalkDataHandler().updateSendDataRate(message.length);
|
// UdpTalkDataHandler().updateSendDataRate(message.length);
|
||||||
|
//
|
||||||
// 更新调试信息
|
// // 更新调试信息
|
||||||
Provider.of<DebugInfoModel>(Get.context!, listen: false).updateDebugInfo(
|
// Provider.of<DebugInfoModel>(Get.context!, listen: false).updateDebugInfo(
|
||||||
UdpTalkDataHandler().getLastRecvDataRate() ~/ 1024, // 转换为KB
|
// UdpTalkDataHandler().getLastRecvDataRate() ~/ 1024, // 转换为KB
|
||||||
UdpTalkDataHandler().getLastRecvPacketCount(),
|
// UdpTalkDataHandler().getLastRecvPacketCount(),
|
||||||
UdpTalkDataHandler().getLastSendDataRate() ~/ 1024, // 转换为KB
|
// UdpTalkDataHandler().getLastSendDataRate() ~/ 1024, // 转换为KB
|
||||||
UdpTalkDataHandler().getLastSendPacketCount(),
|
// UdpTalkDataHandler().getLastSendPacketCount(),
|
||||||
);
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送消息
|
// 发送消息
|
||||||
@ -1101,9 +1102,10 @@ class StartChartManage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 销毁资源
|
/// 销毁资源
|
||||||
Future<void> destruction() async {
|
void destruction() async {
|
||||||
// sendTalkHangupMessage();
|
// 发送挂断消息
|
||||||
isOnlineStartChartServer = false;
|
sendTalkHangupMessage();
|
||||||
|
isOnlineStarChartServer = false;
|
||||||
// 停止发送心跳消息
|
// 停止发送心跳消息
|
||||||
stopHeartbeat();
|
stopHeartbeat();
|
||||||
// 取消发送期望数据
|
// 取消发送期望数据
|
||||||
@ -1120,8 +1122,12 @@ class StartChartManage {
|
|||||||
stopSendingRbcuConfirmMessages();
|
stopSendingRbcuConfirmMessages();
|
||||||
// 重置数据
|
// 重置数据
|
||||||
_resetData();
|
_resetData();
|
||||||
|
// 删除中继缓存信息
|
||||||
await Storage.removerRelayInfo();
|
await Storage.removerRelayInfo();
|
||||||
|
// 删除注册节点信息
|
||||||
await Storage.removerStarChartRegisterNodeInfo();
|
await Storage.removerStarChartRegisterNodeInfo();
|
||||||
|
// 关闭udp服务
|
||||||
|
closeUdpSocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 重置数据
|
/// 重置数据
|
||||||
@ -1130,6 +1136,7 @@ class StartChartManage {
|
|||||||
videoType: [VideoTypeE.IMAGE],
|
videoType: [VideoTypeE.IMAGE],
|
||||||
audioType: [AudioTypeE.G711],
|
audioType: [AudioTypeE.G711],
|
||||||
);
|
);
|
||||||
isOnlineStartChartServer = false;
|
isOnlineStarChartServer = false;
|
||||||
|
talkStatus.setUninitialized();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,9 +21,12 @@ import 'package:star_lock/app_settings/app_settings.dart';
|
|||||||
import 'package:star_lock/blue/blue_manage.dart';
|
import 'package:star_lock/blue/blue_manage.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_openLock.dart';
|
import 'package:star_lock/blue/io_protocol/io_openLock.dart';
|
||||||
import 'package:star_lock/blue/io_tool/io_tool.dart';
|
import 'package:star_lock/blue/io_tool/io_tool.dart';
|
||||||
|
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
||||||
import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_logic.dart';
|
import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_logic.dart';
|
||||||
import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_state.dart';
|
import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_state.dart';
|
||||||
import 'package:star_lock/main/lockDetail/lockDetail/lockNetToken_entity.dart';
|
import 'package:star_lock/main/lockDetail/lockDetail/lockNetToken_entity.dart';
|
||||||
|
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
|
||||||
|
import 'package:star_lock/main/lockMian/lockList/lockList_logic.dart';
|
||||||
import 'package:star_lock/network/api_repository.dart';
|
import 'package:star_lock/network/api_repository.dart';
|
||||||
import 'package:star_lock/talk/call/g711.dart';
|
import 'package:star_lock/talk/call/g711.dart';
|
||||||
import 'package:star_lock/talk/starChart/constant/talk_status.dart';
|
import 'package:star_lock/talk/starChart/constant/talk_status.dart';
|
||||||
@ -98,8 +101,6 @@ class TalkViewLogic extends BaseGetXController {
|
|||||||
state.videoBuffer.removeAt(0); // 丢弃最旧的数据
|
state.videoBuffer.removeAt(0); // 丢弃最旧的数据
|
||||||
}
|
}
|
||||||
state.videoBuffer.add(talkData); // 添加新数据
|
state.videoBuffer.add(talkData); // 添加新数据
|
||||||
/// 更新网络状态
|
|
||||||
// updateNetworkStatus(currentTimestamp);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -233,36 +234,6 @@ class TalkViewLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 修改网络状态
|
|
||||||
void updateNetworkStatus(int currentTimestamp) {
|
|
||||||
if (state.lastFrameTimestamp.value != 0) {
|
|
||||||
final frameInterval = currentTimestamp - state.lastFrameTimestamp.value;
|
|
||||||
if (frameInterval > 500 && frameInterval <= 1000) {
|
|
||||||
// 判断帧间隔是否在500毫秒到1秒之间
|
|
||||||
state.networkStatus.value = NetworkStatus.lagging;
|
|
||||||
// showNetworkStatus("Network is lagging");
|
|
||||||
} else if (frameInterval > 1000) {
|
|
||||||
// 判断帧间隔是否超过1秒
|
|
||||||
state.networkStatus.value = NetworkStatus.delayed;
|
|
||||||
// showNetworkStatus("Network is delayed");
|
|
||||||
} else {
|
|
||||||
state.networkStatus.value = NetworkStatus.normal;
|
|
||||||
state.alertCount.value = 0; // 重置计数器
|
|
||||||
}
|
|
||||||
}
|
|
||||||
state.lastFrameTimestamp.value = currentTimestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 提示网络状态
|
|
||||||
void showNetworkStatus(String message) {
|
|
||||||
// 如果提示次数未达到最大值且 EasyLoading 未显示,则显示提示
|
|
||||||
if (state.alertCount.value < state.maxAlertNumber.value &&
|
|
||||||
!EasyLoading.isShow) {
|
|
||||||
showToast(message);
|
|
||||||
state.alertCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 停止播放音频
|
/// 停止播放音频
|
||||||
void _stopPlayG711Data() async {
|
void _stopPlayG711Data() async {
|
||||||
await FlutterPcmSound.pause();
|
await FlutterPcmSound.pause();
|
||||||
@ -271,44 +242,44 @@ class TalkViewLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 开门
|
/// 开门
|
||||||
udpOpenDoorAction() async {
|
// udpOpenDoorAction() async {
|
||||||
final List<String>? privateKey =
|
// final List<String>? privateKey =
|
||||||
await Storage.getStringList(saveBluePrivateKey);
|
// await Storage.getStringList(saveBluePrivateKey);
|
||||||
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
// final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
|
//
|
||||||
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
|
// final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
|
||||||
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
// final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||||
|
//
|
||||||
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
// final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||||
final List<int> getTokenList = changeStringListToIntList(token!);
|
// final List<int> getTokenList = changeStringListToIntList(token!);
|
||||||
|
//
|
||||||
await _getLockNetToken();
|
// await _getLockNetToken();
|
||||||
|
//
|
||||||
final OpenLockCommand openLockCommand = OpenLockCommand(
|
// final OpenLockCommand openLockCommand = OpenLockCommand(
|
||||||
lockID: BlueManage().connectDeviceName,
|
// lockID: BlueManage().connectDeviceName,
|
||||||
userID: await Storage.getUid(),
|
// userID: await Storage.getUid(),
|
||||||
openMode: lockDetailState.openDoorModel,
|
// openMode: lockDetailState.openDoorModel,
|
||||||
openTime: _getUTCNetTime(),
|
// openTime: _getUTCNetTime(),
|
||||||
onlineToken: lockDetailState.lockNetToken,
|
// onlineToken: lockDetailState.lockNetToken,
|
||||||
token: getTokenList,
|
// token: getTokenList,
|
||||||
needAuthor: 1,
|
// needAuthor: 1,
|
||||||
signKey: signKeyDataList,
|
// signKey: signKeyDataList,
|
||||||
privateKey: getPrivateKeyList,
|
// privateKey: getPrivateKeyList,
|
||||||
);
|
// );
|
||||||
final messageDetail = openLockCommand.packageData();
|
// final messageDetail = openLockCommand.packageData();
|
||||||
// 将 List<int> 转换为十六进制字符串
|
// // 将 List<int> 转换为十六进制字符串
|
||||||
String hexString = messageDetail
|
// String hexString = messageDetail
|
||||||
.map((byte) => byte.toRadixString(16).padLeft(2, '0'))
|
// .map((byte) => byte.toRadixString(16).padLeft(2, '0'))
|
||||||
.join(' ');
|
// .join(' ');
|
||||||
|
//
|
||||||
AppLog.log('open lock hexString: $hexString');
|
// AppLog.log('open lock hexString: $hexString');
|
||||||
// 发送远程开门消息
|
// // 发送远程开门消息
|
||||||
StartChartManage().sendRemoteUnLockMessage(
|
// StartChartManage().sendRemoteUnLockMessage(
|
||||||
bluetoothDeviceName: BlueManage().connectDeviceName,
|
// bluetoothDeviceName: BlueManage().connectDeviceName,
|
||||||
openLockCommand: messageDetail,
|
// openLockCommand: messageDetail,
|
||||||
);
|
// );
|
||||||
showToast('正在开锁中...'.tr);
|
// showToast('正在开锁中...'.tr);
|
||||||
}
|
// }
|
||||||
|
|
||||||
int _getUTCNetTime() {
|
int _getUTCNetTime() {
|
||||||
if (lockDetailState.isHaveNetwork) {
|
if (lockDetailState.isHaveNetwork) {
|
||||||
@ -524,6 +495,34 @@ class TalkViewLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 远程开锁
|
||||||
|
Future<void> remoteOpenLock() async {
|
||||||
|
final lockPeerId = StartChartManage().lockPeerId;
|
||||||
|
final lockListPeerId = StartChartManage().lockListPeerId;
|
||||||
|
int lockId = 0;
|
||||||
|
if (lockListPeerId.length == 0) {
|
||||||
|
// 如果锁列表没有获取到peerId,代表只有一个锁,直接使用锁详情的lockId
|
||||||
|
lockId = lockDetailState.keyInfos.value.lockId ?? 0;
|
||||||
|
} else {
|
||||||
|
// 如果锁列表获取到peerId,代表有多个锁,使用锁列表的peerId
|
||||||
|
// 从列表中遍历出对应的peerId
|
||||||
|
lockId = lockListPeerId
|
||||||
|
.firstWhere(
|
||||||
|
(element) => element.network?.peerId == lockPeerId,
|
||||||
|
orElse: () => LockListInfoItemEntity(), // 如果没有找到,返回 null
|
||||||
|
)
|
||||||
|
?.lockId ??
|
||||||
|
0;
|
||||||
|
}
|
||||||
|
if (lockPeerId.isNotEmpty) {}
|
||||||
|
final LoginEntity entity = await ApiRepository.to
|
||||||
|
.remoteOpenLock(lockId: lockId.toString(), timeOut: 60);
|
||||||
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
|
showToast('已开锁'.tr);
|
||||||
|
StartChartManage().lockListPeerId = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// 初始化音频录制器
|
/// 初始化音频录制器
|
||||||
void _initAudioRecorder() {
|
void _initAudioRecorder() {
|
||||||
state.voiceProcessor = VoiceProcessor.instance;
|
state.voiceProcessor = VoiceProcessor.instance;
|
||||||
|
|||||||
@ -56,31 +56,31 @@ class _TalkViewPageState extends State<TalkViewPage>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
_latencyStream = measureServerLatencyStream(F.apiPrefix); // 替换为你的服务器地址
|
// _latencyStream = measureServerLatencyStream(F.apiPrefix); // 替换为你的服务器地址
|
||||||
}
|
|
||||||
|
|
||||||
Stream<int> measureServerLatencyStream(String url) async* {
|
|
||||||
while (true) {
|
|
||||||
final latency = await measureServerLatency(url);
|
|
||||||
yield latency;
|
|
||||||
await Future.delayed(Duration(seconds: 1)); // 每秒测量一次
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<int> measureServerLatency(String url) async {
|
|
||||||
final Stopwatch stopwatch = Stopwatch()..start();
|
|
||||||
try {
|
|
||||||
final http.Response response = await http.get(Uri.parse(url));
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
stopwatch.stop();
|
|
||||||
return stopwatch.elapsedMilliseconds;
|
|
||||||
} else {
|
|
||||||
return -1; // 表示请求失败
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
return -1; // 表示请求失败
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
// Stream<int> measureServerLatencyStream(String url) async* {
|
||||||
|
// while (true) {
|
||||||
|
// final latency = await measureServerLatency(url);
|
||||||
|
// yield latency;
|
||||||
|
// await Future.delayed(Duration(seconds: 1)); // 每秒测量一次
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Future<int> measureServerLatency(String url) async {
|
||||||
|
// final Stopwatch stopwatch = Stopwatch()..start();
|
||||||
|
// try {
|
||||||
|
// final http.Response response = await http.get(Uri.parse(url));
|
||||||
|
// if (response.statusCode == 200) {
|
||||||
|
// stopwatch.stop();
|
||||||
|
// return stopwatch.elapsedMilliseconds;
|
||||||
|
// } else {
|
||||||
|
// return -1; // 表示请求失败
|
||||||
|
// }
|
||||||
|
// } catch (e) {
|
||||||
|
// return -1; // 表示请求失败
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -255,40 +255,40 @@ class _TalkViewPageState extends State<TalkViewPage>
|
|||||||
)
|
)
|
||||||
: Container()),
|
: Container()),
|
||||||
//ToDo: 增加对讲调试、正式可删除
|
//ToDo: 增加对讲调试、正式可删除
|
||||||
// Visibility(
|
Visibility(
|
||||||
// visible: true,
|
visible: true,
|
||||||
// child: Positioned(
|
child: Positioned(
|
||||||
// top: 20, // 设置在顶部
|
top: 20, // 设置在顶部
|
||||||
// left: 20,
|
left: 20,
|
||||||
// right: 20, // 确保调试信息在屏幕宽度内居中
|
right: 20, // 确保调试信息在屏幕宽度内居中
|
||||||
// child: Container(
|
child: Container(
|
||||||
// height: 100, // 设置高度为 100
|
height: 100, // 设置高度为 100
|
||||||
// color: Colors.black.withOpacity(0.5), // 可选:设置背景颜色和透明度
|
color: Colors.black.withOpacity(0.5), // 可选:设置背景颜色和透明度
|
||||||
// padding: const EdgeInsets.all(10), // 可选:设置内边距
|
padding: const EdgeInsets.all(10), // 可选:设置内边距
|
||||||
// child: Consumer<DebugInfoModel>(
|
child: Consumer<DebugInfoModel>(
|
||||||
// builder: (BuildContext context, DebugInfoModel debugInfo,
|
builder: (BuildContext context, DebugInfoModel debugInfo,
|
||||||
// Widget? child) {
|
Widget? child) {
|
||||||
// return Column(
|
return Column(
|
||||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
// children: <Widget>[
|
children: <Widget>[
|
||||||
// Text(
|
Text(
|
||||||
// 'recv ${debugInfo.recvDataRate}KB/s [${debugInfo.recvPacketCount}]',
|
'recv ${debugInfo.recvDataRate}KB/s [${debugInfo.recvPacketCount}]',
|
||||||
// style: const TextStyle(
|
style: const TextStyle(
|
||||||
// color: Colors.white), // 设置文本颜色为白色
|
color: Colors.white), // 设置文本颜色为白色
|
||||||
// ),
|
),
|
||||||
// Text(
|
Text(
|
||||||
// 'send ${debugInfo.sendDataRate}KB/s [${debugInfo.sendPacketCount}]',
|
'send ${debugInfo.sendDataRate}KB/s [${debugInfo.sendPacketCount}]',
|
||||||
// style: const TextStyle(
|
style: const TextStyle(
|
||||||
// color: Colors.white), // 设置文本颜色为白色
|
color: Colors.white), // 设置文本颜色为白色
|
||||||
// ),
|
),
|
||||||
// ],
|
],
|
||||||
// );
|
);
|
||||||
// },
|
},
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
// // 添加服务器延迟检测
|
// 添加服务器延迟检测
|
||||||
// Positioned(
|
// Positioned(
|
||||||
// top: 120,
|
// top: 120,
|
||||||
// left: 20,
|
// left: 20,
|
||||||
@ -455,10 +455,11 @@ class _TalkViewPageState extends State<TalkViewPage>
|
|||||||
'开锁'.tr,
|
'开锁'.tr,
|
||||||
AppColors.mainColor,
|
AppColors.mainColor,
|
||||||
onClick: () {
|
onClick: () {
|
||||||
if (state.talkStatus.value == TalkStatus.answeredSuccessfully &&
|
// if (state.talkStatus.value == TalkStatus.answeredSuccessfully &&
|
||||||
state.listData.value.length > 0) {
|
// state.listData.value.length > 0) {
|
||||||
logic.udpOpenDoorAction();
|
// logic.udpOpenDoorAction();
|
||||||
}
|
logic.remoteOpenLock();
|
||||||
|
// }
|
||||||
// if (UDPManage().remoteUnlock == 1) {
|
// if (UDPManage().remoteUnlock == 1) {
|
||||||
// logic.udpOpenDoorAction();
|
// logic.udpOpenDoorAction();
|
||||||
// showDeletPasswordAlertDialog(context);
|
// showDeletPasswordAlertDialog(context);
|
||||||
@ -534,46 +535,46 @@ class _TalkViewPageState extends State<TalkViewPage>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showDeletPasswordAlertDialog(BuildContext context) {
|
// void showDeletPasswordAlertDialog(BuildContext context) {
|
||||||
showDialog(
|
// showDialog(
|
||||||
barrierDismissible: false,
|
// barrierDismissible: false,
|
||||||
context: context,
|
// context: context,
|
||||||
builder: (BuildContext context) {
|
// builder: (BuildContext context) {
|
||||||
return ShowTFView(
|
// return ShowTFView(
|
||||||
title: '请输入6位数字开锁密码'.tr,
|
// title: '请输入6位数字开锁密码'.tr,
|
||||||
tipTitle: '',
|
// tipTitle: '',
|
||||||
controller: state.passwordTF,
|
// controller: state.passwordTF,
|
||||||
inputFormatters: <TextInputFormatter>[
|
// inputFormatters: <TextInputFormatter>[
|
||||||
LengthLimitingTextInputFormatter(6), //限制长度
|
// LengthLimitingTextInputFormatter(6), //限制长度
|
||||||
FilteringTextInputFormatter.allow(RegExp('[0-9]')),
|
// FilteringTextInputFormatter.allow(RegExp('[0-9]')),
|
||||||
],
|
// ],
|
||||||
sureClick: () async {
|
// sureClick: () async {
|
||||||
//发送删除锁请求
|
// //发送删除锁请求
|
||||||
// if (state.passwordTF.text.isEmpty) {
|
// // if (state.passwordTF.text.isEmpty) {
|
||||||
// logic.showToast('请输入开锁密码'.tr);
|
// // logic.showToast('请输入开锁密码'.tr);
|
||||||
// return;
|
// // return;
|
||||||
|
// // }
|
||||||
|
//
|
||||||
|
// // List<int> numbers = state.passwordTF.text.split('').map((char) => int.parse(char)).toList();
|
||||||
|
// // 开锁
|
||||||
|
// // lockID
|
||||||
|
// // final List<int> numbers = <int>[];
|
||||||
|
// // final List<int> lockIDData = utf8.encode(state.passwordTF.text);
|
||||||
|
// // numbers.addAll(lockIDData);
|
||||||
|
// // // topBytes = getFixedLengthList(lockIDData, 20 - lockIDData.length);
|
||||||
|
// // for (int i = 0; i < 6 - lockIDData.length; i++) {
|
||||||
|
// // numbers.add(0);
|
||||||
|
// // }
|
||||||
|
// // logic.udpOpenDoorAction();
|
||||||
|
// },
|
||||||
|
// cancelClick: () {
|
||||||
|
// Get.back();
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// );
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// List<int> numbers = state.passwordTF.text.split('').map((char) => int.parse(char)).toList();
|
|
||||||
// 开锁
|
|
||||||
// lockID
|
|
||||||
// final List<int> numbers = <int>[];
|
|
||||||
// final List<int> lockIDData = utf8.encode(state.passwordTF.text);
|
|
||||||
// numbers.addAll(lockIDData);
|
|
||||||
// // topBytes = getFixedLengthList(lockIDData, 20 - lockIDData.length);
|
|
||||||
// for (int i = 0; i < 6 - lockIDData.length; i++) {
|
|
||||||
// numbers.add(0);
|
|
||||||
// }
|
|
||||||
logic.udpOpenDoorAction();
|
|
||||||
},
|
|
||||||
cancelClick: () {
|
|
||||||
Get.back();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
//旋转动画
|
//旋转动画
|
||||||
Widget buildRotationTransition() {
|
Widget buildRotationTransition() {
|
||||||
return Positioned(
|
return Positioned(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user