fix:增加获取锁板peerId的逻辑

This commit is contained in:
liyi 2025-01-14 13:41:23 +08:00
parent 88fbd1cac9
commit 641ff4a2b6

View File

@ -68,7 +68,7 @@ class _LockDetailPageState extends State<LockDetailPage>
lockListInfoItemEntity: widget.lockListInfoItemEntity,
isOnlyOneData: widget.isOnlyOneData);
_handleLockSettingInfoData();
_handleLockMonitor2();
}
@override
@ -1164,10 +1164,7 @@ class _LockDetailPageState extends State<LockDetailPage>
showWidgetArr.add(
bottomItem('images/main/icon_catEyes.png', '监控'.tr,
state.bottomBtnisEable.value, () async {
_handleLockSettingInfoData();
// id
StartChartManage().startCallRequestMessageTimer(
ToPeerId: StartChartManage().lockPeerId ?? '');
await _handleLockMonitor();
}),
);
}
@ -1575,7 +1572,7 @@ class _LockDetailPageState extends State<LockDetailPage>
BlueManage().disconnect();
}
void _handleLockSettingInfoData() async {
Future<void> _handleLockMonitor2() async {
final lockId = state.keyInfos.value.lockId;
final LockSetInfoEntity entity =
await ApiRepository.to.getLockSettingInfoData(
@ -1587,12 +1584,47 @@ class _LockDetailPageState extends State<LockDetailPage>
if (mac != null && mac.isNotEmpty) {
final DeviceNetwork deviceNetworkInfo = await ApiRepository.to
.getDeviceNetwork(deviceType: 2, deviceMac: mac);
final peerId = deviceNetworkInfo?.data?.peerId;
if (peerId == null || peerId.isEmpty) {
throw Exception('设备peerId为空');
if (deviceNetworkInfo.data?.wifiName == null) {
return;
} else {
final peerId = deviceNetworkInfo?.data?.peerId;
if (peerId == null || peerId.isEmpty) {
throw Exception('设备peerId为空');
}
// peerID
StartChartManage().lockPeerId = peerId;
}
}
}
}
Future<void> _handleLockMonitor() 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) {
//
logic.showToast('请先进行配网');
return;
} else {
final peerId = deviceNetworkInfo?.data?.peerId;
if (peerId == null || peerId.isEmpty) {
throw Exception('设备peerId为空');
}
// peerID
StartChartManage().lockPeerId = peerId;
// id
StartChartManage().startCallRequestMessageTimer(
ToPeerId: StartChartManage().lockPeerId ?? '');
}
// peerID
StartChartManage().lockPeerId = peerId;
}
}
}