OSDP.Net 5.2.1
A .NET library for implementing the Open Supervised Device Protocol (OSDP)
Loading...
Searching...
No Matches
ReplyTracker.cs
1using System;
2
3namespace OSDP.Net.Messages;
4
5internal class ReplyTracker
6{
7 private readonly OutgoingMessage _issuingCommand;
8 private readonly DeviceProxy _device;
9
10 public ReplyTracker(Guid connectionId, IncomingMessage replyMessage, OutgoingMessage issuingCommand,
11 DeviceProxy device)
12 {
13 ConnectionId = connectionId;
14 ReplyMessage = replyMessage;
15 _issuingCommand = issuingCommand;
16 _device = device;
17 }
18
19 public IncomingMessage ReplyMessage { get; }
20
21 public Guid ConnectionId { get; }
22
30 public bool IsValidReply => ReplyMessage.Address == _issuingCommand.Address && ReplyMessage.IsDataCorrect;
31
38 public bool MatchIssuingCommand(byte address, byte commandCode) =>
39 address.Equals(_issuingCommand.Address) && commandCode.Equals(_issuingCommand.Code);
40
41 internal bool ValidateSecureChannelEstablishment()
42 {
43 if (!ReplyMessage.SecureCryptogramHasBeenAccepted())
44 {
45 return false;
46 }
47
48 _device.MessageSecureChannel.Establish(ReplyMessage.Payload);
49
50 return true;
51 }
52}