Merge branch 'develop_liyi' of code-internal.star-lock.cn:StarlockTeam/app-starlock into develop_liyi
This commit is contained in:
commit
d5ac3ebf3e
@ -35,7 +35,6 @@ abstract class SenderProtocol extends IOData {
|
||||
void printLog(List<int> data) {
|
||||
AppLog.log(
|
||||
"App -> 锁,指令类型:${commandType!.typeName} ${commandType!.typeValue == 0x3030 ? '子命令:${data[3]}' : ''} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}");
|
||||
AppLog.log("子命令数据是:${data.sublist(66, 79)}");
|
||||
}
|
||||
|
||||
// 拼装数据
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_entity.dart';
|
||||
import 'package:star_lock/talk/starChart/entity/star_chart_register_node_entity.dart';
|
||||
|
||||
class LoginData {
|
||||
LoginData(
|
||||
@ -63,4 +64,13 @@ class LoginData {
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
void updateStarchart(
|
||||
StarChartRegisterNodeEntity starChartRegisterNodeEntity) {
|
||||
starchart = Starchart(
|
||||
starchartId: starChartRegisterNodeEntity.peer?.id,
|
||||
starchartPeerPublicKey: starChartRegisterNodeEntity.peer?.publicKey,
|
||||
starchartPeerPrivateKey: starChartRegisterNodeEntity.peer?.privateKey,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,17 +58,22 @@ class StarLockLoginLogic extends BaseGetXController {
|
||||
'login_res': '成功',
|
||||
});
|
||||
|
||||
Storage.saveLoginData(entity.data);
|
||||
Storage.setBool(saveIsVip, entity.data!.isVip == 1);
|
||||
//如已有星图配置则保存 无需重复注册节点及重复绑定
|
||||
if (entity.data!.starchart != null) {
|
||||
final Starchart starChart = entity.data!.starchart!;
|
||||
Storage.saveStarChartRegisterNodeInfo(StarChartRegisterNodeEntity(
|
||||
peer: PeerData(
|
||||
id: starChart.starchartId,
|
||||
publicKey: starChart.starchartPeerPublicKey,
|
||||
privateKey: starChart.starchartPeerPrivateKey)));
|
||||
final StarChartRegisterNodeEntity starChartRegisterNodeEntity =
|
||||
StarChartRegisterNodeEntity(
|
||||
peer: PeerData(
|
||||
id: starChart.starchartId,
|
||||
publicKey: starChart.starchartPeerPublicKey,
|
||||
privateKey: starChart.starchartPeerPrivateKey,
|
||||
),
|
||||
);
|
||||
Storage.saveStarChartRegisterNodeInfo(starChartRegisterNodeEntity);
|
||||
entity.data!.updateStarchart(starChartRegisterNodeEntity);
|
||||
}
|
||||
Storage.saveLoginData(entity.data);
|
||||
Storage.setBool(saveIsVip, entity.data!.isVip == 1);
|
||||
eventBus.fire(MineInfoChangeRefreshUI());
|
||||
if (Get.isRegistered<LockMainLogic>()) {
|
||||
Get.find<LockMainLogic>().getStarLockInfo(isUnShowLoading: true);
|
||||
|
||||
@ -10,6 +10,7 @@ import 'package:star_lock/apm/apm_helper.dart';
|
||||
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
||||
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockDetail/device_network_info.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockSet/lockTime/getServerDatetime_entity.dart';
|
||||
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
|
||||
import 'package:star_lock/talk/starChart/constant/talk_status.dart';
|
||||
@ -744,12 +745,40 @@ class LockDetailLogic extends BaseGetXController {
|
||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||
}
|
||||
|
||||
/// 请求设备网络信息并设置
|
||||
void _requestDeviceNetworkInfo() async {
|
||||
final DeviceNetwork deviceNetworkInfo =
|
||||
await ApiRepository.to.getDeviceNetwork(
|
||||
deviceType: 2,
|
||||
deviceMac: state.keyInfos.value.mac!,
|
||||
);
|
||||
if (deviceNetworkInfo.data?.wifiName == null ||
|
||||
deviceNetworkInfo.data?.wifiName == '') {
|
||||
return;
|
||||
} else {
|
||||
final peerId = deviceNetworkInfo?.data?.peerId;
|
||||
if (peerId == null || peerId.isEmpty || peerId == '') {
|
||||
throw Exception('设备peerId为空');
|
||||
}
|
||||
// 设置锁的peerID
|
||||
StartChartManage().lockPeerId = peerId;
|
||||
}
|
||||
}
|
||||
|
||||
/// 发送监控消息
|
||||
void sendMonitorMessage() {
|
||||
// 发送监控id
|
||||
StartChartManage().startCallRequestMessageTimer(
|
||||
ToPeerId: StartChartManage().lockPeerId ?? '');
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onReady() async {
|
||||
super.onReady();
|
||||
getServerDatetime();
|
||||
await PermissionDialog.request(Permission.location);
|
||||
await PermissionDialog.requestBluetooth();
|
||||
_requestDeviceNetworkInfo();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -68,7 +68,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
lockListInfoItemEntity: widget.lockListInfoItemEntity,
|
||||
isOnlyOneData: widget.isOnlyOneData);
|
||||
|
||||
_handleLockMonitor2();
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
@ -1164,7 +1164,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
showWidgetArr.add(
|
||||
bottomItem('images/main/icon_catEyes.png', '监控'.tr,
|
||||
state.bottomBtnisEable.value, () async {
|
||||
await _handleLockMonitor();
|
||||
logic.sendMonitorMessage();
|
||||
}),
|
||||
);
|
||||
}
|
||||
@ -1572,36 +1572,4 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
BlueManage().disconnect();
|
||||
}
|
||||
|
||||
Future<void> _handleLockMonitor2() async {
|
||||
final lockId = state.keyInfos.value.lockId;
|
||||
final LockSetInfoEntity entity =
|
||||
await ApiRepository.to.getLockSettingInfoData(
|
||||
lockId: lockId.toString(),
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
final LockSetInfoData data = entity.data!;
|
||||
final mac = data.lockBasicInfo?.mac;
|
||||
if (mac != null && mac.isNotEmpty) {
|
||||
final DeviceNetwork deviceNetworkInfo = await ApiRepository.to
|
||||
.getDeviceNetwork(deviceType: 2, deviceMac: mac);
|
||||
if (deviceNetworkInfo.data?.wifiName == null ||
|
||||
deviceNetworkInfo.data?.wifiName == '') {
|
||||
return;
|
||||
} else {
|
||||
final peerId = deviceNetworkInfo?.data?.peerId;
|
||||
if (peerId == null || peerId.isEmpty || peerId == '') {
|
||||
throw Exception('设备peerId为空');
|
||||
}
|
||||
// 设置锁的peerID
|
||||
StartChartManage().lockPeerId = peerId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _handleLockMonitor() async {
|
||||
// 发送监控id
|
||||
StartChartManage().startCallRequestMessageTimer(
|
||||
ToPeerId: StartChartManage().lockPeerId ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
@ -313,7 +313,7 @@ class LockMainLogic extends BaseGetXController {
|
||||
|
||||
// 开启UDP
|
||||
// AppLog.log('onReady() LockMainLogic');
|
||||
UdpHelp().openUDP();
|
||||
// UdpHelp().openUDP();
|
||||
BlueManage();
|
||||
}
|
||||
|
||||
|
||||
@ -53,9 +53,11 @@ class LockMainXHJLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
if (entity.data!.starchart != null) {
|
||||
if (entity.data!.starchart!.starchartId!.isEmpty) {
|
||||
if (entity.data!.starchart!.starchartId == null) {
|
||||
bindStarChart();
|
||||
}
|
||||
} else {
|
||||
StartChartManage().init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ class MineSetLogic extends BaseGetXController {
|
||||
'logout_result': '成功',
|
||||
});
|
||||
|
||||
UdpHelp().closeUDP();
|
||||
// UdpHelp().closeUDP();
|
||||
logOut();
|
||||
|
||||
StoreService.to.saveLanguageCode('');
|
||||
|
||||
@ -146,23 +146,23 @@ class StartChartManage {
|
||||
await _requestStarChartRegisterNode();
|
||||
await _saveStarChartRegisterNodeToStorage(requestStarChartRegisterNode);
|
||||
FromPeerId = requestStarChartRegisterNode.peer!.id ?? '';
|
||||
bindUserStarchart();
|
||||
bindUserStarchart(requestStarChartRegisterNode);
|
||||
}
|
||||
}
|
||||
|
||||
//绑定星图配置
|
||||
Future<void> bindUserStarchart() async {
|
||||
Future<void> bindUserStarchart(
|
||||
StarChartRegisterNodeEntity requestStarChartRegisterNode) async {
|
||||
try {
|
||||
final StarChartRegisterNodeEntity? registerNodeEntity =
|
||||
await Storage.getStarChartRegisterNodeInfo();
|
||||
|
||||
final LoginEntity entity = await ApiRepository.to.bindUserStarchart(
|
||||
starchartId: registerNodeEntity?.peer?.id ?? '',
|
||||
starchartPeerPublicKey: registerNodeEntity?.peer?.publicKey ?? '',
|
||||
starchartPeerPrivateKey: registerNodeEntity?.peer?.privateKey ?? '',
|
||||
starchartId: requestStarChartRegisterNode.peer?.id ?? '',
|
||||
starchartPeerPublicKey:
|
||||
requestStarChartRegisterNode.peer?.publicKey ?? '',
|
||||
starchartPeerPrivateKey:
|
||||
requestStarChartRegisterNode.peer?.privateKey ?? '',
|
||||
);
|
||||
registerNodeEntity?.peer?.id = entity.data?.starchart?.starchartId;
|
||||
await Storage.saveStarChartRegisterNodeInfo(registerNodeEntity!);
|
||||
requestStarChartRegisterNode.peer?.id =
|
||||
entity.data?.starchart?.starchartId;
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
AppLog.log('绑定成功');
|
||||
} else {
|
||||
@ -762,6 +762,9 @@ class StartChartManage {
|
||||
StarChartRegisterNodeEntity starChartRegisterNodeEntity) async {
|
||||
if (starChartRegisterNodeEntity != null) {
|
||||
await Storage.saveStarChartRegisterNodeInfo(starChartRegisterNodeEntity);
|
||||
final LoginData? loginData = await Storage.getLoginData();
|
||||
loginData?.updateStarchart(starChartRegisterNodeEntity);
|
||||
Storage.saveLoginData(loginData);
|
||||
}
|
||||
}
|
||||
|
||||
@ -779,9 +782,9 @@ class StartChartManage {
|
||||
final RelayInfoEntity? relayInfoEntity = await Storage.getRelayInfo();
|
||||
|
||||
// 获取公钥
|
||||
final publicKey = await getPublicKey();
|
||||
final String publicKey = await getPublicKey();
|
||||
// 获取私钥
|
||||
final privateKey = await getPrivateKey();
|
||||
final String privateKey = await getPrivateKey();
|
||||
// 生成签名
|
||||
final sign = await DoSign().generateSign(
|
||||
currentTimestamp: relayInfoEntity!.time ?? 0,
|
||||
|
||||
@ -255,39 +255,39 @@ class _TalkViewPageState extends State<TalkViewPage>
|
||||
)
|
||||
: Container()),
|
||||
//ToDo: 增加对讲调试、正式可删除
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: Positioned(
|
||||
top: 20, // 设置在顶部
|
||||
left: 20,
|
||||
right: 20, // 确保调试信息在屏幕宽度内居中
|
||||
child: Container(
|
||||
height: 100, // 设置高度为 100
|
||||
color: Colors.black.withOpacity(0.5), // 可选:设置背景颜色和透明度
|
||||
padding: const EdgeInsets.all(10), // 可选:设置内边距
|
||||
child: Consumer<DebugInfoModel>(
|
||||
builder: (BuildContext context, DebugInfoModel debugInfo,
|
||||
Widget? child) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'recv ${debugInfo.recvDataRate}KB/s [${debugInfo.recvPacketCount}]',
|
||||
style: const TextStyle(
|
||||
color: Colors.white), // 设置文本颜色为白色
|
||||
),
|
||||
Text(
|
||||
'send ${debugInfo.sendDataRate}KB/s [${debugInfo.sendPacketCount}]',
|
||||
style: const TextStyle(
|
||||
color: Colors.white), // 设置文本颜色为白色
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Visibility(
|
||||
// visible: true,
|
||||
// child: Positioned(
|
||||
// top: 20, // 设置在顶部
|
||||
// left: 20,
|
||||
// right: 20, // 确保调试信息在屏幕宽度内居中
|
||||
// child: Container(
|
||||
// height: 100, // 设置高度为 100
|
||||
// color: Colors.black.withOpacity(0.5), // 可选:设置背景颜色和透明度
|
||||
// padding: const EdgeInsets.all(10), // 可选:设置内边距
|
||||
// child: Consumer<DebugInfoModel>(
|
||||
// builder: (BuildContext context, DebugInfoModel debugInfo,
|
||||
// Widget? child) {
|
||||
// return Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: <Widget>[
|
||||
// Text(
|
||||
// 'recv ${debugInfo.recvDataRate}KB/s [${debugInfo.recvPacketCount}]',
|
||||
// style: const TextStyle(
|
||||
// color: Colors.white), // 设置文本颜色为白色
|
||||
// ),
|
||||
// Text(
|
||||
// 'send ${debugInfo.sendDataRate}KB/s [${debugInfo.sendPacketCount}]',
|
||||
// style: const TextStyle(
|
||||
// color: Colors.white), // 设置文本颜色为白色
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// 添加服务器延迟检测
|
||||
// Positioned(
|
||||
// top: 120,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user